Game ClassDelta Engine Documentation
Game Logic and initialization for Asteroids View code on GitHub
Inheritance Hierarchy

System Object
  DeltaEngine.Content ContentData
    DeltaEngine.Scenes Scene
      Asteroids Game

Namespace: Asteroids
Assembly: Asteroids (in Asteroids.exe) Version: 1.1.1.0 (1.1.1)
Syntax

public class Game : Scene

The Game type exposes the following members.

Constructors

  NameDescription
Public methodGame
Initializes a new instance of the Game class
Top
Methods

  NameDescription
Public methodAdd(Entity2D) (Inherited from Scene.)
Public methodAdd(IEnumerable Entity2D ) (Inherited from Scene.)
Public methodAddControlToScene (Inherited from Scene.)
Public methodBackToMenu
Public methodClear (Inherited from Scene.)
Protected methodCreateDefault (Inherited from ContentData.)
Public methodDispose (Inherited from ContentData.)
Protected methodDisposeData (Inherited from Scene.)
Public methodGameOver
Public methodGetHighscoresFromString
Public methodHide (Inherited from Scene.)
Public methodInternalCreateDefault (Inherited from ContentData.)
Protected methodLoadData (Inherited from Scene.)
Public methodLoadFromFile (Inherited from Scene.)
Public methodRemove (Inherited from Scene.)
Public methodRestartGame
Public methodSetQuadraticBackground(String) (Inherited from Scene.)
Public methodSetQuadraticBackground(Material) (Inherited from Scene.)
Public methodSetViewportBackground(String) (Inherited from Scene.)
Public methodSetViewportBackground(Material) (Inherited from Scene.)
Public methodShow (Inherited from Scene.)
Public methodStartGame
Public methodToBackground (Inherited from Scene.)
Public methodToForeground (Inherited from Scene.)
Public methodToString (Inherited from ContentData.)
Top
Fields

  NameDescription
Protected fieldbackground (Inherited from Scene.)
Protected fieldContentChanged (Inherited from ContentData.)
Public fieldGameState
Top
Properties

  NameDescription
Protected propertyAllowCreationIfContentNotFound (Inherited from ContentData.)
Public propertyControls (Inherited from Scene.)
Public propertyDrawArea (Inherited from Scene.)
Public propertyHudInterface
Public propertyInteractionLogic
Public propertyIsDisposed (Inherited from ContentData.)
Public propertyMetaData (Inherited from ContentData.)
Public propertyName (Inherited from ContentData.)
Top
Remarks

Tests: Asteroids.Tests.GameLogicTests
Examples

9 unit tests call Asteroids.Game
[Test, CloseAfterFirstFrame]
public void ProjectileAndAsteroidDisposedOnCollision()
{
    var projectile = new Projectile(new Vector2D(0.5f, 0.55f), 0);
    interactionLogic.CreateAsteroidsAtPosition(Vector2D.Half, 1, 1);
    AdvanceTimeAndUpdateEntities();
    Assert.IsFalse(projectile.IsActive);
}
[Test, CloseAfterFirstFrame]
public void PlayerShipAndAsteroidCollidingResultsInGameOver()
{
    bool gameOver = false;
    interactionLogic.BeginGame();
    interactionLogic.GameOver += () => { gameOver = true; };
    interactionLogic.Player.Set(new Rectangle(Vector2D.Half, new Size(.05f)));
    interactionLogic.CreateAsteroidsAtPosition(Vector2D.Half, 1, 1);
    AdvanceTimeAndUpdateEntities();
    Assert.IsTrue(gameOver);
}
[Test, CloseAfterFirstFrame]
public void InteractionLogicIsPauseable()
{
    Assert.IsTrue(interactionLogic.IsPauseable);
}
See Also