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
Onuralp SEZER
Game Library
Commits
26080389
Commit
26080389
authored
2 years ago
by
Joseph Walton-Rivers
Browse files
Options
Downloads
Patches
Plain Diff
don't bother loading 3D stuff for 2D scenes
parent
5b549d1e
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
demo/demo/grid.cpp
+8
-5
8 additions, 5 deletions
demo/demo/grid.cpp
demo/include/grid.hpp
+5
-1
5 additions, 1 deletion
demo/include/grid.hpp
fggl/scenes/game.cpp
+14
-0
14 additions, 0 deletions
fggl/scenes/game.cpp
include/fggl/scenes/game.hpp
+19
-0
19 additions, 0 deletions
include/fggl/scenes/game.hpp
with
46 additions
and
6 deletions
demo/demo/grid.cpp
+
8
−
5
View file @
26080389
...
...
@@ -90,14 +90,15 @@ namespace demo {
auto
player
=
manager
.
create
();
auto
&
cellPos
=
manager
.
add
<
CellPos
>
(
player
);
cellPos
.
pos
=
{
5
,
5
};
cellPos
.
direction
=
1
;
}
}
GridScene
::
GridScene
(
fggl
::
App
&
app
)
:
Game
(
app
),
m_tiles
(),
m_grid
(
nullptr
)
{
GridScene
::
GridScene
(
fggl
::
App
&
app
)
:
Game
Base
(
app
),
m_tiles
(),
m_grid
(
nullptr
)
{
}
void
GridScene
::
activate
()
{
Game
::
activate
();
Game
Base
::
activate
();
fggl
::
debug
::
log
(
fggl
::
debug
::
Level
::
info
,
"GridScene::activate()"
);
...
...
@@ -164,16 +165,18 @@ namespace demo {
// convert grid pos to world pos
fggl
::
math
::
vec2f
drawPos
=
cellPos
.
pos
;
drawPos
*=
DRAW_SIZE
;
drawPos
+=
cellPos
.
drawOffset
;
auto
shape
=
fggl
::
gfx
::
make_shape
(
drawPos
,
DRAW_HALF
,
3
);
fggl
::
gfx
::
ShapeOpts
opts
;
opts
.
angleOffset
=
(
float
)
cellPos
.
direction
*
fggl
::
math
::
HALF_PI
+
cellPos
.
rotationOffset
;
auto
shape
=
fggl
::
gfx
::
make_shape
(
drawPos
,
DRAW_HALF
,
3
,
NAVAJO_WHITE
,
opts
);
paint
.
fill
(
shape
);
}
}
//float progress = 0.0f;
void
GridScene
::
render
(
fggl
::
gfx
::
Graphics
&
gfx
)
{
Game
::
render
(
gfx
);
fggl
::
gfx
::
Paint
paint
;
render_grid
(
paint
,
*
m_grid
);
render_objects
(
paint
,
*
m_grid
);
...
...
This diff is collapsed.
Click to expand it.
demo/include/grid.hpp
+
5
−
1
View file @
26080389
...
...
@@ -35,9 +35,13 @@ namespace demo {
struct
CellPos
{
fggl
::
math
::
vec2i
pos
;
uint8_t
direction
;
fggl
::
math
::
vec2f
drawOffset
{
0.0
F
,
0.0
F
};
float
rotationOffset
{
0.0
F
};
};
class
GridScene
:
public
fggl
::
scenes
::
Game
{
class
GridScene
:
public
fggl
::
scenes
::
Game
Base
{
public:
explicit
GridScene
(
fggl
::
App
&
app
);
void
activate
()
override
;
...
...
This diff is collapsed.
Click to expand it.
fggl/scenes/game.cpp
+
14
−
0
View file @
26080389
...
...
@@ -24,6 +24,20 @@
namespace
fggl
::
scenes
{
GameBase
::
GameBase
(
fggl
::
App
&
app
)
:
AppState
(
app
)
{
m_input
=
app
.
service
<
input
::
Input
>
();
}
void
GameBase
::
update
()
{
// detect the user quitting
if
(
m_input
!=
nullptr
)
{
bool
escapePressed
=
m_input
->
keyboard
.
pressed
(
glfwGetKeyScancode
(
GLFW_KEY_ESCAPE
));
if
(
escapePressed
)
{
m_owner
.
change_state
(
m_previous
);
}
}
}
Game
::
Game
(
fggl
::
App
&
app
)
:
AppState
(
app
)
{
m_input
=
app
.
service
<
input
::
Input
>
();
}
...
...
This diff is collapsed.
Click to expand it.
include/fggl/scenes/game.hpp
+
19
−
0
View file @
26080389
...
...
@@ -25,6 +25,25 @@
namespace
fggl
::
scenes
{
class
GameBase
:
public
fggl
::
AppState
{
public:
explicit
GameBase
(
fggl
::
App
&
app
);
void
update
()
override
;
void
render
(
fggl
::
gfx
::
Graphics
&
gfx
)
override
=
0
;
protected:
inline
auto
input
()
->
input
::
Input
&
{
return
*
m_input
;
}
private
:
input
::
Input
*
m_input
;
std
::
string
m_previous
=
"menu"
;
};
class
Game
:
public
fggl
::
AppState
{
public:
...
...
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