public override void Update(MainGame game, EntityContainer parent, GameTime time) { foreach (Entity item in this.Items) { item.Update(game, this, time); } }
public override void Draw(MainGame game, EntityContainer parent) { foreach (Entity item in this.Items) { item.Draw(game, this); } }
public override void Update(MainGame game, EntityContainer parent, GameTime time) { if (game.IsKeyDown(Keys.W) || game.IsKeyDown(Keys.Up)) { DoMove(game, 0, (float)time.ElapsedGameTime.Milliseconds / 5); } if (game.IsKeyDown(Keys.S) || game.IsKeyDown(Keys.Down)) { DoMove(game, 0, -(float)time.ElapsedGameTime.Milliseconds / 5); } if (game.IsKeyDown(Keys.A) || game.IsKeyDown(Keys.Left)) { DoMove(game, (float)time.ElapsedGameTime.Milliseconds / 5, 0); } if (game.IsKeyDown(Keys.D) || game.IsKeyDown(Keys.Right)) { DoMove(game, -(float)time.ElapsedGameTime.Milliseconds / 5, 0); } }
public override void Draw(MainGame game, EntityContainer parent) { game.DrawImage("player", new Rectangle(MainGame.WindowWidth / 2 - 8, MainGame.WindowHeight / 2 - 8, LivingEntSize, LivingEntSize), true); }
public override void Update(MainGame game, EntityContainer parent, GameTime time) { Rectangle seenBounds = game.CameraBounds; for (int x = seenBounds.X / TileSize; x < (seenBounds.X + seenBounds.Width) / TileSize + 2; x++) { for (int y = seenBounds.Y / TileSize; y < (seenBounds.Y + seenBounds.Height) / TileSize + 1 + 2; y++) { if (x >= Width || x < 0 || y >= Height || y < 0) { continue; } Map[x, y].Update(game, time); } } }
public virtual void Update(MainGame game, EntityContainer parent, GameTime time) { }
public virtual void Draw(MainGame game, EntityContainer parent) { }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. _Batch = new SpriteBatch(GraphicsDevice); Container = new EntityContainer(); LoadAllContent(); OnInit(); Container.Update(); // TODO: use this.Content to load your game content here }