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
f01edb68
Commit
f01edb68
authored
6 months ago
by
fdai7466
Browse files
Options
Downloads
Patches
Plain Diff
add dynamic TileMarker color
parent
94659fe2
Branches
Branches containing commit
No related tags found
2 merge requests
!33
Win end screen
,
!29
Merge main into box2d to implement physics
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/game/Engine.cpp
+2
-1
2 additions, 1 deletion
src/game/Engine.cpp
src/game/ui/TileMarker.cpp
+26
-2
26 additions, 2 deletions
src/game/ui/TileMarker.cpp
src/game/ui/TileMarker.hpp
+11
-7
11 additions, 7 deletions
src/game/ui/TileMarker.hpp
with
39 additions
and
10 deletions
src/game/Engine.cpp
+
2
−
1
View file @
f01edb68
...
...
@@ -106,7 +106,8 @@ void Engine::render()
std
::
shared_ptr
<
Scene
>
currentScene
=
m_scenes
.
back
();
currentScene
->
render
(
*
this
);
// prevent epilepsy
SDL_SetRenderDrawColor
(
this
->
m_SDLRenderer
,
128
,
128
,
128
,
128
);
SDL_RenderPresent
(
this
->
m_SDLRenderer
);
}
...
...
This diff is collapsed.
Click to expand it.
src/game/ui/TileMarker.cpp
+
26
−
2
View file @
f01edb68
...
...
@@ -4,7 +4,7 @@
namespace
advanced_wars
{
TileMarker
::
TileMarker
(
int
renderingScale
,
int
tileX
,
int
tileY
,
int
levelWidth
,
int
levelHeight
)
:
m_renderingScale
(
renderingScale
),
m_width
(
16
),
m_height
(
16
)
:
m_renderingScale
(
renderingScale
),
m_width
(
16
),
m_height
(
16
)
,
m_markerColor
({
255
,
0
,
0
,
255
})
{
int
tileSize
=
16
*
renderingScale
;
m_x
=
tileX
*
tileSize
;
...
...
@@ -15,7 +15,8 @@ TileMarker::TileMarker(int renderingScale, int tileX, int tileY, int levelWidth,
void
TileMarker
::
render
(
Engine
&
engine
)
{
SDL_SetRenderDrawColor
(
engine
.
renderer
(),
255
,
0
,
0
,
255
);
SDL_SetRenderDrawColor
(
engine
.
renderer
(),
m_markerColor
.
r
,
m_markerColor
.
g
,
m_markerColor
.
b
,
m_markerColor
.
a
);
SDL_Rect
box
=
{
m_x
,
m_y
,
m_width
,
m_height
};
SDL_RenderFillRect
(
engine
.
renderer
(),
&
box
);
}
...
...
@@ -88,4 +89,27 @@ void TileMarker::setPosition(int tileX, int tileY)
m_y
=
tileY
*
16
*
m_renderingScale
+
(
16
*
m_renderingScale
-
m_height
);
}
void
TileMarker
::
setMarkerColor
(
PlayerFaction
faction
)
{
switch
(
faction
)
{
case
PlayerFaction
::
RED
:
m_markerColor
=
{
255
,
0
,
0
,
255
};
break
;
case
PlayerFaction
::
BLUE
:
m_markerColor
=
{
0
,
0
,
255
,
255
};
break
;
case
PlayerFaction
::
GREEN
:
m_markerColor
=
{
0
,
255
,
0
,
255
};
break
;
case
PlayerFaction
::
YELLOW
:
m_markerColor
=
{
255
,
255
,
0
,
255
};
break
;
case
PlayerFaction
::
PURPLE
:
m_markerColor
=
{
255
,
0
,
255
,
255
};
break
;
default
:
break
;
}
}
}
// namespace advanced_wars
This diff is collapsed.
Click to expand it.
src/game/ui/TileMarker.hpp
+
11
−
7
View file @
f01edb68
#pragma once
#include
"../Player.hpp"
#include
"../Scene.hpp"
namespace
advanced_wars
...
...
@@ -21,6 +22,8 @@ class TileMarker : public Scene
void
setPosition
(
int
x
,
int
y
);
void
setMarkerColor
(
PlayerFaction
faction
);
private:
int
m_x
;
int
m_y
;
...
...
@@ -29,5 +32,6 @@ class TileMarker : public Scene
int
m_height
;
int
m_levelHeight
;
int
m_levelWidth
;
SDL_Color
m_markerColor
;
};
}
// namespace advanced_wars
\ 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