Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Game Library
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Game Development
Game Library
Commits
9e6f29ea
Commit
9e6f29ea
authored
2 years ago
by
Joseph Walton-Rivers
Browse files
Options
Downloads
Patches
Plain Diff
add victory condition
parent
9402eae2
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
demo/demo/grid.cpp
+18
-4
18 additions, 4 deletions
demo/demo/grid.cpp
demo/include/grid.hpp
+1
-0
1 addition, 0 deletions
demo/include/grid.hpp
include/fggl/scenes/game.hpp
+4
-1
4 additions, 1 deletion
include/fggl/scenes/game.hpp
with
23 additions
and
5 deletions
demo/demo/grid.cpp
+
18
−
4
View file @
9e6f29ea
...
@@ -28,10 +28,9 @@ namespace demo {
...
@@ -28,10 +28,9 @@ namespace demo {
using
namespace
fggl
::
entity
::
grid
;
using
namespace
fggl
::
entity
::
grid
;
static
void
build_tileset
(
TileSet
&
tiles
)
{
static
void
build_tileset
(
TileSet
&
tiles
)
{
fggl
::
entity
::
grid
::
FloorTile
empty
{
fggl
::
entity
::
grid
::
FloorTile
::
IMPOSSIBLE
,
BLACK
};
tiles
.
m_floors
.
push_back
(
FloorTile
{
FloorTile
::
IMPOSSIBLE
,
BLACK
});
fggl
::
entity
::
grid
::
FloorTile
ground
{
1
,
GREEN
};
tiles
.
m_floors
.
push_back
(
FloorTile
{
1
,
GREEN
});
tiles
.
m_floors
.
push_back
(
empty
);
tiles
.
m_floors
.
push_back
(
FloorTile
{
1
,
YELLOW_GREEN
});
tiles
.
m_floors
.
push_back
(
ground
);
fggl
::
entity
::
grid
::
WallTile
noWall
{};
fggl
::
entity
::
grid
::
WallTile
noWall
{};
tiles
.
m_walls
.
push_back
(
noWall
);
tiles
.
m_walls
.
push_back
(
noWall
);
...
@@ -82,6 +81,9 @@ namespace demo {
...
@@ -82,6 +81,9 @@ namespace demo {
build_doorway
(
area
,
{
10
,
5
},
false
,
1
);
build_doorway
(
area
,
{
10
,
5
},
false
,
1
);
build_doorway
(
area
,
{
13
,
5
},
false
,
1
);
build_doorway
(
area
,
{
13
,
5
},
false
,
1
);
// set goal
area
->
setFloorAt
(
17
,
5
,
2
);
build_room
(
area
,
{
25
,
5
},
{
3
,
3
});
build_room
(
area
,
{
25
,
5
},
{
3
,
3
});
// player
// player
...
@@ -273,6 +275,18 @@ namespace demo {
...
@@ -273,6 +275,18 @@ namespace demo {
m_program
.
playing
=
false
;
m_program
.
playing
=
false
;
m_program
.
m_currInstruction
=
0
;
m_program
.
m_currInstruction
=
0
;
m_program
.
m_instructions
.
clear
();
m_program
.
m_instructions
.
clear
();
checkVictory
();
}
}
void
GridScene
::
checkVictory
()
{
if
(
!
m_program
.
playing
)
{
auto
&
botPos
=
m_grid
->
entities
().
get
<
CellPos
>
(
m_player
).
pos
;
auto
gridCell
=
m_grid
->
floorAt
(
botPos
.
x
,
botPos
.
y
);
if
(
gridCell
.
colour
==
YELLOW_GREEN
)
{
// a winner is you!
returnToMenu
();
}
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
demo/include/grid.hpp
+
1
−
0
View file @
9e6f29ea
...
@@ -68,6 +68,7 @@ namespace demo {
...
@@ -68,6 +68,7 @@ namespace demo {
Program
m_program
;
Program
m_program
;
void
tickPlayer
();
void
tickPlayer
();
void
checkVictory
();
inline
void
forward
()
{
inline
void
forward
()
{
auto
&
cell
=
m_grid
->
entities
().
get
<
CellPos
>
(
m_player
);
auto
&
cell
=
m_grid
->
entities
().
get
<
CellPos
>
(
m_player
);
...
...
This diff is collapsed.
Click to expand it.
include/fggl/scenes/game.hpp
+
4
−
1
View file @
9e6f29ea
...
@@ -34,11 +34,14 @@ namespace fggl::scenes {
...
@@ -34,11 +34,14 @@ namespace fggl::scenes {
void
render
(
fggl
::
gfx
::
Graphics
&
gfx
)
override
=
0
;
void
render
(
fggl
::
gfx
::
Graphics
&
gfx
)
override
=
0
;
protected:
protected:
inline
auto
input
()
->
input
::
Input
&
{
inline
auto
input
()
->
input
::
Input
&
{
return
*
m_input
;
return
*
m_input
;
}
}
inline
void
returnToMenu
()
{
m_owner
.
change_state
(
m_previous
);
}
private
:
private
:
input
::
Input
*
m_input
;
input
::
Input
*
m_input
;
std
::
string
m_previous
=
"menu"
;
std
::
string
m_previous
=
"menu"
;
...
...
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