Exemplo n.º 1
0
        public ScreenManager(GameType gametype, Game1 game)
        {
            menubase        = new Menu_Base(Content_Manager.getInstance().Textures["menubase"]);
            menuoptions     = new Menu_Options(Content_Manager.getInstance().Textures["menuoptions"]);
            menuplay        = new Menu_Play(Content_Manager.getInstance().Textures["menuplay"]);
            menuSolo        = new Menu_Play_Solo(Content_Manager.getInstance().Textures["menusolo"]);
            menusolo1       = new Menu_Play_Solo_World1(Content_Manager.getInstance().Textures["solo1"]);
            menusolo2       = new Menu_Play_Solo_World2(Content_Manager.getInstance().Textures["solo2"]);
            menuMulti       = new Menu_Play_Multi(Content_Manager.getInstance().Textures["menumulti"]);
            menupauseoption = new Menu_Pause_Options(Content_Manager.getInstance().Textures["menupauseoption"]);
            casper          = new Casper(Content_Manager.getInstance().Textures["Casper"], new Rectangle(0, 0, 16, 34));
            player2         = new Casper(Content_Manager.getInstance().Textures["Casper"], new Rectangle(50, 50, 16, 34));
            casper2         = new Casper(Content_Manager.getInstance().Textures["Player1"], new Rectangle(50, 50, 0, 0));
            controls        = new Controls(casper.Position, casper.Velocity, casper.Speed, Keys.W, Keys.A, Keys.D, Keys.S);
            controlsPlayer2 = new Controls(player2.Position, player2.Velocity, player2.Speed, Keys.Up, Keys.Left, Keys.Right, Keys.Down);
            controlsWorld2  = new Controls(casper2.Position, casper2.Velocity, casper2.Speed, Keys.Up, Keys.Left, Keys.Right, Keys.Down);
            world2vert1     = new Decors(Content_Manager.getInstance().Textures["vert"], new Rectangle(-1680, 0, 1680, 1050));
            world2vert2     = new Decors(Content_Manager.getInstance().Textures["vert"], new Rectangle(1680, 0, 1680, 1050));


            camera           = new Camera(Game1.GetGame().GraphicsDevice.Viewport);
            game.casperr     = casper;
            decors           = new Decors(Content_Manager.getInstance().Textures["Level1"], new Rectangle(0, 0, 1680, 1050));
            decors1          = new Decors(Content_Manager.getInstance().Textures["Level1"], new Rectangle(1680, 0, 1680, 1050));
            decors2          = new Decors(Content_Manager.getInstance().Textures["Level1"], new Rectangle(-1680, 0, 1680, 1050));
            world2           = new Decors(Content_Manager.getInstance().Textures["world2"], new Rectangle(0, 0, 1680, 1050));
            menupause        = new Menu_Pause(Content_Manager.getInstance().Textures["menupause"]);
            level1           = new Level1(new Vector2(0, 0));
            obstacles        = new Obstacles(level1.getList());
            previousgametype = GameType.Exit;

            this.gametype = gametype;
        }
Exemplo n.º 2
0
        public void update(GameTime gametime, GameType gametype, Casper casper)
        {
            keyboardState = Keyboard.GetState();
            int delta = gametime.ElapsedGameTime.Milliseconds;

            if (keyboardState.IsKeyDown(Keys.S) && previousKeyboardState.IsKeyUp(Keys.S) || keyboardState.IsKeyDown(Keys.Down) && previousKeyboardState.IsKeyUp(Keys.Down))
            {
                hasJumped = true;
            }

            if (gametype == GameType.Menu_Play_Solo_world1_lvl1 || gametype == GameType.Menu_Play_Solo_world1_lvl2 || gametype == GameType.Menu_Play_Solo_world1_lvl3 || gametype == GameType.Menu_Play_Multi_Type)
            {
                if ((keyboardState.IsKeyUp(Left) && keyboardState.IsKeyUp(Right)) || (keyboardState.IsKeyDown(Left) && keyboardState.IsKeyDown(Right)))
                {
                    if (Velocity.X > 0)
                    {
                        Velocity.X += -Acceleration.X * 3;
                        if (Velocity.X < 0)
                        {
                            Velocity.X = 0f;
                        }
                    }
                    else
                    {
                        Velocity.X += Acceleration.X * 3;
                        if (Velocity.X > 0)
                        {
                            Velocity.X = 0f;
                        }
                    }
                }
                else if (keyboardState.IsKeyDown(Left))
                {
                    if (Velocity.X > 0)
                    {
                        Velocity.X += -Acceleration.X * 3;
                    }
                    else if (Velocity.X > -maxspeed)
                    {
                        Velocity.X += -Acceleration.X;
                    }
                }
                else if (keyboardState.IsKeyDown(Right))
                {
                    if (Velocity.X < 0)
                    {
                        Velocity.X += Acceleration.X * 3;
                    }
                    else if (Velocity.X < maxspeed)
                    {
                        Velocity.X += Acceleration.X;
                    }
                }
                if (keyboardState.IsKeyDown(Up) && hasJumped == false)
                {
                    SoundManager.jump.Play();
                    Velocity.Y += -600;
                    hasJumped   = true;
                }

                if (hasJumped == true)
                {
                    Velocity.Y += Acceleration.Y;
                }


                if (Position.Y > 1015)
                {
                    Position.Y = 1015f;
                    Velocity.Y = 0f;
                    hasJumped  = false;
                }

                previousKeyboardState = keyboardState;
                Velocity         = Collision(casper.Hitbox, level1.getList());
                Position        += Velocity * speed;
                previousPosition = Position;
            }
            else if (gametype == GameType.Menu_Play_Solo_world2_lvl1)
            {
                if ((keyboardState.IsKeyUp(Left) && keyboardState.IsKeyUp(Right)) || (keyboardState.IsKeyDown(Left) && keyboardState.IsKeyDown(Right)))
                {
                    if (Velocity.X > 0)
                    {
                        Velocity.X += -Acceleration.X * 3;
                        if (Velocity.X < 0)
                        {
                            Velocity.X = 0f;
                        }
                    }
                    else
                    {
                        Velocity.X += Acceleration.X * 3;
                        if (Velocity.X > 0)
                        {
                            Velocity.X = 0f;
                        }
                    }
                }
                else if (keyboardState.IsKeyDown(Left))
                {
                    if (Velocity.X > 0)
                    {
                        Velocity.X += -Acceleration.X * 3;
                    }
                    else if (Velocity.X > -maxspeed)
                    {
                        Velocity.X += -Acceleration.X;
                    }
                }
                else if (keyboardState.IsKeyDown(Right))
                {
                    if (Velocity.X < 0)
                    {
                        Velocity.X += Acceleration.X * 3;
                    }
                    else if (Velocity.X < maxspeed)
                    {
                        Velocity.X += Acceleration.X;
                    }
                }

                if ((keyboardState.IsKeyUp(Up) && keyboardState.IsKeyUp(Down)) || (keyboardState.IsKeyDown(Up) && keyboardState.IsKeyDown(Down)))
                {
                    if (Velocity.Y > 0)
                    {
                        Velocity.Y += -Acceleration.Y * 3;
                        if (Velocity.Y < 0)
                        {
                            Velocity.Y = 0f;
                        }
                    }
                    else
                    {
                        Velocity.Y += Acceleration.Y * 3;
                        if (Velocity.Y > 0)
                        {
                            Velocity.Y = 0f;
                        }
                    }
                }
                else if (keyboardState.IsKeyDown(Up))
                {
                    if (Velocity.Y > 0)
                    {
                        Velocity.Y += -Acceleration.Y * 3;
                    }
                    else if (Velocity.Y > -maxspeed)
                    {
                        Velocity.Y += -Acceleration.Y;
                    }
                }
                else if (keyboardState.IsKeyDown(Down))
                {
                    if (Velocity.Y < 0)
                    {
                        Velocity.Y += Acceleration.Y * 3;
                    }
                    else if (Velocity.Y < maxspeed)
                    {
                        Velocity.Y += Acceleration.Y;
                    }
                }

                previousKeyboardState = keyboardState;

                Position += Velocity * speed;
            }
        }
Exemplo n.º 3
0
        public ScreenManager(GameType gametype, Game1 game)
        {
            menubase = new Menu_Base(Content_Manager.getInstance().Textures["menubase"]);
            menuoptions = new Menu_Options(Content_Manager.getInstance().Textures["menuoptions"]);
            menuplay = new Menu_Play(Content_Manager.getInstance().Textures["menuplay"]);
            menuSolo = new Menu_Play_Solo(Content_Manager.getInstance().Textures["menusolo"]);
            menusolo1 = new Menu_Play_Solo_World1(Content_Manager.getInstance().Textures["solo1"]);
            menusolo2 = new Menu_Play_Solo_World2(Content_Manager.getInstance().Textures["solo2"]);
            menuMulti = new Menu_Play_Multi(Content_Manager.getInstance().Textures["menumulti"]);
            menupauseoption = new Menu_Pause_Options(Content_Manager.getInstance().Textures["menupauseoption"]);
            casper = new Casper(Content_Manager.getInstance().Textures["Casper"], new Rectangle(0, 0, 16, 34));
            player2 = new Casper(Content_Manager.getInstance().Textures["Casper"], new Rectangle(50, 50, 16, 34));
            casper2 = new Casper(Content_Manager.getInstance().Textures["Player1"], new Rectangle(50, 50, 0, 0));
            controls = new Controls(casper.Position, casper.Velocity, casper.Speed, Keys.W, Keys.A, Keys.D, Keys.S);
            controlsPlayer2 = new Controls(player2.Position, player2.Velocity, player2.Speed, Keys.Up, Keys.Left, Keys.Right, Keys.Down);
            controlsWorld2 = new Controls(casper2.Position, casper2.Velocity, casper2.Speed, Keys.Up, Keys.Left, Keys.Right, Keys.Down);
            world2vert1 = new Decors(Content_Manager.getInstance().Textures["vert"], new Rectangle(-1680, 0, 1680, 1050));
            world2vert2 = new Decors(Content_Manager.getInstance().Textures["vert"], new Rectangle(1680, 0, 1680, 1050));

            camera = new Camera(Game1.GetGame().GraphicsDevice.Viewport);
            game.casperr = casper;
            decors = new Decors(Content_Manager.getInstance().Textures["Level1"], new Rectangle(0, 0, 1680, 1050));
            decors1 = new Decors(Content_Manager.getInstance().Textures["Level1"], new Rectangle(1680, 0, 1680, 1050));
            decors2 = new Decors(Content_Manager.getInstance().Textures["Level1"], new Rectangle(-1680, 0, 1680, 1050));
            world2 = new Decors(Content_Manager.getInstance().Textures["world2"], new Rectangle(0, 0, 1680, 1050));
            menupause = new Menu_Pause(Content_Manager.getInstance().Textures["menupause"]);
            level1 = new Level1(new Vector2(0, 0));
            obstacles = new Obstacles(level1.getList());
            previousgametype = GameType.Exit;

            this.gametype = gametype;
        }