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