ELEC2645 (2019/20)
/
ELEC2645_Project_el18jb
test 1 doc
Diff: Ennemy/Enemy.cpp
- Revision:
- 11:b3024ab59fa5
- Parent:
- 10:9317a62bd4d0
--- a/Ennemy/Enemy.cpp Wed May 27 02:00:08 2020 +0000 +++ b/Ennemy/Enemy.cpp Wed May 27 03:52:11 2020 +0000 @@ -26,14 +26,14 @@ //update -void Enemy::update(int _evx, int _evy) +void Enemy::update(int _ev) { - if( _type == 0 ) { + if( _type == TYPE_HOR ) { // go left or right depending on direction switch (xDir) { case 1: - _enX -= _evx; + _enX -= _ev; //switch direction when it hits a wall if(_enX + 7 > WIDTH || _enX < 0) { xDir = 0; @@ -41,7 +41,7 @@ } break; case 0: - _enX += _evx; + _enX += _ev; //switch direction when it hits a wall if(_enX + 7 > WIDTH || _enX < 0) { xDir = 1; @@ -51,11 +51,11 @@ } } - if( _type == 1 ) { + if( _type == TYPE_VERT ) { // go up or down depending on direction switch (yDir) { case 1: - _enY -= _evy; + _enY -= _ev; //switch direction when it hits a wall if(_enY + 5 > HEIGHT || _enY < 0) { yDir = 0; @@ -63,7 +63,7 @@ } break; case 0: - _enY += _evy; + _enY += _ev; //switch direction when it hits a wall if(_enY + 5 > HEIGHT || _enY < 0) { yDir = 1;