source: trunk/deushax/game.cpp @ 221

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

Complete Lol Engine / Deus Hax / Monsterz split.

  • Property svn:keywords set to Id
File size: 1.2 KB
Line 
1//
2// Deus Hax (working title)
3// Copyright (c) 2010-2011 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#include "game.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
51void Game::TickGame(float deltams)
52{
53    Entity::TickGame(deltams);
54}
55
56void Game::TickDraw(float deltams)
57{
58    Entity::TickDraw(deltams);
59
60    GetScene();
61
62    data->map->Render(data->scene, -data->mousex, -data->mousey, 0);
63    data->scene->Render();
64
65    delete data->scene;
66    data->scene = NULL;
67}
68
69Scene *Game::GetScene()
70{
71    if (!data->scene)
72        data->scene = new Scene();
73    return data->scene;
74}
75
76void Game::SetMouse(int x, int y)
77{
78    data->mousex = x;
79    data->mousey = y;
80}
81
82void Game::Quit()
83{
84    data->done = 1;
85}
86
87int Game::Finished()
88{
89    return data->done;
90}
91
Note: See TracBrowser for help on using the repository browser.