-
Notifications
You must be signed in to change notification settings - Fork 4
/
Dungeon.h
142 lines (128 loc) · 3.69 KB
/
Dungeon.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// Dungeon.h
#ifndef __DUNGEON_H__
#define __DUNGEON_H__
#include "JLinkList.h"
#include "DungeonTile.h"
#include "Monster.h"
#include "Item.h"
#include "TileSet.h"
#include "DungeonMap.h"
//class CMonster;
//class CItem;
//#define DUNG_FONT_COURIER
#ifdef DUNG_FONT_COURIER
#define DUNG_TILESET CTileset("Resources/Courier.png", 32, 32 )
#define DUNG_ASPECT vSize(1.0f,1.0f)
#else
#define DUNG_TILESET CTileset("Resources/SmallText6x8.png", 6,8 )
#define DUNG_ASPECT vSize(0.75f,1.0f)
#endif
#define DUNG_ZOOM_MIN 4
#define DUNG_ZOOM_NORMAL 20
#define DUNG_ZOOM_MAX 100
class CDungeon
{
// Member Variables
public:
int m_dwHeight;
int m_dwWidth;
CDungeonTile *m_Tiles;
int depth; // dungeon level / 50ft.
CTileset *m_TileSet;
JLinkList<CMonster> *m_llMonsters;
JLinkList<CItem> *m_llItems;
protected:
CDungeonTileDef *m_dtdlist;
JLinkList <CMonsterDef> *m_llMonsterDefs;
JLinkList <CItemDef> *m_llItemDefs;
private:
Uint16 m_dwZoom;
bool m_bDraw;
// Member Functions
public:
CDungeon():
m_Tiles(NULL),
m_dwWidth(0),
m_dwHeight(0),
depth(0),
//m_Tileset(NULL),
m_dtdlist(NULL),
m_Rect( -DUNG_WIDTH, DUNG_HEIGHT, DUNG_WIDTH, -DUNG_HEIGHT ),
m_vfTranslate( (int)(-DUNG_WIDTH*0.5f), (int)(-DUNG_HEIGHT*0.5f) ),
m_dwZoom(DUNG_ZOOM_NORMAL),
//m_dmTownLevel(NULL),
m_dmCurLevel(NULL)
{};
~CDungeon() { Term(); };
void PreDraw() ;
void Draw() ;
void DrawDungeon();
void DrawItems();
void DrawMonsters();
void PostDraw() ;
void Init();
void Term();
bool Tick( const int dwClock );
bool Update( float fCurTime );
JResult OnChangeLevel(const int delta);
void Zoom( Uint16 dwDelta )
{
m_dwZoom += dwDelta;
if( m_dwZoom < DUNG_ZOOM_MIN )
{
m_dwZoom = DUNG_ZOOM_MIN;
}
else if ( m_dwZoom > DUNG_ZOOM_MAX )
{
m_dwZoom = DUNG_ZOOM_MAX;
}
}
CDungeonTile *GetITile( JIVector &vPos )
{
/*if( !IsInWorld(vPos) )
{
return NULL;
}/**/
return (m_Tiles + (vPos.y * DUNG_WIDTH) + vPos.x ); // going to have to work in offsets, too, if the dungeon's bigger than the screen. --Jimbo
};
CDungeonTile *GetTile( const JVector &vPos )
{
/*if( !IsInWorld(vPos) )
{
return NULL;
}/**/
// casting to int is *absolutely* the wrong way to do this. fix this once it inevitably breaks.
return (m_Tiles + ((int)vPos.y * DUNG_WIDTH) + (int)vPos.x ); // going to have to work in offsets, too, if the dungeon's bigger than the screen. --Jimbo
};
int IsWalkableFor( JVector &vPos, bool isPlayer=false );
int CanPlaceItemAt( JVector &vPos );
int CanPlaceStairsAt( JVector &vPos );
bool IsOpenable( JVector &vPos );
bool IsTunnelable( JVector &vPos );
bool IsCloseable( JVector &vPos );
int IsStairs( JVector &vPos );
void RemoveMonster( CMonster *pMon );
JResult Modify( JVector &vPos );
CItem *PickUp( JVector &vPickupPos );
void Drop( CItem *pItem, JVector &vDropPos );
protected:
JRect m_Rect;
JFVector m_vfTranslate;
CDungeonMap *m_dmCurLevel; // Data about the curennt level (and holds dungeon gen algorithm)
float m_fOpenFloorArea; // How much of the current level is open?
void extracted();
//CDungeonMap m_dmTownLevel; // The Dungeon remembers where you live...
JResult CreateNewLevel(const int delta);
JResult CreateMap();
JResult InitDungeonTiles();
JResult PlaceScenery(const int depth);
JResult PlaceStairs(const int desired, const int type);
JResult PlaceItems(const int depth);
JResult SpawnMonsters(const int depth);
int ChooseMonsterForDepth(const int depth);
int ChooseItemForDepth(const int depth);
JResult TerminateLevel();
private:
bool IsOnScreen(JVector vPos);
};
#endif // __DUNGEON_H__