static void Main(string[] args) { DCG.Sprite spr = new DCG.Sprite(new[] { " .---.", "| o o |", "| ._. |", " '---'" }); ball = new DCG.Object("Ball", spr, 2, 3); List <DCG.Object> sceneObjects = new List <DCG.Object>(); sceneObjects.Add(ball); List <DCG.Scene> scenes = new List <DCG.Scene>(); scenes.Add(new DCG.Scene(sceneObjects, "Main Scene")); GameEngine = new DCG.Engine(scenes, 10); GameEngine.Events.Add(new DCG.Event.OnStep(Step)); GameEngine.Events.Add(new DCG.Event.OnMouseClick(Shoot)); // engine.OnStep = ref Step; GameEngine.Start(); }
public static void Step() { if (DCG.Actions.KeyDown(System.Windows.Input.Key.Left)) { ball.X -= 1; } if (DCG.Actions.KeyDown(System.Windows.Input.Key.Right)) { ball.X += 1; } if (DCG.Actions.KeyDown(System.Windows.Input.Key.Down)) { ball.Y += 1; } if (DCG.Actions.KeyDown(System.Windows.Input.Key.Up)) { ball.Y -= 1; } for (int i = 0; i < GameEngine.CurrentScene.Objects.Count; i++) { DCG.Object obj = GameEngine.CurrentScene.Objects[i]; if (obj is Projectile) { Projectile pr = (Projectile)obj; if (pr.Remove()) { GameEngine.CurrentScene.Objects.Remove(obj); } else { pr.Update(); } } } }