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
ff2b004d
Commit
ff2b004d
authored
8 years ago
by
Ian Prins
Browse files
Options
Downloads
Patches
Plain Diff
make level getters return references
parent
325ff34a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/include/level.h
+4
-2
4 additions, 2 deletions
src/include/level.h
src/level.cpp
+5
-3
5 additions, 3 deletions
src/level.cpp
with
9 additions
and
5 deletions
src/include/level.h
+
4
−
2
View file @
ff2b004d
...
...
@@ -3,6 +3,7 @@
#include
"terrain.h"
#include
"random.h"
#include
"playerchar.h"
#include
"goldpile.h"
#ifndef LEVEL_H
#define LEVEL_H
...
...
@@ -10,14 +11,15 @@
class
Level
{
public:
Level
(
Coord
,
int
);
Terrain
tileAt
(
Coord
);
Terrain
operator
[](
Coord
);
Terrain
&
tileAt
(
Coord
);
Terrain
&
operator
[](
Coord
);
void
generate
(
PlayerChar
);
private:
const
int
MAX_ROOMS
=
9
;
const
double
GOLD_CHANCE
=
.333
;
std
::
vector
<
std
::
vector
<
Terrain
>
>
tiles
;
std
::
vector
<
Mob
>
mobs
;
std
::
vector
<
GoldPile
>
golds
;
int
genGoldAmount
(
Generator
);
Coord
size
;
int
depth
;
...
...
This diff is collapsed.
Click to expand it.
src/level.cpp
+
5
−
3
View file @
ff2b004d
...
...
@@ -15,16 +15,16 @@ Level::Level(Coord size, int depth)
for
(
auto
x
=
0
;
x
<
size
[
0
];
x
++
)
{
tiles
.
push_back
(
std
::
vector
<
Terrain
>
());
for
(
auto
y
=
0
;
y
<
size
[
1
];
y
++
)
{
tiles
[
x
].
push_back
(
Floor
());
tiles
[
x
].
push_back
(
Wall
());
}
}
}
Terrain
Level
::
operator
[](
Coord
coord
)
{
Terrain
&
Level
::
operator
[](
Coord
coord
)
{
return
tileAt
(
coord
);
}
Terrain
Level
::
tileAt
(
Coord
coord
)
{
Terrain
&
Level
::
tileAt
(
Coord
coord
)
{
return
tiles
[
coord
[
0
]][
coord
[
1
]];
}
...
...
@@ -45,10 +45,12 @@ void Level::generate(PlayerChar player) {
roomPosition
=
boxTopLeft
+
positionRand
;
}
while
(
roomPosition
[
1
]
==
0
);
Room
curRoom
=
Room
(
roomPosition
,
roomPosition
+
roomSize
);
curRoom
.
dig
(
*
this
);
//put gold in current room
if
(
gen
()
<
GOLD_CHANCE
&&
(
!
player
.
foundAmulet
()
||
depth
>=
player
.
maxDelved
()))
{
Coord
goldPos
=
gen
.
randPosition
(
curRoom
[
0
],
curRoom
[
1
]);
int
goldAmount
=
genGoldAmount
(
gen
);
golds
.
push_back
(
GoldPile
(
goldPos
,
goldAmount
));
}
//put monsters in current room
}
...
...
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