public PlayingState() { Paused = false; Input = new InputManager(); camera = new Camera(); Players = new List<Player>(); MapTiles = new List<Sprite>(); collision = new Collision(); FPSText = ""; AvailableTextures = new Dictionary<string, Texture2D>(); }
public EditorState() { ChosenFile = false; ChosenMethod = false; LoadFile = false; GoMenu = false; FileLoadError = false; BuildHoriz = true; BuildAmount = 1; InputString = ""; Input = new InputManager(); camera = new Camera(); AvailableTextures = new Dictionary<string, Texture2D>(); MapTiles = new List<Sprite>(); map = new Map(); CurrentTexture = 0; CurrentDepth = 1.0f; }
public virtual void Update(GameTime gameTime, InputManager Input) { base.Update(gameTime); GamePadState gamePad = Input.GetCurrentGamePadState(PlayerNumber); //Check input if (gamePad.ThumbSticks.Left.X < 0.0f) { movementState.right = false; movementState.left = true; } else if (gamePad.ThumbSticks.Left.X > 0.0f) { movementState.left = false; movementState.right = true; } else { movementState.right = false; movementState.left = false; } if (movementState.right) { PlayAnimation("running"); lastDireciton = false; if(moveState.canMoveRight) Velocity.X += 1.0f; } else if (movementState.left) { PlayAnimation("running"); lastDireciton = true; if (moveState.canMoveLeft) Velocity.X -= 1.0f; } else { if (Velocity.X > 0.0f) Velocity.X -= 0.6f; if (Velocity.X < 0.0f) Velocity.X += 0.6f; PlayAnimation("idle"); } //Clip velocity if (Velocity.X > -0.6f && Velocity.X < 0.6f) Velocity.X = 0.0f; else if (Velocity.X > 20.0f) Velocity.X = 20.0f; else if (Velocity.X < -20.0f) Velocity.X = -20.0f; if (!moveState.canMoveLeft || !moveState.canMoveRight) Velocity.X = 0.0f; if (!moveState.canMoveDown || !moveState.canMoveUp) Velocity.Y = 0.0f; if (gamePad.Buttons.A == ButtonState.Pressed) { if (!Jumping && !Falling) { Jumping = true; OnGround = false; JumpHeight = Position.Y - 190.0f; } } else if (gamePad.Buttons.A == ButtonState.Released) { if (Jumping) { Jumping = false; Falling = true; } } if(Jumping) { if (Position.Y < JumpHeight) { Jumping = false; Falling = true; } else { Velocity.Y -= 5.0f; } } if (!OnGround) Falling = true; if (Falling) Velocity.Y += 1.0f; if (OnGround) Velocity.Y = 0.0f; Position += Velocity; int width = SpriteTexture.Width / Columns; int height = SpriteTexture.Height / Rows; BoundingBox = new Rectangle((int)Position.X, (int)Position.Y, width, height); moveState.canMoveLeft = true; moveState.canMoveRight = true; moveState.canMoveUp = true; moveState.canMoveDown = true; }