Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: Ship/Ship.cpp
- Revision:
- 51:2231e2e141b9
- Parent:
- 45:fe5fc85a5c73
--- a/Ship/Ship.cpp Thu May 09 06:02:20 2019 +0000 +++ b/Ship/Ship.cpp Thu May 09 08:42:25 2019 +0000 @@ -8,7 +8,7 @@ { } -// data needed for first ship: kestrel +// Sprites for the ships const int kestrelSprite[6][9] = { { 0,0,0,0,1,0,0,0,0 }, { 0,0,0,1,1,1,0,0,0 }, @@ -42,25 +42,22 @@ {1,0,0,0,0,0,1}, }; -/* -int kestrel_width = 9; -int kestrel_height = 6; -int kestrel_speed = 5; -*/ + -// Set kestrel ship to be default + void Ship::init(int ship_width,int ship_height,int ship_speed,int ship_xpos,int ship_ypos) { + // initialize the ships parameters _ship_width = ship_width; _ship_height = ship_height; _ship_speed = ship_speed; _ship_xpos = ship_xpos; _ship_xpos = ship_ypos; -// _ship_shape[_ship_height][_ship_width] = ship_shape; } -// Draw the ship ***Note: figure out how to change ship type e.g from kestrel to devotion + void Ship::draw_ship(N5110 &lcd, SHIP shipUsed) { + // Switch ship sprite based on what ship is being used switch (shipUsed) { case kestrel: lcd.drawSprite(_ship_xpos,_ship_ypos,6,9,(int *)kestrelSprite); @@ -109,12 +106,8 @@ void Ship::set_parameters(int ship_width, int ship_height, int ship_speed) { + // set ship height, width and speed _ship_width = ship_width; _ship_height = ship_height; _ship_speed = ship_speed; } - -/****Note: if you make all the ships the same size, you could then creare a enum for them ship.[ enum class Ship {kestrel, devotion}; ] -then, you can declare a new variable belonging to the enum Ship, ship. then to set a ships sprite simply use the variable to test if -the ship is correct and create an if function to draw the appropriate ship -*/ \ No newline at end of file