-
Notifications
You must be signed in to change notification settings - Fork 0
/
Game.cs
64 lines (52 loc) · 1.28 KB
/
Game.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
using System;
using System.Windows.Forms;
namespace AsteroidsGdiApp.Core
{
public class Game
{
private readonly IGameForm _parentForm;
private readonly GameStatus _status;
private Timer _timer;
public Game(IGameForm parent)
{
_status = new GameStatus {GameOver = false};
_parentForm = parent;
InitializeForm();
}
private void InitializeForm()
{
_parentForm.Initialize();
}
void TimerTick(object sender, EventArgs e)
{
if (!_status.GameOver)
{
Update();
}
Draw();
}
protected virtual void Update()
{
}
public virtual void Draw()
{
}
public virtual void Run()
{
_timer = new Timer
{
Interval = 30
};
_timer.Tick += TimerTick;
_timer.Enabled = true;
_timer.Start();
}
protected IGameForm ParentForm
{
get
{
return _parentForm;
}
}
}
}