source: trunk/src/game.cpp @ 137

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

Invert the mouse coordinate handling logic.

  • Property svn:keywords set to Id
File size: 1.3 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    Scene *scene;
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->scene = NULL;
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    GetScene();
66
67    data->map->Render(data->scene, -data->mousex, -data->mousey, 0);
68    data->scene->Render();
69
70    delete data->scene;
71    data->scene = NULL;
72}
73
74Scene *Game::GetScene()
75{
76    if (!data->scene)
77        data->scene = new Scene();
78    return data->scene;
79}
80
81void Game::SetMouse(int x, int y)
82{
83    data->mousex = x;
84    data->mousey = y;
85}
86
87void Game::Quit()
88{
89    data->done = 1;
90}
91
92int Game::Finished()
93{
94    return data->done;
95}
96
Note: See TracBrowser for help on using the repository browser.