source: trunk/src/mapviewer.cpp @ 155

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

New MapViewer class and some GTK+ refactoring.

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