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
72825774
Commit
72825774
authored
6 months ago
by
Lorenz Martin Diel
Browse files
Options
Downloads
Patches
Plain Diff
unit hpp
parent
77c17106
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/level.hpp
+74
-17
74 additions, 17 deletions
src/level.hpp
src/tile.hpp
+13
-2
13 additions, 2 deletions
src/tile.hpp
src/unit.hpp
+50
-11
50 additions, 11 deletions
src/unit.hpp
with
137 additions
and
30 deletions
src/level.hpp
+
74
−
17
View file @
72825774
...
...
@@ -9,12 +9,69 @@
#include
<vector>
#include
<SDL.h>
#include
<boost/graph/adjacency_list.hpp>
#include
<boost/graph/dijkstra_shortest_paths.hpp>
namespace
advanced_wars
{
/**
* @brief The main window of the game
*/
struct
VertexProperties
{
int
x
;
int
y
;
TerrainType
terrain
;
}
struct
EdgeProperties
{
int
weight
;
}
using
Graph
=
boost
::
adjacency_list
<
boost
::
vecS
,
// OutEdgeList
boost
::
vecS
,
// VertexList
boost
::
undirectedS
,
// Directed
VertexProperties
,
// Vertex properties
EdgeProperties
// Edge properties
>
;
using
Vertex
=
boost
::
graph_traits
<
Graph
>::
vertex_descriptor
;
const
std
::
map
<
std
::
pair
<
MovementType
,
TerrainType
>
,
int
>
MOVEMENT_COSTS
=
{
{{
MovementType
::
INFANTRY
,
TerrainType
::
PLAIN
},
1
},
{{
MovementType
::
INFANTRY
,
TerrainType
::
FOREST
},
2
},
{{
MovementType
::
INFANTRY
,
TerrainType
::
MOUNTAIN
},
2
},
{{
MovementType
::
INFANTRY
,
TerrainType
::
STREET
},
1
},
{{
MovementType
::
INFANTRY
,
TerrainType
::
WATER
},
999
},
{{
MovementType
::
TRACKED
,
TerrainType
::
PLAIN
},
1
},
{{
MovementType
::
TRACKED
,
TerrainType
::
FOREST
},
2
},
{{
MovementType
::
TRACKED
,
TerrainType
::
MOUNTAIN
},
999
},
{{
MovementType
::
TRACKED
,
TerrainType
::
STREET
},
1
},
{{
MovementType
::
TRACKED
,
TerrainType
::
WATER
},
999
},
{{
MovementType
::
WHEELED
,
TerrainType
::
PLAIN
},
2
},
{{
MovementType
::
WHEELED
,
TerrainType
::
FOREST
},
3
},
{{
MovementType
::
WHEELED
,
TerrainType
::
MOUNTAIN
},
999
},
{{
MovementType
::
WHEELED
,
TerrainType
::
STREET
},
1
},
{{
MovementType
::
WHEELED
,
TerrainType
::
WATER
},
999
},
{{
MovementType
::
AIR
,
TerrainType
::
PLAIN
},
1
},
{{
MovementType
::
AIR
,
TerrainType
::
FOREST
},
1
},
{{
MovementType
::
AIR
,
TerrainType
::
MOUNTAIN
},
1
},
{{
MovementType
::
AIR
,
TerrainType
::
STREET
},
1
},
{{
MovementType
::
AIR
,
TerrainType
::
WATER
},
999
},
{{
MovementType
::
SHIPENGINE
,
TerrainType
::
PLAIN
},
999
},
{{
MovementType
::
SHIPENGINE
,
TerrainType
::
FOREST
},
999
},
{{
MovementType
::
SHIPENGINE
,
TerrainType
::
MOUNTAIN
},
999
},
{{
MovementType
::
SHIPENGINE
,
TerrainType
::
STREET
},
999
},
{{
MovementType
::
SHIPENGINE
,
TerrainType
::
WATER
},
1
}};
class
Level
:
public
Scene
{
public:
...
...
This diff is collapsed.
Click to expand it.
src/tile.hpp
+
13
−
2
View file @
72825774
#ifndef TILE_HPP
#define TILE_HPP
class
Tile
{
enum
class
TerrainType
{
PLAIN
,
MOUNTAIN
,
FOREST
,
WATER
,
STREET
,
AIR
};
class
Tile
{
public:
Tile
();
};
...
...
This diff is collapsed.
Click to expand it.
src/unit.hpp
+
50
−
11
View file @
72825774
...
...
@@ -3,23 +3,27 @@
#include
<string>
#include
<utility>
#include
"tile.hpp"
// Enumerationen für Bewegungstyp und Waffenart
enum
class
MovementType
{
Foot
,
Tracks
,
Wheels
,
Air
,
Shipengine
enum
class
MovementType
{
INFANTRY
,
TRACKS
,
WHEELS
,
AIR
,
SHIPENIGNE
};
enum
class
WeaponType
{
Gun
,
Rocket
enum
class
WeaponType
{
GUN
,
ROCKET
};
// Deklaration der Unit-Klasse
class
Unit
{
class
Unit
{
public:
// Konstruktor
Unit
(
std
::
string
name
,
int
health
,
int
speed
,
int
attack
,
std
::
pair
<
int
,
int
>
range
,
MovementType
movement
,
WeaponType
weapon
);
...
...
@@ -51,6 +55,41 @@ private:
WeaponType
weapon
;
int
x
;
// Position auf der x-Achse
int
y
;
// Position auf der y-Achse
// Definition der statischen Bewegungskosten
const
std
::
map
<
std
::
pair
<
MovementType
,
TerrainType
>
,
int
>
MOVEMENT_COSTS
=
{
{{
MovementType
::
INFANTRY
,
TerrainType
::
PLAIN
},
1
},
{{
MovementType
::
INFANTRY
,
TerrainType
::
FOREST
},
2
},
{{
MovementType
::
INFANTRY
,
TerrainType
::
MOUNTAIN
},
2
},
{{
MovementType
::
INFANTRY
,
TerrainType
::
STREET
},
1
},
{{
MovementType
::
INFANTRY
,
TerrainType
::
WATER
},
999
},
{{
MovementType
::
TRACKED
,
TerrainType
::
PLAIN
},
1
},
{{
MovementType
::
TRACKED
,
TerrainType
::
FOREST
},
2
},
{{
MovementType
::
TRACKED
,
TerrainType
::
MOUNTAIN
},
999
},
{{
MovementType
::
TRACKED
,
TerrainType
::
STREET
},
1
},
{{
MovementType
::
TRACKED
,
TerrainType
::
WATER
},
999
},
{{
MovementType
::
WHEELED
,
TerrainType
::
PLAIN
},
2
},
{{
MovementType
::
WHEELED
,
TerrainType
::
FOREST
},
3
},
{{
MovementType
::
WHEELED
,
TerrainType
::
MOUNTAIN
},
999
},
{{
MovementType
::
WHEELED
,
TerrainType
::
STREET
},
1
},
{{
MovementType
::
WHEELED
,
TerrainType
::
WATER
},
999
},
{{
MovementType
::
AIR
,
TerrainType
::
PLAIN
},
1
},
{{
MovementType
::
AIR
,
TerrainType
::
FOREST
},
1
},
{{
MovementType
::
AIR
,
TerrainType
::
MOUNTAIN
},
1
},
{{
MovementType
::
AIR
,
TerrainType
::
STREET
},
1
},
{{
MovementType
::
AIR
,
TerrainType
::
WATER
},
999
},
{{
MovementType
::
SHIPENGINE
,
TerrainType
::
PLAIN
},
999
},
{{
MovementType
::
SHIPENGINE
,
TerrainType
::
FOREST
},
999
},
{{
MovementType
::
SHIPENGINE
,
TerrainType
::
MOUNTAIN
},
999
},
{{
MovementType
::
SHIPENGINE
,
TerrainType
::
STREET
},
999
},
{{
MovementType
::
SHIPENGINE
,
TerrainType
::
WATER
},
1
}
};
};
#endif // UNIT_HPP
\ No newline at end of file
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