Beispiel #1
0
 public Barrel(StateHandler _state,int posX, int posY)
     : base(_state,posX,posY)
 {
     _statehandler = _state;
     _statecount = 0;
     _goingright = true;
 }
Beispiel #2
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();
        }
 public GraphicsObject(StateHandler _state,int posX, int posY)
 {
     Xpos = posX;
     Ypos = posY;
     _statehandler = _state;
     loadbitmap ();
 }
        public void TestCaseStateHandling()
        {
            StateHandler s = new StateHandler ();

            // check all default states
            Assert.IsTrue (s.Gamestate == GameState.Menu);
            Assert.IsTrue (s.Menustate == MenuState.MainMenu);
            Assert.IsTrue (s.Levelstate == LevelState.Level1);
            Assert.IsTrue (s.Transitionstate == TransitionState.LevelStart);
            Assert.IsTrue (s.Characterstate == CharacterState.Standing);

            //check gamestate transitions
            s.ChangeState(GameState.Game);
            s.Run ();
            Assert.IsTrue(s.Gamestate == GameState.Game);

            s.ChangeState(GameState.Menu);
            s.Run ();
            Assert.IsTrue(s.Gamestate == GameState.Menu);

            s.ChangeState(GameState.Transition);
            s.Run ();
            Assert.IsTrue(s.Gamestate == GameState.Transition);

            // check menu state transtitons
            s.ChangeState(MenuState.ViewingScores);
            s.Run ();
            Assert.IsTrue(s.Menustate == MenuState.ViewingScores);

            // check level state transition
            s.ChangeState(LevelState.Level2);
            s.Run ();
            Assert.IsTrue(s.Levelstate == LevelState.Level2);

            // check transition state
            s.ChangeState(TransitionState.WinScreen);
            s.Run ();
            Assert.IsTrue(s.Transitionstate == TransitionState.WinScreen);

            //check character state transition
            s.ChangeState(CharacterState.Jumping);
            s.Run ();
            Assert.IsTrue(s.Characterstate == CharacterState.Jumping);
        }
        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);
        }
        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);
        }
 public GraphicsHandler(StateHandler _state,ObjectsHandler _object)
 {
     _objecthandler = _object;
     _statehandler = _state;
 }
Beispiel #8
0
 public Mario(StateHandler _state,int posX, int posY)
     : base(_state,posX,posY)
 {
 }
Beispiel #9
0
 public Luigi(StateHandler _state,int posX, int posY)
     : base(_state,posX,posY)
 {
 }
Beispiel #10
0
 public Input_Handler(StateHandler _state,ObjectsHandler _object)
 {
     _statehandler = _state;
     _objecthandler = _object;
 }