Laila Al Badwawi 200906179 SpaceInvaders I declare this my own independent work and understand the university rules on plagiarism.
Dependencies: mbed
Diff: Alien/Alien.cpp
- Revision:
- 134:2da2db5871bd
- Parent:
- 133:eed60548d170
- Child:
- 137:fe80c0f2da9d
--- a/Alien/Alien.cpp Wed May 08 18:54:03 2019 +0000 +++ b/Alien/Alien.cpp Wed May 08 19:02:21 2019 +0000 @@ -24,31 +24,29 @@ void Alien::draw(N5110 &lcd) { - + lcd.drawSprite(_x_alien,_y_alien,32,32,(int *)alien2); - } - +} -//void Alien::killed(){_dead = true; _x_alien = 0; _y_alien = 0;} void Alien::update(Direction d,float mag) { _speed_alien = int(mag*10.0f); - } +} + +srand(time(NULL)); +_y_alien += rand() % 17 - 8; + - srand(time(NULL)); - _y_alien += rand() % 17 - 8; - - - if(_y_alien>=30){ - _y_alien=30; - } - else - if(_y_alien<=0){ - _y_alien=0; - } - +if(_y_alien>=30) +{ + _y_alien=30; +} else if(_y_alien<=0) +{ + _y_alien=0; +} + } @@ -77,7 +75,7 @@ int Alien::get_score() { return _score; - } +} bool Alien::isAlive() { @@ -87,7 +85,9 @@ void Alien::setAlive(bool alive) { _alive = alive; -} +} + - + +