source: trunk/src/game.cpp @ 91

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

Naive font renderer prototype.

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