private void KeyDownEvent(object sender, KeyEventArgs e) { if (e.Key == Key.D) //right { double x = FoxDraw.GetLeft(FoxDraw.Tiles[0]) + 10; double y = FoxDraw.GetTop(FoxDraw.Tiles[0]) + 0; FoxDraw.SetPosition(FoxDraw.Tiles[0], x, y); } if (e.Key == Key.A) //left { double x = FoxDraw.GetLeft(FoxDraw.Tiles[0]) - 10; double y = FoxDraw.GetTop(FoxDraw.Tiles[0]) + 0; FoxDraw.SetPosition(FoxDraw.Tiles[0], x, y); } if (e.Key == Key.S) //down { double x = FoxDraw.GetLeft(FoxDraw.Tiles[0]) + 0; double y = FoxDraw.GetTop(FoxDraw.Tiles[0]) + 10; FoxDraw.SetPosition(FoxDraw.Tiles[0], x, y); } if (e.Key == Key.W) //up { double x = FoxDraw.GetLeft(FoxDraw.Tiles[0]) + 0; double y = FoxDraw.GetTop(FoxDraw.Tiles[0]) - 10; FoxDraw.SetPosition(FoxDraw.Tiles[0], x, y); } }
private void KeyDownEvent(object sender, KeyEventArgs e) { if (e.Key == Key.Down && y < 500) { y += 50; for (int i = 0; i < map.wallYCoordinates.Count; i++) { if (y == map.wallYCoordinates[i] && x == map.wallXCoordinates[i]) { y -= 50; } } FoxDraw.SetPosition(FoxDraw.HeroImages[0], x, y); } if (e.Key == Key.Up && y > 0) { y -= 50; for (int i = 0; i < map.wallYCoordinates.Count; i++) { if (y == map.wallYCoordinates[i] && x == map.wallXCoordinates[i]) { y += 50; } } FoxDraw.SetPosition(FoxDraw.HeroImages[0], x, y); } if (e.Key == Key.Left && x > 0) { x -= 50; for (int i = 0; i < map.wallYCoordinates.Count; i++) { if (x == map.wallXCoordinates[i] && y == map.wallYCoordinates[i]) { x += 50; } } FoxDraw.SetPosition(FoxDraw.HeroImages[0], x, y); } if (e.Key == Key.Right && x < 450) { x += 50; for (int i = 0; i < map.wallYCoordinates.Count; i++) { if (x == map.wallXCoordinates[i] && y == map.wallYCoordinates[i]) { x -= 50; } } FoxDraw.SetPosition(FoxDraw.HeroImages[0], x, y); } }