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:
- 106:73d5d818ae7d
- Parent:
- 105:b206078335a3
- Child:
- 107:83b0bc100600
--- a/Spaceship/Spaceship.cpp Sun May 05 13:17:31 2019 +0000 +++ b/Spaceship/Spaceship.cpp Sun May 05 13:20:44 2019 +0000 @@ -1,63 +1,20 @@ #include "Spaceship.h" -Space_ship::Space_ship() +Spaceship::Spaceship() { - } - -Space_ship::~Space_ship() +Spaceship::~Spaceship() { - } - -const int Space_ship[10][12]= { - {0,0,0,0,0,0,0,0,0,0,0,0}, - {0,0,0,1,1,0,0,0,0,0,0,0}, - {0,0,0,1,1,0,0,0,0,0,0,0}, - {0,1,1,1,1,1,1,1,0,0,0,0}, - {0,1,1,1,1,1,1,1,1,0,0,0}, - {0,1,1,1,1,1,1,1,1,1,1,0}, - {0,1,1,1,1,1,1,1,1,0,0,0}, - {0,1,1,1,1,1,1,1,0,0,0,0}, - {0,0,0,1,1,0,0,0,0,0,0,0}, - {0,0,0,1,1,0,0,0,0,0,0,0}, - -}; - -void Space_ship::init(int x,int height,int width) +void Spaceship::init(int x_spaceship,int y_spaceship, int speed_spaceship) { - _x = x; // x value on screen is fixed - _y = HEIGHT/2 - height/2; // y depends on height of screen and height of Space_ship - _height = height; - _width = width; - _speed = 1; // default speed - _score = 0; // start score from zero + + _x_spaceship= x_spaceship; + _y_spaceship= y_spaceship; + _speed_spaceship= speed_spaceship; +} - -} - -void Space_ship::draw(N5110 &lcd) -{ - // draw Space_ship in screen buffer. - lcd.drawSprite(x_Space_ship,y_Space_ship,10,12,(int *) Space_ship); -} - -void Space_ship::add_score() -{ - _score++; -} - -int Space_ship::get_score() -{ - return _score; -} - -Vector2D Space_ship::get_pos() -{ - Vector2D p = {_x,_y}; - return p; -} \ No newline at end of file