public void Update(float dt) { if (!GameOver) { currentMap = currentMap.ResolveDoors(hero); hero.Update(dt); if (InputManager.Instance.KeyPressed(OpenTK.Input.Key.Space)) { PointF velocity = new PointF(0.0f, 0.0f); if (hero.currentSprite == "up" ) { velocity.Y = -100.0f; } else if (hero.currentSprite == "down") { velocity.Y = 100.0f; } if (hero.currentSprite == "left") { velocity.X = -100.0f; } else if(hero.currentSprite == "right") { velocity.X = 100.0f; } projectiles.Add(new Bullet(hero.Center, velocity)); } for (int i = projectiles.Count-1; i >= 0; i--) { projectiles[i].Update(dt); } currentMap.Update(dt, hero,projectiles); } else { if (InputManager.Instance.KeyPressed(OpenTK.Input.Key.Space)) { currentMap = room1; hero.Position = new Point(spawnTile.X * tileSize, spawnTile.Y * tileSize); GameOver = false; } } }
public void Initialize(OpenTK.GameWindow window) { Window = window; window.ClientSize = new Size(room1Layout[0].Length * tileSize, room1Layout.Length * tileSize); projectiles = new List<Bullet>(); TextureManager.Instance.UseNearestFiltering = true; hero = new PlayerCharacter(heroSheet, new Point(spawnTile.X * tileSize, spawnTile.Y * tileSize)); room1 = new Map(room1Layout, spriteSheets, spriteSources, 2, 0); room2 = new Map(room2Layout, spriteSheets, spriteSources, 0, 2); room1[4][7].MakeDoor(room2, new Point(1, 1)); room2[1][0].MakeDoor(room1, new Point(6, 4)); currentMap = room1; room1.AddEnemy(npcSheet, new Point(6 * tileSize, 1 * tileSize), true); room2.AddEnemy(npcSheet, new Point(1 * tileSize, 4 * tileSize), false); }
public void MakeDoor(Map target, Point location) { DoorTarget = target; DoorLocation = location; IsDoor = true; }