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); room1.AddItem(spriteSheets, new Rectangle(350, 255, 16, 16), 10, new Point(3 * tileSize + 7, 2 * tileSize + 7)); room1.AddItem(spriteSheets, new Rectangle(381, 256, 13, 15), 20, new Point(5 * tileSize + 7, 4 * tileSize + 7)); room2.AddItem(spriteSheets, new Rectangle(412, 256, 16, 15), 30, new Point(4 * tileSize + 7, 2 * tileSize + 7)); }
public void MakeDoor(Map target, Point location) { DoorTarget = target; DoorLocation = location; IsDoor = true; }
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; } } }