Last change
on this file since 210 was
210,
checked in by sam, 10 years ago
|
Allow for different priorities in game and draw tick levels.
|
-
Property svn:keywords set to
Id
|
File size:
1.2 KB
|
Line | |
---|
1 | // |
---|
2 | // Deus Hax (working title) |
---|
3 | // Copyright (c) 2010 Sam Hocevar <sam@hocevar.net> |
---|
4 | // |
---|
5 | |
---|
6 | #if defined HAVE_CONFIG_H |
---|
7 | # include "config.h" |
---|
8 | #endif |
---|
9 | |
---|
10 | #include <cstdio> |
---|
11 | |
---|
12 | #include "core.h" |
---|
13 | |
---|
14 | /* |
---|
15 | * Game implementation class |
---|
16 | */ |
---|
17 | |
---|
18 | class GameData |
---|
19 | { |
---|
20 | friend class Game; |
---|
21 | |
---|
22 | private: |
---|
23 | Map *map; |
---|
24 | int x, y; |
---|
25 | int mousex, mousey; |
---|
26 | int done; |
---|
27 | |
---|
28 | Scene *scene; |
---|
29 | }; |
---|
30 | |
---|
31 | /* |
---|
32 | * Public Game class |
---|
33 | */ |
---|
34 | |
---|
35 | Game::Game(char const *mapname) |
---|
36 | { |
---|
37 | data = new GameData(); |
---|
38 | data->map = new Map(mapname); |
---|
39 | data->x = data->y = 0; |
---|
40 | data->done = 0; |
---|
41 | data->scene = NULL; |
---|
42 | } |
---|
43 | |
---|
44 | Game::~Game() |
---|
45 | { |
---|
46 | delete data->map; |
---|
47 | delete data; |
---|
48 | } |
---|
49 | |
---|
50 | void Game::TickGame(float deltams) |
---|
51 | { |
---|
52 | Entity::TickGame(deltams); |
---|
53 | } |
---|
54 | |
---|
55 | void Game::TickDraw(float deltams) |
---|
56 | { |
---|
57 | Entity::TickDraw(deltams); |
---|
58 | |
---|
59 | GetScene(); |
---|
60 | |
---|
61 | data->map->Render(data->scene, -data->mousex, -data->mousey, 0); |
---|
62 | data->scene->Render(); |
---|
63 | |
---|
64 | delete data->scene; |
---|
65 | data->scene = NULL; |
---|
66 | } |
---|
67 | |
---|
68 | Scene *Game::GetScene() |
---|
69 | { |
---|
70 | if (!data->scene) |
---|
71 | data->scene = new Scene(); |
---|
72 | return data->scene; |
---|
73 | } |
---|
74 | |
---|
75 | void Game::SetMouse(int x, int y) |
---|
76 | { |
---|
77 | data->mousex = x; |
---|
78 | data->mousey = y; |
---|
79 | } |
---|
80 | |
---|
81 | void Game::Quit() |
---|
82 | { |
---|
83 | data->done = 1; |
---|
84 | } |
---|
85 | |
---|
86 | int Game::Finished() |
---|
87 | { |
---|
88 | return data->done; |
---|
89 | } |
---|
90 | |
---|
Note: See
TracBrowser
for help on using the repository browser.