Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
RogueReborn
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Analyze
Contributor analytics
Repository analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Mikhail Andrenkov
RogueReborn
Commits
bf7a83d3
Commit
bf7a83d3
authored
8 years ago
by
Ian Prins
Browse files
Options
Downloads
Patches
Plain Diff
add flags to determine type of room
parent
a54f3697
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/include/level.h
+5
-4
5 additions, 4 deletions
src/include/level.h
src/include/room.h
+11
-0
11 additions, 0 deletions
src/include/room.h
src/level.cpp
+7
-2
7 additions, 2 deletions
src/level.cpp
src/room.cpp
+8
-1
8 additions, 1 deletion
src/room.cpp
with
31 additions
and
7 deletions
src/include/level.h
+
5
−
4
View file @
bf7a83d3
#pragma once
#include
<vector>
#include
"coord.h"
#include
"terrain.h"
#include
"random.h"
#include
"playerchar.h"
#include
"goldpile.h"
#include
"room.h"
#ifndef LEVEL_H
#define LEVEL_H
class
Room
;
class
Level
{
public:
...
...
@@ -21,11 +23,10 @@ class Level {
const
double
GOLD_CHANCE
=
.333
;
const
Coord
SIZE
=
Coord
(
80
,
25
);
std
::
vector
<
std
::
vector
<
Terrain
>
>
tiles
;
std
::
vector
<
Room
>
rooms
;
std
::
vector
<
Mob
>
mobs
;
std
::
vector
<
GoldPile
>
golds
;
int
genGoldAmount
(
Generator
);
Coord
size
;
int
depth
;
};
#endif
This diff is collapsed.
Click to expand it.
src/include/room.h
+
11
−
0
View file @
bf7a83d3
#pragma once
#include
"coord.h"
#include
"level.h"
class
Level
;
class
Room
{
public:
enum
Darkness
{
DARK
,
LIT
};
enum
Treasure
{
TREASURE
,
WORTHLESS
};
enum
Hidden
{
HIDDEN
,
VISIBLE
};
Room
(
Coord
,
Coord
,
Darkness
,
Treasure
,
Hidden
);
Room
(
Coord
,
Coord
);
Coord
operator
[](
int
);
void
dig
(
Level
&
);
...
...
@@ -11,4 +19,7 @@ class Room {
private
:
Coord
topLeft
;
Coord
bottomRight
;
Darkness
isDark
;
Treasure
isTreasure
;
Hidden
isHidden
;
};
This diff is collapsed.
Click to expand it.
src/level.cpp
+
7
−
2
View file @
bf7a83d3
...
...
@@ -49,10 +49,13 @@ void Level::generate(PlayerChar player) {
Coord
roomPosition
,
roomSize
;
do
{
roomSize
=
Coord
(
4
+
gen
.
intFromRange
(
0
,
maxRoomSize
[
0
]
-
4
),
4
+
gen
.
intFromRange
(
0
,
maxRoomSize
[
1
]
-
4
));
Coord
positionRand
=
Coord
(
gen
.
intFromRange
(
0
,
maxRoomSize
[
0
]
-
roomSize
[
0
]),
gen
.
intFromRange
(
0
,
maxRoomSize
[
1
]
-
roomSize
[
1
]));
Coord
positionRand
=
Coord
(
gen
.
intFromRange
(
0
,
maxRoomSize
[
0
]
-
roomSize
[
0
]),
gen
.
intFromRange
(
0
,
maxRoomSize
[
1
]
-
roomSize
[
1
]));
roomPosition
=
boxTopLeft
+
positionRand
;
}
while
(
roomPosition
[
1
]
==
0
);
Room
curRoom
=
Room
(
roomPosition
,
roomPosition
+
roomSize
);
Room
::
Darkness
isDark
=
gen
.
intFromRange
(
0
,
10
)
<
depth
-
1
?
Room
::
DARK
:
Room
::
LIT
;
Room
curRoom
=
Room
(
roomPosition
,
roomPosition
+
roomSize
,
isDark
,
Room
::
WORTHLESS
,
Room
::
VISIBLE
);
curRoom
.
dig
(
*
this
);
//put gold in current room
if
(
gen
()
<
GOLD_CHANCE
&&
(
!
player
.
foundAmulet
()
||
depth
>=
player
.
maxDelved
()))
{
...
...
@@ -61,5 +64,7 @@ void Level::generate(PlayerChar player) {
golds
.
push_back
(
GoldPile
(
goldPos
,
goldAmount
));
}
//put monsters in current room
rooms
.
push_back
(
curRoom
);
}
}
This diff is collapsed.
Click to expand it.
src/room.cpp
+
8
−
1
View file @
bf7a83d3
...
...
@@ -5,9 +5,16 @@
#include
<string>
Room
::
Room
(
Coord
topLeft
,
Coord
bottomRight
)
:
Room
(
topLeft
,
bottomRight
,
LIT
,
WORTHLESS
,
VISIBLE
)
{}
Room
::
Room
(
Coord
topLeft
,
Coord
bottomRight
,
Darkness
dark
,
Treasure
treas
,
Hidden
hid
)
:
topLeft
(
topLeft
)
,
bottomRight
(
bottomRight
)
{}
,
isDark
(
dark
)
,
isTreasure
(
treas
)
,
isHidden
(
hid
)
{}
Coord
Room
::
operator
[](
int
corner
)
{
if
(
corner
==
0
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment