source: trunk/src/game.cpp @ 111

Last change on this file since 111 was 111, checked in by sam, 10 years ago

The frame counter is now an asset object.

  • Property svn:keywords set to Id
File size: 1.1 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 "game.h"
13#include "map.h"
14
15/*
16 * Game implementation class
17 */
18
19class GameData
20{
21    friend class Game;
22
23private:
24    Map *map;
25    int x, y;
26    int mousex, mousey;
27    int done;
28
29    int frame;
30};
31
32/*
33 * Public Game class
34 */
35
36Game::Game(char const *mapname)
37{
38    data = new GameData();
39    data->map = new Map(mapname);
40    data->x = data->y = 0;
41    data->done = 0;
42    data->frame = 0;
43}
44
45Game::~Game()
46{
47    delete data->map;
48    delete data;
49}
50
51Asset::Group Game::GetGroup()
52{
53    return Asset::GetGroup();
54}
55
56void Game::TickGame(float delta_time)
57{
58    Asset::TickGame(delta_time);
59}
60
61void Game::TickRender(float delta_time)
62{
63    Asset::TickRender(delta_time);
64
65    Scene *scene = new Scene();
66
67    data->map->Render(scene, data->mousex, data->mousey, 0);
68
69    scene->Render();
70    delete scene;
71}
72
73void Game::SetMouse(int x, int y)
74{
75    data->mousex = x;
76    data->mousey = y;
77}
78
79void Game::Quit()
80{
81    data->done = 1;
82}
83
84int Game::Finished()
85{
86    return data->done;
87}
88
Note: See TracBrowser for help on using the repository browser.