/
EnemyTypeOne.cpp
68 lines (50 loc) · 1.16 KB
/
EnemyTypeOne.cpp
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
#include "EnemyTypeOne.h"
#include "GameEngine.h"
EnemyTypeOne::EnemyTypeOne(Image img)
{
image = img;
moveInDir(direction);
moveVelocity(xVelocity, yVelocity);
}
EnemyTypeOne::~EnemyTypeOne(){}
int EnemyTypeOne::xVelocity;
int EnemyTypeOne::yVelocity;
char EnemyTypeOne::direction;
void EnemyTypeOne::updatePosition()
{
rect.y += eto_Y_Velocity;
rect.x += eto_X_Velocity;
}
void EnemyTypeOne::draw(SDL_Surface* window)
{
updatePosition();
SDL_BlitSurface(image.getSurface(), NULL, window, &rect);
}
void EnemyTypeOne::setVelocity(int xVel, int yVel)
{
xVelocity = xVel;
yVelocity = yVel;
}
void EnemyTypeOne::setDirection(char dir)
{
direction = dir;
}
void EnemyTypeOne::moveInDir(char dir)
{
switch(dir)
{
case 't': rect.y = 0; rect.x = get_X_Coordinate(); break;
case 'b': GameEngine::getWindowWidth(); rect.x = get_X_Coordinate(); break;
case 'l': rect.y = get_X_Coordinate(); rect.x = 0; break;
case 'r': rect.y = get_Y_Coordinate(); rect.x = GameEngine::getWindowHeight(); break;
}
}
void EnemyTypeOne::moveVelocity(int xVel, int yVel)
{
eto_X_Velocity = xVel;
eto_Y_Velocity = yVel;
}
SDL_Rect* EnemyTypeOne::getRect()
{
return ▭
}