-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImplementations.cpp
More file actions
84 lines (73 loc) · 1.2 KB
/
Implementations.cpp
File metadata and controls
84 lines (73 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#include "Declarations.h"
Player* newPlayer(char* name)
{
Player player;
player.name = name;
player.lives = 3;
player.score = 0;
player.yPosition = 0;
player.bullets->pos.x;
player.bullets->pos.y;
player.bullets->shot = false;
return &player;
}
void deletePlayer(Player* mPlayer)
{
mPlayer = 0;
}
void movePlayerUp(Player* mPlayer)
{
mPlayer->yPosition -= 1;
if (mPlayer->yPosition < 0)
{
mPlayer->yPosition = 0;
}
}
void movePlayerDown(Player* mPlayer)
{
mPlayer->yPosition += 1;
if (mPlayer->yPosition < 9)
{
mPlayer->yPosition = 9;
}
}
void newShoot(Player* mPlayer)
{
if (mPlayer->bullets->shot = false)
{
mPlayer->bullets->shot = true;
mPlayer->bullets->pos.x = 1;
mPlayer->bullets->pos.y = mPlayer->yPosition;
}
}
void updateBulletsPositions(Player* mPlayer)
{
mPlayer->bullets->pos.x += 1;
if (mPlayer->bullets->pos.x = 60)
{
mPlayer->bullets->shot = false;
}
}
Enemy* newEnemy()
{
Enemy enemy;
enemy.pos.x = 59;
enemy.pos.y = rand() % 10;
return &enemy;
}
void deleteEnemy(Enemy* mEnemy)
{
mEnemy = 0;
}
void updateEnemyPosition(Enemy* mEnemy)
{
mEnemy->pos.x -= 1;
}
bool checkEnemyHit(Enemy* mEnemy)
{
if (mEnemy->pos.x == 0)
{
return true;
}
return false;
}