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
5b4db2eb
Commit
5b4db2eb
authored
2 years ago
by
Joseph Walton-Rivers
Browse files
Options
Downloads
Patches
Plain Diff
extract magic numbers from hexboard into constants
parent
c0c7a9a5
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
demo/demo/hexboard/board.cpp
+13
-10
13 additions, 10 deletions
demo/demo/hexboard/board.cpp
with
13 additions
and
10 deletions
demo/demo/hexboard/board.cpp
+
13
−
10
View file @
5b4db2eb
...
@@ -19,31 +19,34 @@
...
@@ -19,31 +19,34 @@
#include
"hexboard/scene.hpp"
#include
"hexboard/scene.hpp"
namespace
demo
::
hexboard
{
namespace
demo
::
hexboard
{
constexpr
float
SCROLL_SPEED
=
0.01
F
;
constexpr
float
HEX_SIZE
=
64.0
F
;
constexpr
std
::
array
<
fggl
::
grid
::
IntHex
,
4
>
ISLAND_CENTERS
{{
{
2
,
3
},
{
6
,
7
},
{
9
,
10
},
{
6
,
3
}
}};
Scene
::
Scene
(
fggl
::
App
&
app
)
:
GameBase
(
app
),
m_board
(
nullptr
),
m_screen
(
1920.
F
,
1080.
F
)
{
Scene
::
Scene
(
fggl
::
App
&
app
)
:
GameBase
(
app
),
m_board
(
nullptr
),
m_screen
(
1920.
F
,
1080.
F
)
{
}
}
void
Scene
::
activate
()
{
void
Scene
::
activate
()
{
m_board
=
std
::
make_unique
<
fggl
::
grid
::
HexGrid
>
();
m_board
=
std
::
make_unique
<
fggl
::
grid
::
HexGrid
>
();
m_layout
=
std
::
make_unique
<
fggl
::
grid
::
Layout
>
(
fggl
::
grid
::
Orientation
::
make_pointy
(),
64.0
F
);
m_layout
=
std
::
make_unique
<
fggl
::
grid
::
Layout
>
(
fggl
::
grid
::
Orientation
::
make_pointy
(),
HEX_SIZE
);
//m_layout->m_origin = { 1920.0F * -0.5F, 1080.0F * -0.5F};
//m_layout->m_origin = { 1920.0F * -0.5F, 1080.0F * -0.5F};
m_selections
=
std
::
make_unique
<
SelectionModel
>
();
m_selections
=
std
::
make_unique
<
SelectionModel
>
();
fggl
::
grid
::
TerrainType
grass
{
const
fggl
::
grid
::
TerrainType
grass
{
.
data
=
std
::
make_shared
<
fggl
::
grid
::
MaterialData
>
()
.
data
=
std
::
make_shared
<
fggl
::
grid
::
MaterialData
>
()
};
};
grass
.
data
->
name
=
"grass"
;
grass
.
data
->
name
=
"grass"
;
grass
.
data
->
colour
=
{
0.0
F
,
1.0
F
,
0.0
};
grass
.
data
->
colour
=
{
0.0
F
,
1.0
F
,
0.0
};
std
::
array
<
fggl
::
grid
::
IntHex
,
4
>
islands
{{
for
(
auto
islandPoint
:
ISLAND_CENTERS
){
{
3
,
3
},
{
7
,
7
},
{
10
,
10
},
{
7
,
3
}
}};
for
(
auto
islandPoint
:
islands
){
auto
island
=
islandPoint
.
hexesInRange
(
2
);
auto
island
=
islandPoint
.
hexesInRange
(
2
);
for
(
auto
&
hex
:
island
)
{
for
(
auto
&
hex
:
island
)
{
m_board
->
setTerrain
(
hex
,
grass
);
m_board
->
setTerrain
(
hex
,
grass
);
...
@@ -88,7 +91,7 @@ namespace demo::hexboard {
...
@@ -88,7 +91,7 @@ namespace demo::hexboard {
}
}
auto
offset
=
screenPos
-
m_dragging
.
value
();
auto
offset
=
screenPos
-
m_dragging
.
value
();
m_camera
->
teleportBy
(
offset
*
0.01
F
);
m_camera
->
teleportBy
(
offset
*
SCROLL_SPEED
);
}
else
if
(
input
.
mouse
.
released
(
fggl
::
input
::
MouseButton
::
RIGHT
)
)
{
}
else
if
(
input
.
mouse
.
released
(
fggl
::
input
::
MouseButton
::
RIGHT
)
)
{
m_dragging
=
{};
m_dragging
=
{};
}
}
...
...
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