Ejemplo n.º 1
0
Archivo: Player.cs Proyecto: msokk/Hype
 /// <summary>
 /// Construct new Player
 /// </summary>
 /// <param name="playerIndex">Character texture index</param>
 public Player(Level level, String playerIndex)
 {
     this.level = level;
     texture = Level.Content.Load<Texture2D>("Player/" + playerIndex);
     this.location = new Vector2(level.levelWidth - 160, level.levelHeight - 60 - texture.Height);
     dieSound = Level.Content.Load<SoundEffect>("Sounds/playerDeath");
     jumpSound = Level.Content.Load<SoundEffect>("Sounds/jump");
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Updates selection screen with input
        /// </summary>
        public void Update(GameTime gameTime, KeyboardState keyboardState, GamePadState gamePadState, GamePadState genericPadState, Level level)
        {
            if (keyboardState.IsKeyDown(Keys.Enter) || gamePadState.IsButtonDown(Buttons.Start)
                || genericPadState.IsButtonDown(Buttons.A))
            {
                characterselected = true;
                level.Start(getPlayerIndex());
            }

            //Normalized Thumbstick controls
            Vector2 gamePadAxis = new Vector2((float)Math.Round(gamePadState.ThumbSticks.Left.X, 1),
                (float)Math.Round(gamePadState.ThumbSticks.Left.Y, 1));
            Vector2 genericPadAxis = new Vector2((float)Math.Round(genericPadState.ThumbSticks.Left.X, 1),
                (float)Math.Round(genericPadState.ThumbSticks.Left.Y, 1));
            Vector2 oldGamePadAxis = new Vector2((float)Math.Round(oldGamePadState.ThumbSticks.Left.X, 1),
                (float)Math.Round(oldGamePadState.ThumbSticks.Left.Y, 1));
            Vector2 oldGenericPadAxis = new Vector2((float)Math.Round(oldGenericPadState.ThumbSticks.Left.X, 1),
                (float)Math.Round(oldGenericPadState.ThumbSticks.Left.Y, 1));

            //Keypresses
            //Up
            if ((genericPadAxis.Y <= -t && oldGenericPadAxis.Y > -t)
                || (gamePadAxis.Y <= -t && oldGamePadAxis.Y > -t)
                || (keyboardState.IsKeyDown(Keys.Up) && !oldKeyboardState.IsKeyDown(Keys.Up)))
            {
                colorIndex = MathHelper.Clamp(--colorIndex, minColors, maxColors);
            }

            //Down
            if ((genericPadAxis.Y >= t && oldGenericPadAxis.Y < t)
                || (gamePadAxis.Y >= t && oldGamePadAxis.Y < t)
                || (keyboardState.IsKeyDown(Keys.Down) && !oldKeyboardState.IsKeyDown(Keys.Down)))
            {
                colorIndex = MathHelper.Clamp(++colorIndex, minColors, maxColors);
            }

            //Right
            if ((genericPadAxis.X >= t && oldGenericPadAxis.X < t)
                || (gamePadAxis.X >= t && oldGamePadAxis.X < t)
                || (keyboardState.IsKeyDown(Keys.Right) && !oldKeyboardState.IsKeyDown(Keys.Right)))
            {
                typeIndex = MathHelper.Clamp(++typeIndex, minTypes, maxTypes);
            }

            //Left
            if ((genericPadAxis.X <= -t && oldGenericPadAxis.X > -t)
                || (gamePadAxis.X <= -t && oldGamePadAxis.X > -t)
                || (keyboardState.IsKeyDown(Keys.Left) && !oldKeyboardState.IsKeyDown(Keys.Left)))
            {
                typeIndex = MathHelper.Clamp(--typeIndex, minTypes, maxTypes);
            }

            oldKeyboardState = keyboardState;
            oldGamePadState = gamePadState;
            oldGenericPadState = genericPadState;
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Load overlays, fonts, character selection and level
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            uiFont = Content.Load<SpriteFont>("Fonts/UI");
            bigUIFont = Content.Load<SpriteFont>("Fonts/BigUI");

            startOverlay = Content.Load<Texture2D>("Overlays/start");
            endOverlay = Content.Load<Texture2D>("Overlays/end");
            splash = Content.Load<Texture2D>("Overlays/splash");
            background = Content.Load<Texture2D>("bg");

            charselect = new CharacterSelect(Services);
            level = new Level(Services, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight);
        }
Ejemplo n.º 4
0
Archivo: Player.cs Proyecto: msokk/Hype
 public Player(Level level)
     : this(level, "1.1")
 {
 }