source: trunk/monsterz/game.cpp @ 259

Last change on this file since 259 was 259, checked in by sam, 11 years ago

Slightly change the ...Data initialisation in classes.

  • Property svn:keywords set to Id
File size: 1.3 KB
Line 
1//
2// Monsterz
3//
4// Copyright: (c) 2005-2011 Sam Hocevar <sam@hocevar.net>
5//   This program is free software; you can redistribute it and/or
6//   modify it under the terms of the Do What The Fuck You Want To
7//   Public License, Version 2, as published by Sam Hocevar. See
8//   http://sam.zoy.org/projects/COPYING.WTFPL for more details.
9//
10
11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include <cstdio>
16
17#include "core.h"
18#include "game.h"
19
20/*
21 * Game implementation class
22 */
23
24class GameData
25{
26    friend class Game;
27
28private:
29    int x, y;
30    int mousex, mousey;
31    int done;
32
33    Scene *scene;
34};
35
36/*
37 * Public Game class
38 */
39
40Game::Game()
41  : data(new GameData())
42{
43    data->x = data->y = 0;
44    data->done = 0;
45    data->scene = NULL;
46}
47
48Game::~Game()
49{
50    delete data;
51}
52
53void Game::TickGame(float deltams)
54{
55    Entity::TickGame(deltams);
56}
57
58void Game::TickDraw(float deltams)
59{
60    Entity::TickDraw(deltams);
61
62    GetScene();
63
64    data->scene->Render();
65
66    delete data->scene;
67    data->scene = NULL;
68}
69
70Scene *Game::GetScene()
71{
72    if (!data->scene)
73        data->scene = new Scene(0.0f);
74    return data->scene;
75}
76
77void Game::SetMouse(int x, int y)
78{
79    data->mousex = x;
80    data->mousey = y;
81}
82
83void Game::Quit()
84{
85    data->done = 1;
86}
87
88int Game::Finished()
89{
90    return data->done;
91}
92
Note: See TracBrowser for help on using the repository browser.