public void LoadContent(ContentManager content, Map map, string mapID) { layer = new Layer(); collision = new Collision(); id = mapID; layer.LoadContent(map, "Layer1"); collision.LoadContent(content, mapID); }
public override void Update(GameTime gameTime, InputManager inputManager, Collision col, Layers layer) { moveAnimation.IsActive = true; if (inputManager.KeyDown(Keys.Right, Keys.D)) { moveAnimation.CurrentFrame = new Vector2(moveAnimation.CurrentFrame.X, 2); position.X += moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds; } else if (inputManager.KeyDown(Keys.Left, Keys.A)) { moveAnimation.CurrentFrame = new Vector2(moveAnimation.CurrentFrame.X, 1); position.X -= moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds; } else if (inputManager.KeyDown(Keys.Down, Keys.S)) { moveAnimation.CurrentFrame = new Vector2(moveAnimation.CurrentFrame.X, 0); position.Y += moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds; } else if (inputManager.KeyDown(Keys.Up, Keys.W)) { moveAnimation.CurrentFrame = new Vector2(moveAnimation.CurrentFrame.X, 3); position.Y -= moveSpeed * (float)gameTime.ElapsedGameTime.TotalSeconds; } else { moveAnimation.IsActive = false; } for (int i = 0; i < col.CollisionMap.Count; i++) { for (int j = 0; j < col.CollisionMap[i].Count; j++) { if (col.CollisionMap[i][j] == "x") //check only for obstructed tiles { if (position.X + moveAnimation.FrameWidth < j * layer.TileDimensions.X || position.X > j * layer.TileDimensions.X + layer.TileDimensions.X || position.Y + moveAnimation.FrameHeight < i * layer.TileDimensions.Y || position.Y > i * layer.TileDimensions.Y + layer.TileDimensions.Y) { //no collision } else { position = moveAnimation.Position; //move animation position is last frame position } } } } moveAnimation.Position = position; ssAnimation.Update(gameTime, ref moveAnimation); }
public override void Update(GameTime gameTime, InputManager inputManager, Collision col, Layers layer) { }
public virtual void Update(GameTime gameTime, InputManager inputManager, Collision col, Layers layer) { }