Ejemplo n.º 1
0
 private void Awake()
 {
     Instance = this;
     Application.targetFrameRate = 30;
     DontDestroyOnLoad(gameObject);
     gameObject.AddComponent <Loom>();
 }
Ejemplo n.º 2
0
 public override void MatchedTilesAsBonus(GameDriver driver, TileType matchedType)
 {
     if (Random.Range(0, 100) <= bonusChance) {
         driver.AddStats(matchedType, 3, matchedType);
         driver.AddBonus(type);
     }
 }
Ejemplo n.º 3
0
        public static List <Toy> Perform(GameDriver driver)
        {
            Log.Debug("Loading: Toys");
            var toysFolder = DataPath.Get("Toys");
            var toyFiles   = Directory.GetFiles(toysFolder);

            var toys = new List <Toy>();

            foreach (var toyFile in toyFiles)
            {
                var toy = JsonData.DeserializeFromFile <Toy>(toyFile);
                toy.Active = false;
                toy.Name   = Path.GetFileNameWithoutExtension(toyFile);
                foreach (var damage in toy.DamagePoints)
                {
                    damage.Active = true;
                }

                if (driver.CurrentToy != null && toy.Name == driver.CurrentToy.Name)
                {
                    toy.Active        = true;
                    driver.CurrentToy = toy;
                }

                toys.Add(toy);
            }

            return(toys);
        }
Ejemplo n.º 4
0
 //
 //Call this from the cube when placement is cancelled
 //
 public static void cancelPlaceCube()
 {
     GameObject.Destroy(gameDriver.cubeSelected);
     gameDriver.cubeSelected    = null;
     StateMachine.isPlacingCube = false;
     GameDriver.selectLightOff();
 }
Ejemplo n.º 5
0
    //////////////////Static stuff for calling easily from outside//////////////////////////////////


    //
    //Call this from the cube when it is placed
    //
    public static void placedCube()
    {
        if (gameDriver.addPlayerPoints(StateMachine.currentTurn(), gameDriver.cubeSelected.GetComponent <UnitClass>().cost) == -1)
        {
            print("Something went wrong with the player point counts!");
        }
        gameDriver.cubesInPlay.Add(gameDriver.cubeSelected);
        if (gameDriver.cubeSelected.GetComponent <UnitClass>().unitClass == className.King)
        {
            if (StateMachine.currentTurn() == 1)
            {
                StateMachine.p1KingPlaced();
            }
            else if (StateMachine.currentTurn() == 2)
            {
                StateMachine.p2KingPlaced();
            }
            else
            {
                print("That king was placed on no particular player's turn!");
            }
        }
        gameDriver.cubeSelected    = null;
        StateMachine.isPlacingCube = false;
        GameDriver.updatePointInterface();
        StateMachine.passTurn();
    }
Ejemplo n.º 6
0
 //Constructor-MainPage
 public MainPage()
 {
     this.InitializeComponent();
     _GameDriver = new GameDriver(CanvasPlayingArea, btnPauseGame, btnResumeGame, btnStartNewgame, btnSaveFile, btnLoadFile, _IsGameLoaded, GaneOverContentDialog, YouWinContentDialog, PauseContentDialog, txtLifesLeft); //Initialize GameDriver and pass OUR Canvas, and BUTTONS to it so we can use them in GameDriver.cs
     Window.Current.CoreWindow.KeyDown += CoreWindow_KeyDown;                                                                                                                                                              //Register the KeyDown Event with a CoreWindow_KeyDown Method
     SetButtonsToNewGameState();                                                                                                                                                                                           //Start button state
 }
Ejemplo n.º 7
0
    //Dealing with Healer interactions

    public static void healerActivated()
    {
        gameDriver.healerPoints = 0;
        GameDriver.showHealerInterface();
        StateMachine.healerPhase();
        updateHealerInterface();
    }
        private void TidesOfMadnessForm_Load(object sender, EventArgs e)
        {
            driver = new GameDriver();
            driver.InitializeGame();
            UpdateGameLog(driver.GetGameLog());
            UpdateScoreDisplays();

            pbxCardImage.SizeMode = PictureBoxSizeMode.StretchImage;


            lbxHumanHand.DataSource    = driver.GetHumanPlayer().GetCardsInHand();
            lbxHumanHand.DisplayMember = "CardNameDisplay";

            lbxHumanInPlay.DataSource    = driver.GetHumanPlayer().GetCardsInPlay();
            lbxHumanInPlay.DisplayMember = "CardNameDisplay";

            lbxOppInPlay.DataSource    = driver.GetAIPlayer().GetCardsInPlay();
            lbxOppInPlay.DisplayMember = "CardNameDisplay";

            lbxDiscardPile.DataSource    = driver.GameState.DiscardPile.CardsInCollection;
            lbxDiscardPile.DisplayMember = "CardNameDisplay";

            pbxCardImage.ImageLocation = SetArtFromListBox(lbxHumanHand, 0);

            UpdatePlayerInstructions(driver.GetCurrentGameState(), lblPlayerInstructions);
            UpdateUISettings(driver.GetCurrentGameState());
        }
Ejemplo n.º 9
0
        public static GameInterface Initialize(GameDriver driver)
        {
            Log.Message("Initializing: Game Interface");
            var path = DataPath.Get("UI\\GameUI.json");

            return(JsonData.DeserializeFromFile <GameInterface>(path));
        }
Ejemplo n.º 10
0
    //TODO: Add messages for each condition., rearrange conditions
    void OnMouseDown()
    {
        if ((StateMachine.turnState != Turn.pause) && (StateMachine.getPhase() == GamePhase.battle) &&
            (playState == PlayState.idle) && (!StateMachine.isCubeLaunched) && (StateMachine.currentTurn() == unit.owner))
        {
            //Check for special units
            if (unit.unitClass == className.Healer)
            {
                GameDriver.healerActivated();
                GameDriver.removeCubeFromPlay(this.gameObject);
            }
            //Slect normal cube to flick
            else if ((flick == false) && (stun == false))
            {
                hitPos       = this.gameObject.transform.position;
                launcherY    = this.gameObject.transform.position.y;
                maxHitPosY   = hitPos.y + this.gameObject.GetComponent <Renderer> ().bounds.extents.y;
                minHitPosY   = hitPos.y - this.gameObject.GetComponent <Renderer> ().bounds.extents.y;
                maxlauncherY = maxHitPosY + this.gameObject.GetComponent <Renderer> ().bounds.extents.y;
                minlauncherY = minHitPosY - this.gameObject.GetComponent <Renderer> ().bounds.extents.y;


                isKinematic = true;
                UpdatelaunchVelocity();
                LaunchLine.launchLine.Enabled(true);
                GameDriver.selectLightOn(this.gameObject);
                changeToAiming = true;
                //playState = PlayState.aiming;
            }
        }
    }
Ejemplo n.º 11
0
 void OnCollisionEnter(Collision other)
 {
     if (unit.unitClass == className.Paralyze)
     {
         if (other.gameObject.GetComponent <Cube>() != null)
         {
             if (other.gameObject.GetComponent <UnitClass> ().owningPlayer != unit.owningPlayer &&
                 unit.unitClass != className.Paralyze)
             {
                 other.gameObject.GetComponent <Cube>().stunned = true;
             }
         }
     }
     else if (unit.unitClass == className.Bomb && StateMachine.gamePhase == GamePhase.battle)
     {
         Collider[] explosionHit = Physics.OverlapSphere(this.gameObject.transform.position, GetComponent <UnitClass>().attack);
         foreach (Collider hit in explosionHit)
         {
             if (hit.gameObject.GetComponent <Rigidbody>() != null)
             {
                 hit.gameObject.GetComponent <Rigidbody>().AddExplosionForce(GetComponent <UnitClass>().attack *250, this.gameObject.transform.position, GetComponent <UnitClass>().attack);
             }
         }
         GameDriver.checkCubeMovement();
         GameDriver.removeCubeFromPlay(this.gameObject);
     }
 }
Ejemplo n.º 12
0
 public static void Initialize(GameDriver driver)
 {
     _driver              = driver;
     _font                = driver.Content.Load <SpriteFont>("Fonts/DebugFont");
     _spriteBatch         = new SpriteBatch(driver.GraphicsDevice);
     _driver.Window.Title = "The Toymaker";
 }
Ejemplo n.º 13
0
 public static void Perform(GameDriver driver)
 {
     if (KeyInput.JustPressed(Keys.Escape))
     {
         driver.Exit();
     }
 }
Ejemplo n.º 14
0
        protected override void OnConnected(Client client)
        {
            var state = new GameState();
            var me = new InteractivePlayer(Name, state);
            var driver= new GameDriver(me, state, client);

            while (driver.Dispatch(client.ReadLine())) ;
        }
Ejemplo n.º 15
0
        public static PaintingKit Perform(GameDriver driver)
        {
            Log.Debug("Loading: Painting Kit");
            var elementsFolder = DataPath.Get("Elements");
            var path           = Path.Combine(elementsFolder, "PaintingKit.json");

            return(JsonData.DeserializeFromFile <PaintingKit>(path));
        }
Ejemplo n.º 16
0
        public static DeskClock Perform(GameDriver driver)
        {
            Log.Debug("Loading: Desk Clock");
            var elementsFolder = DataPath.Get("Elements");
            var path           = Path.Combine(elementsFolder, "DeskClock.json");

            return(JsonData.DeserializeFromFile <DeskClock>(path));
        }
Ejemplo n.º 17
0
 public static void endSetup()
 {
     foreach (GameObject obj in gameDriver.setupInterfaceObjects)
     {
         obj.SetActive(false);
     }
     GameDriver.startBattle();
 }
Ejemplo n.º 18
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.tag.Equals("Cube"))
     {
         GameDriver.removeCubeFromPlay(collision.gameObject);
         GameDriver.checkCubeMovement();
     }
 }
Ejemplo n.º 19
0
 public static void initiateTurns()
 {
     if (state == GameState.active)
     {
         turnState = Turn.player1;
         GameDriver.updateTurnInterface();
     }
 }
Ejemplo n.º 20
0
 public static void endSetup()
 {
     GameDriver.hidePointHider();
     GameDriver.hideSetupHider();
     GameDriver.hideSetupInterface();
     GameDriver.hidePointInterface();
     GameDriver.startBattle();
 }
Ejemplo n.º 21
0
        public void TestInvalidInputException()
        {
            var file = "InvalidInput.txt";

            string[]   inputs     = inputReader.ReadInput(file);
            GameDriver gameDriver = new GameDriver(logger);

            gameDriver.ValidateInputs(inputs);
        }
        public static void Perform(GameDriver driver)
        {
            if (!KeyInput.JustPressed(Keys.F1))
            {
                return;
            }

            driver.GameInterface = GameInterface.Initialize(driver);
        }
Ejemplo n.º 23
0
        public void Play_WontPlayIfAlreadyFinished()
        {
            var game = new Mock<IDartsGame>();
            game.Setup(g => g.Finished).Returns(true);

            var gameDriver = new GameDriver(game.Object);
            gameDriver.Play();

            game.Verify(g => g.PlayNextTurn(), Times.Never);
        }
Ejemplo n.º 24
0
 public SysDriver(FantasyConsole fc)
 {
     _fc                   = fc;
     _drivers              = new List <Driver>();
     _drivers.Add(FS       = new FileSystemDriver());
     _drivers.Add(Input    = new InputDriver(_fc.Mem.InputBuffer));
     _drivers.Add(Console  = new ConsoleDriver(_fc.Mem.TextBuffer));
     _drivers.Add(Graphics = new GraphicsDriver(_fc.Mem));
     _drivers.Add(Menu     = new MenuDriver(Input, Console));
     _drivers.Add(Game     = new GameDriver(this, _fc.Mem));
 }
Ejemplo n.º 25
0
 private void OnCollisionEnter(Collision collision)
 {
     if (collision.gameObject.tag.Equals("Cube"))
     {
         if (collision.gameObject.GetComponent <Cube> ().playState == PlayState.launch && collision.gameObject.GetComponent <UnitClass>().unitClass != className.King)
         {
             GameDriver.checkCubeMovement();
         }
         GameDriver.removeCubeFromPlay(collision.gameObject);
     }
 }
Ejemplo n.º 26
0
 private void Awake()
 {
     DontDestroyOnLoad(this.gameObject);
     if (gd == null)
     {
         gd = this;
     }
     else if (gd != this)
     {
         Destroy(this.gameObject);
     }
 }
Ejemplo n.º 27
0
        protected override void OnConnected(Client client)
        {
            var state = new GameState();
            var me = new RandomPlayer(Name, state);
            var driver= new GameDriver(me, state, client);

            while (driver.Dispatch(client.ReadLine())) ;

            Console.WriteLine();
            Console.WriteLine("Press Enter to exit...");
            Console.ReadLine();
        }
Ejemplo n.º 28
0
        public static void Perform(GameDriver driver)
        {
            var currentToy = driver.CurrentToy;

            if (!currentToy.IsFixed)
            {
                return;
            }

            HandleHotspotInteraction.SendCurrentToolToStart();
            driver.ChangeState(GameState.ClientPayment);
        }
Ejemplo n.º 29
0
 public override void AddStatsAsBonus(GameDriver driver, TileType statsType, float amount, TileType primaryType)
 {
     if (primaryType == TileType.None) {
         return; // this was an cascading or auto-match, ignore it
     }
     float now = driver.GetTime();
     if (lastMatch != Mathf.Infinity && now - lastMatch < bonusThreshold) {
         driver.AddBonus(type, bonusAmount);
     }
     lastMatch = now;
     return;
 }
Ejemplo n.º 30
0
        public void TestGameDraw()
        {
            var file = "Input3.txt";

            string[]   input      = inputReader.ReadInput(file);
            GameDriver gameDriver = new GameDriver(logger);

            gameDriver.Start(input);
            string winner = "None";

            Assert.AreEqual(winner, gameDriver.Winner);
        }
Ejemplo n.º 31
0
        public static DeskClock Initialize(GameDriver driver)
        {
            var path  = DataPath.Get("Elements\\DeskClock.json");
            var clock = JsonData.DeserializeFromFile <DeskClock>(path);

            clock.Hour   = 8;
            clock.Minute = 0;
            clock.MinuteHandTransform.Angle = 0.0f;
            clock.HourHandTransform.Angle   = 240.0f;
            clock._minuteAngle = 0.0f;
            return(clock);
        }
Ejemplo n.º 32
0
        public GameEntry() : base()
        {
            m_DriverObject = new GameObject("GameDriver");
            GameObject.DontDestroyOnLoad(m_DriverObject);
            GameDriver driverComp = m_DriverObject.AddComponent <GameDriver>();

            driverComp.Init(this);

            m_FrameWorkEntry = new FrameWorkEntry();

            IsEditor = true;
            Init();
        }
Ejemplo n.º 33
0
 public override void UpdateAsBonus(GameDriver driver)
 {
     // each second after a match, has bonusChance to automatch
     if (driver.board.IsNewIdleSecond
         && Random.Range(0, 100) < bonusChance) {
         PairInt position, direction;
         if (driver.board.FindMatch(out position, out direction)) {
             driver.board.SwapTile(position, direction, false);
             driver.board.CreateHintOneShot(position, direction, hintArrowRobot);
             driver.AddBonus(type);
         }
     }
 }
Ejemplo n.º 34
0
        public void Play_KeepsPlayingTurnUntilGameIsFinished()
        {
            var game = new Mock<IDartsGame>();
            game.SetupSequence(g => g.Finished)
                .Returns(false)
                .Returns(false)
                .Returns(true);

            var gameDriver = new GameDriver(game.Object);
            gameDriver.Play();

            game.Verify(g => g.PlayNextTurn(), Times.Exactly(2));
        }
Ejemplo n.º 35
0
 public static void battlePhase()
 {
     if (state == GameState.active)
     {
         gamePhase = GamePhase.battle;
         GameDriver.gameDriver.p1Side.SetActive(false);
         GameDriver.gameDriver.p2Side.SetActive(false);
         if ((flickableCubesAvailable(1) == 0) && (flickableCubesAvailable(2) == 0))
         {
             GameDriver.resolveStalemate();
         }
     }
 }
Ejemplo n.º 36
0
    //场景功能
    #region

    #endregion
    GameCtrl()
    {
        //CenceCtroler = new CenceCtrl();
        GameObject modelCtrler = Resources.Load("Prefab\\Base\\GameControler") as GameObject;

        if (modelCtrler != null)
        {
            GameObject driverObj = GameObject.Instantiate(modelCtrler);
            _GameDriver = driverObj.GetComponent <GameDriver>();
            _Pool       = driverObj.GetComponent <SpawnPool>();
        }
        //_SceneMgr = SceneMgr.Mgr;
    }
Ejemplo n.º 37
0
        private static void SearchForGrabbed(GameDriver driver)
        {
            if (!MouseInput.LeftButtonJustPressed)
            {
                return;
            }

            foreach (var hotspot in driver.HotSpots)
            {
                var transform = hotspot.Transform;
                if (!IsGrabbed(transform))
                {
                    continue;
                }

                Grab(transform, null, $"Hotspot: {hotspot.Name}");
                return;
            }

            foreach (var toy in driver.Toys)
            {
                foreach (var damagePoint in toy.DamagePoints)
                {
                    var transform = damagePoint.Transform;
                    if (!IsGrabbed(damagePoint.GetGlobalTransform()))
                    {
                        continue;
                    }

                    Grab(transform, GameDriver.Instance.GameInterface.ToyLocationInFront, $"DamagePoint: {damagePoint.Type}");
                    return;
                }
            }

            if (IsGrabbed(driver.Clock.HourHandTransform))
            {
                Grab(driver.Clock.HourHandTransform, null, "Clock: Hour Hand");
            }
            else if (IsGrabbed(driver.Clock.MinuteHandTransform))
            {
                Grab(driver.Clock.MinuteHandTransform, null, "Clock: Minute Hand");
            }
            else if (IsGrabbed(driver.SewingKit.Transform))
            {
                Grab(driver.SewingKit.Transform, null, "SewingKit");
            }
            else if (IsGrabbed(driver.PaintingKit.Transform))
            {
                Grab(driver.PaintingKit.Transform, null, "PaintingKit");
            }
        }
Ejemplo n.º 38
0
        public void ADarts301GameCanBePlayed()
        {
            var playerAMockThrower = new Mock<IDartsThrower>();
            playerAMockThrower.SetupSequence(dt => dt.ThrowDart()).Returns(60).Returns(60).Returns(60).Returns(60).Returns(60).Returns(1);
            var playerBMockThrower = new Mock<IDartsThrower>();
            playerBMockThrower.Setup(dt => dt.ThrowDart()).Returns(20);

            var game = new Darts301Game(
                            new DartsPlayer(playerAMockThrower.Object),
                            new DartsPlayer(playerBMockThrower.Object));
            var gameDriver = new GameDriver(game);
            gameDriver.Play();

            Assert.True(game.Finished);
            Assert.Equal(game.Winner, game.Players.First());
        }
Ejemplo n.º 39
0
 public override void MatchedTilesAsBonus(GameDriver driver, TileType matchedType)
 {
     if (driver.GetCurrentAntiStreak() >= 4) {
         driver.AddBonus(type, bonusAmount);
     }
 }
Ejemplo n.º 40
0
 int load_datafile_text(GameDriver drv, ref string buffer, int bufsize, tDatafileIndex[] idx, string tag)
 {
     throw new Exception();
 }
Ejemplo n.º 41
0
 public virtual void UpdateAsBonus(GameDriver driver)
 {
 }
Ejemplo n.º 42
0
    void Start()
    {
        if(instance != null) {
            Destroy(gameObject);
            return;
        }
        instance = this;
        DontDestroyOnLoad(gameObject);

        if(currentLevel == null) {
            currentLevel = GameConfig.instance.levels[0];
        }
        InitLevel();
    }
Ejemplo n.º 43
0
 public virtual void AddStatsAsBonus(GameDriver driver, TileType statsType, float amount, TileType primaryType)
 {
 }
Ejemplo n.º 44
0
 public virtual void MatchedTilesAsBonus(GameDriver driver, TileType matchedType)
 {
 }
Ejemplo n.º 45
0
 // Use this for initialization
 void Start()
 {
     health = maxHealth;
     beats = new List<GameObject>();
     markPosition = transform.Find("PulseMark").transform.localPosition.x;
     bgMat = transform.Find("PulseBackground").GetComponent<LineRenderer>().material;
     gameState = GameObject.Find("GameState").GetComponent<GameState>();
     gameDriver = GameObject.Find("GameDriver").GetComponent<GameDriver>();
     tm = GameObject.Find("TypeMaster").GetComponent<TypeMaster>();
     heart = GameObject.Find("Heart");
     if (gameState.gameConfig != null)
         beatDelay = 60f / gameState.gameConfig.rate;
 }
Ejemplo n.º 46
0
 public override void UpdateAsBonus(GameDriver driver)
 {
     if (driver.board.HandleHint(hintCooldown, hintArrowHoly)) {
         driver.AddBonus(type);
     }
 }
Ejemplo n.º 47
0
        bool load_driver_history(GameDriver drv, ref string buffer)
        {
            bool history = false, mameinfo = false;
            int err;

            buffer = "";

            if (history_filename == null)
                history_filename = "history.dat";

            /* try to open history datafile */
            if (ParseOpen(history_filename))
            {
                /* create index if necessary */
                if (hist_idx != null)
                    history = true;
                else
                    history = (index_datafile(ref hist_idx) != 0);

                /* load history text */
                if (hist_idx != null)
                {
                    GameDriver gdrv = drv;

                    do
                    {
                        err = load_datafile_text(gdrv, ref  buffer, bufsize, hist_idx, DATAFILE_TAG_BIO);
                        gdrv = gdrv.clone_of;
                    } while (err != 0 && gdrv != null);

                    if (err != 0) history = false;
                }
                ParseClose();
            }

            if (mameinfo_filename == null)
                mameinfo_filename = "mameinfo.dat";

            /* try to open mameinfo datafile */
            if (ParseOpen(mameinfo_filename))
            {
                /* create index if necessary */
                if (mame_idx != null)
                    mameinfo = true;
                else
                    mameinfo = (index_datafile(ref mame_idx) != 0);

                /* load informational text (append) */
                if (mame_idx != null)
                {
                    int len = buffer.Length;
                    GameDriver gdrv = drv;

                    gdrv = drv; do
                    {
                        err = load_datafile_text(gdrv, ref buffer, bufsize - len, mame_idx, DATAFILE_TAG_MAME);
                        gdrv = gdrv.clone_of;
                    } while (err != 0 && gdrv != null);

                    if (err != 0) mameinfo = false;
                }
                ParseClose();
            }

            return (history == false && mameinfo == false);
        }
Ejemplo n.º 48
0
 // Use this for initialization
 void Start()
 {
     driver = GameObject.Find("GameDriver").GetComponent<GameDriver>();
     squareMask = 1 << LayerMask.NameToLayer("Square");
     selection = transform.FindChild("Selection").gameObject;
     selection.SetActive(false);
     InitBoard();
 }
Ejemplo n.º 49
0
        int run_game(string game)
        {
            int err;

            Machine.gamedrv = gamedrv = GetDriver(game);
            Machine.drv = drv = gamedrv.drv;

            /* copy configuration */
            if (options.color_depth == 16 ||
                    (options.color_depth != 8 && (Machine.gamedrv.flags & GAME_REQUIRES_16BIT) != 0))
                Machine.color_depth = 16;
            else
                Machine.color_depth = 8;
            Machine.sample_rate = options.samplerate;

            /* get orientation right */
            Machine.orientation = (int)(gamedrv.flags & ORIENTATION_MASK);
            Machine.ui_orientation = ROT0;
            if (options.norotate)
                Machine.orientation = ROT0;
            if (options.ror)
            {
                /* if only one of the components is inverted, switch them */
                if ((Machine.orientation & ROT180) == ORIENTATION_FLIP_X ||
                        (Machine.orientation & ROT180) == ORIENTATION_FLIP_Y)
                    Machine.orientation ^= ROT180;

                Machine.orientation ^= ROT90;

                /* if only one of the components is inverted, switch them */
                if ((Machine.ui_orientation & ROT180) == ORIENTATION_FLIP_X ||
                        (Machine.ui_orientation & ROT180) == ORIENTATION_FLIP_Y)
                    Machine.ui_orientation ^= ROT180;

                Machine.ui_orientation ^= ROT90;
            }
            if (options.rol)
            {
                /* if only one of the components is inverted, switch them */
                if ((Machine.orientation & ROT180) == ORIENTATION_FLIP_X ||
                        (Machine.orientation & ROT180) == ORIENTATION_FLIP_Y)
                    Machine.orientation ^= ROT180;

                Machine.orientation ^= ROT270;

                /* if only one of the components is inverted, switch them */
                if ((Machine.ui_orientation & ROT180) == ORIENTATION_FLIP_X ||
                        (Machine.ui_orientation & ROT180) == ORIENTATION_FLIP_Y)
                    Machine.ui_orientation ^= ROT180;

                Machine.ui_orientation ^= ROT270;
            }
            if (options.flipx)
            {
                Machine.orientation ^= ORIENTATION_FLIP_X;
                Machine.ui_orientation ^= ORIENTATION_FLIP_X;
            }
            if (options.flipy)
            {
                Machine.orientation ^= ORIENTATION_FLIP_Y;
                Machine.ui_orientation ^= ORIENTATION_FLIP_Y;
            }
            set_pixel_functions();

            /* Do the work*/
            err = 1;
            bailing = 0;
            if (osd_init() == 0)
            {
                if (init_machine() == 0)
                {
                    if (run_machine() == 0)
                        err = 0;
                    else if (bailing == 0)
                    {
                        bailing = 1;
                        printf("Unable to start machine emulation\n");
                    }

                    shutdown_machine();
                }
                else if (bailing == 0)
                {
                    bailing = 1;
                    printf("Unable to initialize machine emulation\n");
                }

                osd_exit();
            }
            else if (bailing == 0)
            {
                bailing = 1;
                printf("Unable to initialize system\n");
            }

            return err;
        }