/// <summary> /// Create form, create game /// </summary> public GameForm() { InitializeComponent(); game = Game.CreateGame(new Size(this.Width - 18, this.Height - 33)); // border size... watch.Start(); WorldClock.Start(); }
static void Main(string[] args) { string dir = Directory.GetParent(Directory.GetCurrentDirectory()).Parent.FullName; Directory.SetCurrentDirectory(dir + @"\Resources"); Game engine = new Game(); engine.Run(); }
static void Main(string[] args) { Game game = new Game(750, 600, "Space Invaders", 60); SpaceInvadersScreen screen = new SpaceInvadersScreen("Space Invaders", game); game.AddScreen(screen); game.ActiveScreen = "Space Invaders"; game.Run(); }
public void RemovesEntityOutOfBounds() { // Set the entity's position out of bounds _ = new Game(); Game.gameSize = new Viewport(0, 0, 800, 480); Vector2 position = new Vector2(900, 500); Vector2 velocity = new Vector2(150, 150); Shot bullet = new Shot(position, velocity); // Update the position of the entity bullet.Update(); // Assert Assert.IsTrue(bullet.shouldRemove); }
public void ProperEntityMovement() { // Arrange _ = new Game(); Game.gameSize = new Viewport(0, 0, 800, 480); Vector2 position = new Vector2(414, 215); Vector2 velocity = new Vector2(-10, 3); Vector2 expected = position + velocity; Shot bullet = new Shot(position, velocity); // Update the position of the entity bullet.Update(); // Assert Assert.IsTrue(bullet.Position.X == expected.X); Assert.IsTrue(bullet.Position.Y == expected.Y); }
public SpaceInvadersScreen(string title, Game parent) : base(title, parent) { backgroundMusic.Play(); SetupHUD(); laneWidth = parent.Size.X / numberOfLanes; player = new Player(new Vector2f(Parent.Size.X * 0.5f, parent.Size.Y - 20), AssetsManager.Textures["ship"]); player.Scale *= 0.5f; playerHitSound.SoundBuffer = AssetsManager.Sounds["playerHit"]; explosionSound.SoundBuffer = AssetsManager.Sounds["explosion"]; spriteBatchTexture = new RenderTexture((uint)(parent.Size.X), (uint)(parent.Size.Y)); spriteBatch = new Sprite(spriteBatchTexture.Texture); }
/// <summary> /// Singleton constructor /// </summary> /// <param name="gameSize">Size of the game area</param> /// /// <returns></returns> public static Game CreateGame(Size gameSize) { if (game == null) game = new Game(gameSize); return game; }