Laila Al Badwawi 200906179 SpaceInvaders I declare this my own independent work and understand the university rules on plagiarism.
Dependencies: mbed
Spaceship/Spaceship.cpp
- Committer:
- fy14lkaa
- Date:
- 2019-05-09
- Revision:
- 140:e389918735a7
- Parent:
- 139:c46a2cef7e09
- Child:
- 141:02858e82c9cc
File content as of revision 140:e389918735a7:
#include "Spaceship.h" Spaceship::Spaceship() //constructor of class Spaceship { } Spaceship::~Spaceship() //Destructor of class Spaceship { } void Spaceship::init(int x_spaceship,int y_spaceship, int speed_spaceship) { //intialise the prameters of class Spaceship _x_spaceship= x_spaceship; // the position of spaceship at x-cooridante. _y_spaceship= y_spaceship; // the position of spaceship at y-cooridante. _speed_spaceship= speed_spaceship; // the speed of the alien. } // void function to draw the spaceship by using N5110 library void Spaceship::draw(N5110 &lcd) { . //drawing the spaceship by using lcd.drawSprite. 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) { //if statment to check if the joystic's direction moves to the north _y_spaceship-=2; // the position of the spaceship at y-coordiante decrement by two // printf("North\n"); } else if(d==S) { _y_spaceship+=2; // printf("North\n"); } if(_y_spaceship>=30) { _y_spaceship=30; } else if(_y_spaceship<=0) { _y_spaceship=0; } } int Spaceship::get_pos_x() { return _x_spaceship; } int Spaceship::get_pos_y() { return _y_spaceship; } void Spaceship::set_pos(int x, int y) { _x_spaceship = x; _y_spaceship = y; } void Spaceship::add_score() { _score++; } int Spaceship::get_score() { return _score; }