source: trunk/src/game.cpp @ 100

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

Slightly improve the documentation in a few files, add the missing
joystick class, and put a header in each source file.

  • Property svn:keywords set to Id
File size: 1.0 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#include "font.h"
15
16/*
17 * Game implementation class
18 */
19
20class GameData
21{
22    friend class Game;
23
24private:
25    Map *map;
26    Font *font;
27    int x, y;
28    int mousex, mousey;
29
30    int frame;
31};
32
33/*
34 * Public Game class
35 */
36
37Game::Game(char const *mapname)
38{
39    data = new GameData();
40    data->map = new Map(mapname);
41    data->font = new Font("gfx/font/ascii.png");
42    data->x = data->y = 0;
43    data->frame = 0;
44}
45
46Game::~Game()
47{
48    delete data->font;
49    delete data->map;
50    delete data;
51}
52
53void Game::SetMouse(int x, int y)
54{
55    data->mousex = x;
56    data->mousey = y;
57}
58
59void Game::Render()
60{
61    Scene *scene = new Scene();
62
63    data->map->Render(scene, data->mousex, data->mousey, 0);
64
65    scene->Render();
66    delete scene;
67
68    char buf[1024];
69    sprintf(buf, "Frame %i", data->frame++);
70    data->font->Print(10, 10, buf);
71}
72
Note: See TracBrowser for help on using the repository browser.