-
Notifications
You must be signed in to change notification settings - Fork 1
/
Enemy.cpp
47 lines (39 loc) · 1018 Bytes
/
Enemy.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
#include "Enemy.h"
Enemy::Enemy(sf::Vector2f pPosition,
sf::Vector2f pVelocity,
sf::Vector2i pSize,
sf::Texture *pTexture,
float pAngle,
float pAngularVelocity) :
//call superclass constructor
AnimatedSprite(pPosition, pVelocity, pSize, pTexture, pAngle, pAngularVelocity)
{
//insert animations based on Enemy spriteSheet
mAnimations.insert(mAnimations.begin(), Animation(2));
mAnimations.insert(mAnimations.begin(), Animation(2));
mAnimations.insert(mAnimations.begin(), Animation(2));
mAnimations.insert(mAnimations.begin(), Animation(2));
//start idle animation
AnimatedSprite::startAnimation();
}
Enemy::~Enemy(void)
{
}
//update based on what state we are in
void Enemy::update()
{
//call superclass update that handles changing pos by velocity and animates
AnimatedSprite::update();
switch (mEnemyState)
{
case eLEFT:
mVelocity = sf::Vector2f(-5,0);
break;
case eRIGHT:
mVelocity = sf::Vector2f(5,0);
break;
default:
mVelocity = sf::Vector2f(0,0);
break;
}
}