Laila Al Badwawi 200906179 SpaceInvaders I declare this my own independent work and understand the university rules on plagiarism.
Dependencies: mbed
Diff: Spaceship/Spaceship.cpp
- Revision:
- 136:58f393968aa3
- Parent:
- 135:cf08bb4bdee9
--- a/Spaceship/Spaceship.cpp Wed May 08 19:06:19 2019 +0000 +++ b/Spaceship/Spaceship.cpp Wed May 08 19:10:28 2019 +0000 @@ -9,43 +9,39 @@ void Spaceship::init(int x_spaceship,int y_spaceship, int speed_spaceship) { - - _x_spaceship= x_spaceship; - _y_spaceship= y_spaceship; - _speed_spaceship= speed_spaceship; + + _x_spaceship= x_spaceship; + _y_spaceship= y_spaceship; + _speed_spaceship= speed_spaceship; } void Spaceship::draw(N5110 &lcd) { - + lcd.drawSprite(_x_spaceship,_y_spaceship,32,32,(int *) spaceship2); - + } void Spaceship::update(Direction d,float mag) { _speed_spaceship = int(mag*10.0f); - - if(d==N){ - // printf("North\n"); - _y_spaceship-=2; - } - else - if(d==S){ - // printf("North\n"); - _y_spaceship+=2; - - } - - if(_y_spaceship>=30){ - _y_spaceship=30; - } - else - if(_y_spaceship<=0){ - _y_spaceship=0; - } - + + if(d==N) { + // printf("North\n"); + _y_spaceship-=2; + } else if(d==S) { + // printf("North\n"); + _y_spaceship+=2; + + } + + if(_y_spaceship>=30) { + _y_spaceship=30; + } else if(_y_spaceship<=0) { + _y_spaceship=0; + } + } int Spaceship::get_pos_x()