Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GCCProg
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Claudio Hoffmann
GCCProg
Commits
dad62155
Commit
dad62155
authored
4 years ago
by
il0z
Browse files
Options
Downloads
Patches
Plain Diff
Spawn Enemies endlessly
parent
ac6ccc13
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
main.cpp
+99
-12
99 additions, 12 deletions
main.cpp
with
99 additions
and
12 deletions
main.cpp
+
99
−
12
View file @
dad62155
...
...
@@ -16,10 +16,21 @@
//constexpr double PI = 3.14159265358979323846;
// <kruegerzo72182
bool
debug
=
false
;
bool
spawnTroopers
=
true
;
float
trooperTimer
=
0.0f
;
float
trooperSpawnTime
=
3.0f
;
int
trooperSpawnX
=
120
;
int
trooperSpawnY
=
170
;
int
trooperSpawnCount
=
1
;
// +1
float
bomberTimer
=
25.0f
;
float
bomberSpawnTime
=
30.0f
;
float
tankTimer
=
15.0f
;
float
tankSpawnTime
=
25.0f
;
float
difficultyTimer
=
0.0f
;
float
difficultyChangeTime
=
60.0f
;
int
screenWidth
=
320
;
int
screenHeigth
=
320
;
int
difficulty
=
0
;
// global helper funktion to add "buildings"
void
addBuilding
(
float
x
,
float
y
,
int
size
,
Level
&
level_ptr
)
...
...
@@ -62,26 +73,38 @@ public:
}
else
{
platform
.
set_title
(
"Player X: "
+
std
::
to_string
(
std
::
lround
(
player_
.
getLeft
()))
+
"
<
Player X: "
+
std
::
to_string
(
std
::
lround
(
player_
.
get
Top
Left
()
.
X
))
+
" --- Player Y: "
+
std
::
to_string
(
std
::
lround
(
player_
.
getTop
()))
std
::
to_string
(
std
::
lround
(
player_
.
getTopLeft
().
Y
))
+
" --- difficulty: "
+
std
::
to_string
(
difficulty
)
+
" --- trooperSpawnCount: "
+
std
::
to_string
(
trooperSpawnCount
)
+
" --- debug>"
);
}
}
// hoffmanncl72341>
// <kruegerzo72182
//Spawn the troopers from the trooperspawner
if
(
spawnTroopers
){
trooperTimer
=
trooperTimer
+
frame_time
.
count
();
if
(
level
.
getEnemySpawnCount
()
!=
0
){
if
(
trooperTimer
>
3.0f
){
if
(
trooperTimer
>
trooperSpawnTime
){
level
.
enemyVector_PushBack
(
level
.
getTrooperSpawn
());
trooperTimer
=
0.0f
;
}
}
else
{
spawnTroopers
=
false
;
level
.
fillTrooperSpawner
(
static_cast
<
float
>
(
trooperSpawnX
),
static_cast
<
float
>
(
trooperSpawnY
),
trooperSpawnCount
);
}
}
if
(
true
){
}
//Spawn bombers from different directions endlessly
bomberTimer
=
bomberTimer
+
frame_time
.
count
();
if
(
bomberTimer
>
30.0f
){
if
(
bomberTimer
>
bomberSpawnTime
){
int
direction
=
rand
()
%
4
;
float
bombX
;
float
bombY
;
...
...
@@ -106,6 +129,59 @@ public:
}
level
.
enemyVector_PushBack
(
std
::
make_unique
<
Bomber
>
(
Bomber
(
bombX
,
bombY
,
direction
,
0
)));
bomberTimer
=
0.0f
;
if
(
difficulty
<
25
)
{
bomberSpawnTime
=
bomberSpawnTime
-
difficulty
;
}
}
if
(
bomberSpawnTime
<
4
){
bomberSpawnTime
=
5
;
}
tankTimer
=
tankTimer
+
frame_time
.
count
();
if
(
tankTimer
>
tankSpawnTime
){
int
direction
=
0
;
int
position
=
rand
()
%
6
;
float
tankX
;
float
tankY
;
switch
(
position
)
{
case
1
:
tankX
=
static_cast
<
float
>
(
50
);
tankY
=
static_cast
<
float
>
(
150
);
direction
=
0
;
break
;
case
2
:
tankX
=
static_cast
<
float
>
(
200
);
tankY
=
static_cast
<
float
>
(
160
);
direction
=
2
;
break
;
case
3
:
tankX
=
static_cast
<
float
>
(
270
);
tankY
=
static_cast
<
float
>
(
50
);
direction
=
1
;
break
;
case
4
:
tankX
=
static_cast
<
float
>
(
15
);
tankY
=
static_cast
<
float
>
(
225
);
direction
=
3
;
break
;
case
5
:
tankX
=
static_cast
<
float
>
(
170
);
tankY
=
static_cast
<
float
>
(
210
);
direction
=
2
;
break
;
default:
tankX
=
static_cast
<
float
>
(
20
);
tankY
=
static_cast
<
float
>
(
25
);
direction
=
3
;
break
;
}
level
.
enemyVector_PushBack
(
std
::
make_unique
<
Tank
>
(
Tank
(
tankX
,
tankY
,
direction
,
0
)));
tankTimer
=
0.0f
;
if
(
difficulty
<
25
)
{
//tankSpawnTime = tankSpawnTime - difficulty;
}
}
// kruegerzo72182>
...
...
@@ -121,6 +197,17 @@ public:
// enemy movement
GameOverFlag
=
(
level
.
doDoSteps
(
frame_time
)
==
false
);
difficultyTimer
=
difficultyTimer
+
frame_time
.
count
();
if
((
difficultyTimer
>
difficultyChangeTime
))
{
difficulty
++
;
difficultyTimer
=
0.0f
;
spawnTroopers
=
true
;
if
(
trooperSpawnCount
<
11
&&
difficulty
%
4
==
0
){
trooperSpawnCount
=
trooperSpawnCount
+
2
;
}
}
// Output to the console, Gamelogic should happen before this
auto
const
&
levelBuffer
=
level
.
draw
();
if
(
GameOverFlag
)
{
...
...
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