source: trunk/deushax/mapviewer.cpp @ 259

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

Slightly change the ...Data initialisation in classes.

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