Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cpp-project
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
David Maul
cpp-project
Commits
bef6bc89
Commit
bef6bc89
authored
5 months ago
by
Frederik
Browse files
Options
Downloads
Patches
Plain Diff
Fix stuff broken by merge
parent
73078f75
No related branches found
No related tags found
2 merge requests
!47
Added Author Tags
,
!46
Merge the refactoring + box2d movement
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/game/level/Level.cpp
+17
-14
17 additions, 14 deletions
src/game/level/Level.cpp
with
17 additions
and
14 deletions
src/game/level/Level.cpp
+
17
−
14
View file @
bef6bc89
...
@@ -56,22 +56,22 @@ Level::Level(const std::string& path, Engine& engine)
...
@@ -56,22 +56,22 @@ Level::Level(const std::string& path, Engine& engine)
// if level is smaler than 20x20 surround with water tiles
// if level is smaler than 20x20 surround with water tiles
if
(
m_width
<
20
||
m_height
<
20
)
if
(
m_width
<
20
||
m_height
<
20
)
{
{
int
x_start
=
(
20
-
width
)
/
2
;
int
x_start
=
(
20
-
m_
width
)
/
2
;
int
y_start
=
(
20
-
height
)
/
2
;
int
y_start
=
(
20
-
m_
height
)
/
2
;
std
::
vector
<
uint8_t
>
transformed_tiles_array
;
std
::
vector
<
uint8_t
>
transformed_tiles_array
;
transformed_tiles_array
.
reserve
(
20
*
20
);
transformed_tiles_array
.
reserve
(
20
*
20
);
for
(
int
y
=
0
;
y
<
20
;
y
++
)
for
(
int
y
=
0
;
y
<
20
;
y
++
)
{
{
for
(
int
x
=
0
;
x
<
20
;
x
++
)
for
(
int
x
=
0
;
x
<
20
;
x
++
)
{
{
if
(
x
<
x_start
||
y
<
y_start
||
x
>=
x_start
+
width
||
y
>=
y_start
+
height
)
if
(
x
<
x_start
||
y
<
y_start
||
x
>=
x_start
+
m_
width
||
y
>=
y_start
+
m_
height
)
{
{
transformed_tiles_array
.
push_back
(
1
);
transformed_tiles_array
.
push_back
(
1
);
}
}
else
else
{
{
transformed_tiles_array
.
push_back
(
transformed_tiles_array
.
push_back
(
level_tilesarray
[
x
-
x_start
+
(
y
-
y_start
)
*
width
]);
level_tilesarray
[
x
-
x_start
+
(
y
-
y_start
)
*
m_
width
]);
}
}
}
}
}
}
...
@@ -94,20 +94,24 @@ Level::Level(const std::string& path, Engine& engine)
...
@@ -94,20 +94,24 @@ Level::Level(const std::string& path, Engine& engine)
if
(
level_tilesarray
[
i
]
>=
50
)
if
(
level_tilesarray
[
i
]
>=
50
)
{
{
// tile id >= 50 -> building -> have to add Plain Tile and Building
// tile id >= 50 -> building -> have to add Plain Tile and Building
tiles
.
push_back
(
Tile
(
TileId
(
TileId
::
PLAIN
),
x
,
y
));
tiles
.
push_back
(
Tile
(
TileId
(
TileId
::
PLAIN
),
tileX
,
tileY
));
BuildingId
building_id
=
static_cast
<
BuildingId
>
((
level_tilesarray
[
i
]
-
50
)
%
5
);
BuildingId
building_id
=
static_cast
<
BuildingId
>
((
level_tilesarray
[
i
]
-
50
)
%
5
);
BuildingFaction
faction_id
=
Faction
faction_id
=
static_cast
<
Faction
>
((
level_tilesarray
[
i
]
-
50
)
/
5
);
static_cast
<
BuildingFaction
>
((
level_tilesarray
[
i
]
-
50
)
/
5
);
if
(
building_id
==
BuildingId
::
HEADQUARTER
)
if
(
building_id
==
BuildingId
::
HEADQUARTER
)
{
{
// an infantery unit should be added onto every HQ
// an infantery unit should be added onto every HQ
units
.
push_back
(
Unit
(
int
index
=
static_cast
<
int
>
(
faction_id
);
x
,
y
,
static_cast
<
UnitFaction
>
(
faction_id
),
UnitId
::
INFANTERY
,
if
(
!
has_factions
[
index
])
UnitState
::
UNAVAILABLE
,
engine
.
getUnitConfig
()));
{
addUnit
(
tileX
,
tileY
,
faction_id
,
UnitTypeId
::
INFANTERY
,
UnitState
::
UNAVAILABLE
,
engine
.
getUnitConfig
());
}
has_factions
[
static_cast
<
int
>
(
faction_id
)]
=
true
;
// collect existing factions
has_factions
[
static_cast
<
int
>
(
faction_id
)]
=
true
;
// collect existing factions
// for later building turnQ
// for later building turnQ
}
}
buildings
.
push_back
(
Building
(
tileX
,
tileY
,
building_id
,
faction
I
d
));
buildings
.
push_back
(
Building
(
tileX
,
tileY
,
building_id
,
faction
_i
d
));
}
}
else
else
{
{
...
@@ -142,8 +146,7 @@ Level::Level(const std::string& path, Engine& engine)
...
@@ -142,8 +146,7 @@ Level::Level(const std::string& path, Engine& engine)
m_turnQ
=
turnQ
;
m_turnQ
=
turnQ
;
level
.
m_turnQ
.
front
().
startTurn
(
level
.
m_units
,
level
.
m_buildings
);
m_turnQ
.
front
().
startTurn
(
m_units
,
m_buildings
);
return
std
::
make_shared
<
Level
>
(
level
);
}
}
std
::
pair
<
int
,
int
>
Level
::
calcTilePos
(
int
mouseX
,
int
mouseY
)
std
::
pair
<
int
,
int
>
Level
::
calcTilePos
(
int
mouseX
,
int
mouseY
)
...
...
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