Пример #1
0
        public static void Main()
        {
            //Start the audio system so sound can be played
            SwinGame.OpenAudio();
            //Open the game window
            SwinGame.OpenGraphicsWindow("GameMain", 800, 600);
            SwinGame.ShowSwinGameSplashScreen();
            StateHandler _statehandler = new StateHandler ();
            ObjectsHandler _objecthandler = new ObjectsHandler (_statehandler);
            Input_Handler _inputhandler = new Input_Handler(_statehandler,_objecthandler);
            GraphicsHandler _graphicshandler = new GraphicsHandler (_statehandler,_objecthandler);

            //Run the game loop
            while(false == SwinGame.WindowCloseRequested())
            {
                //Fetch the next batch of UI interaction
                SwinGame.ProcessEvents();
                //Clear the screen and draw the framerate
                SwinGame.ClearScreen(Color.Black);
                _graphicshandler.Run ();
                _inputhandler.Run ();
                _statehandler.Run ();
                _objecthandler.Run ();

                SwinGame.DrawFramerate(0,0);
                //Draw onto the screen
                SwinGame.RefreshScreen();
                System.Threading.Thread.Sleep (2);
            }
            //End the audio
            SwinGame.CloseAudio();

            //Close any resources we were using
            SwinGame.ReleaseAllResources();
        }
Пример #2
0
        public void TestCaseCharPosReset()
        {
            // test that character starts in default position after the level resets
            StateHandler sh = new StateHandler ();
            ObjectsHandler oh = new ObjectsHandler (sh);
            Input_Handler ih = new Input_Handler(sh,oh);

            Character c = oh.LevelCharacter;
            c.Xpos = 150;
            c.Ypos = 250;

            ih.ResetCharacter ();

            // check that is at defualt pos
            Assert.IsTrue (c.Xpos == 110);
            Assert.IsTrue (c.Ypos == 552);
            Assert.IsTrue (sh.Gamestate == GameState.Menu);
            Assert.IsTrue (sh.Characterstate == CharacterState.Standing);
        }
Пример #3
0
        public void TestCaseBarrelCollide()
        {
            // test character dies when hit by barrel
            StateHandler s = new StateHandler ();
            ObjectsHandler h = new ObjectsHandler (s);

            // adds a barrel at location 100,119
            h.AddBarrel ();
            Character c = h.LevelCharacter;
            c.Xpos = 100;
            c.Ypos = 119;
            Assert.IsTrue (h.LevelCharacter.Xpos == 100);
            Assert.IsTrue (h.LevelCharacter.Ypos == 119);
            Assert.IsTrue (s.Characterstate == CharacterState.Standing);

            h.LevelCharacterObject ();
            s.Run ();
            Assert.IsTrue (s.Characterstate == CharacterState.Dying);
        }
Пример #4
0
 public GraphicsHandler(StateHandler _state,ObjectsHandler _object)
 {
     _objecthandler = _object;
     _statehandler = _state;
 }
Пример #5
0
 public Input_Handler(StateHandler _state,ObjectsHandler _object)
 {
     _statehandler = _state;
     _objecthandler = _object;
 }