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
RosenEngine/RosenEngine.cpp@11:73cd744ffa80, 2019-04-09 (annotated)
- Committer:
- ikenna1
- Date:
- Tue Apr 09 11:21:18 2019 +0000
- Revision:
- 11:73cd744ffa80
- Parent:
- 10:c33d7593a275
- Child:
- 12:47578eb9ea73
Starting to add new ship imperion
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ikenna1 | 3:f9cd1a38d5c6 | 1 | #include "RosenEngine.h" |
ikenna1 | 3:f9cd1a38d5c6 | 2 | |
ikenna1 | 8:87a845b8575e | 3 | |
ikenna1 | 2:66a4e5d7a7cd | 4 | // Constructor |
ikenna1 | 2:66a4e5d7a7cd | 5 | RosenEngine::RosenEngine() |
ikenna1 | 2:66a4e5d7a7cd | 6 | { |
ikenna1 | 2:66a4e5d7a7cd | 7 | |
ikenna1 | 2:66a4e5d7a7cd | 8 | } |
ikenna1 | 2:66a4e5d7a7cd | 9 | // Destructor |
ikenna1 | 2:66a4e5d7a7cd | 10 | RosenEngine::~RosenEngine() |
ikenna1 | 2:66a4e5d7a7cd | 11 | { |
ikenna1 | 2:66a4e5d7a7cd | 12 | |
ikenna1 | 2:66a4e5d7a7cd | 13 | } |
ikenna1 | 3:f9cd1a38d5c6 | 14 | |
ikenna1 | 4:740e14ebbc97 | 15 | |
ikenna1 | 9:241a1a7d8527 | 16 | void RosenEngine::init(int ship_width,int ship_height,int ship_speed,int ship_xpos,int ship_ypos) |
ikenna1 | 2:66a4e5d7a7cd | 17 | { |
ikenna1 | 4:740e14ebbc97 | 18 | // initialise the game parameters |
ikenna1 | 9:241a1a7d8527 | 19 | _ship.init(ship_width,ship_height,ship_speed,ship_xpos,ship_ypos); |
ikenna1 | 9:241a1a7d8527 | 20 | _menu.init(16); |
ikenna1 | 9:241a1a7d8527 | 21 | |
ikenna1 | 4:740e14ebbc97 | 22 | |
ikenna1 | 3:f9cd1a38d5c6 | 23 | } |
ikenna1 | 4:740e14ebbc97 | 24 | |
ikenna1 | 5:bb6edc5b5be3 | 25 | void RosenEngine::read_input(Gamepad &pad) |
ikenna1 | 4:740e14ebbc97 | 26 | { |
ikenna1 | 4:740e14ebbc97 | 27 | Vector2D mapped_coord = pad.get_coord(); |
ikenna1 | 8:87a845b8575e | 28 | _xjoystick = mapped_coord.x; |
ikenna1 | 8:87a845b8575e | 29 | _yjoystick = mapped_coord.y; |
ikenna1 | 9:241a1a7d8527 | 30 | _d = pad.get_direction(); |
ikenna1 | 9:241a1a7d8527 | 31 | // printf("_xjoystick ,_yjoystick = %f , %f\n",_xjoystick, _yjoystick); |
ikenna1 | 4:740e14ebbc97 | 32 | } |
ikenna1 | 4:740e14ebbc97 | 33 | |
ikenna1 | 7:ed5870cfb3e0 | 34 | void RosenEngine::draw(N5110 &lcd) |
ikenna1 | 7:ed5870cfb3e0 | 35 | { |
ikenna1 | 8:87a845b8575e | 36 | _ship.draw_ship(lcd); |
ikenna1 | 9:241a1a7d8527 | 37 | _weapons.draw(lcd); |
ikenna1 | 7:ed5870cfb3e0 | 38 | } |
ikenna1 | 11:73cd744ffa80 | 39 | void RosenEngine::draw_Imperion(N5110 &lcd) |
ikenna1 | 11:73cd744ffa80 | 40 | { |
ikenna1 | 11:73cd744ffa80 | 41 | _ship.draw_imperion(lcd); |
ikenna1 | 11:73cd744ffa80 | 42 | } |
ikenna1 | 7:ed5870cfb3e0 | 43 | |
ikenna1 | 7:ed5870cfb3e0 | 44 | void RosenEngine::update(Gamepad &pad) |
ikenna1 | 7:ed5870cfb3e0 | 45 | { |
ikenna1 | 8:87a845b8575e | 46 | _ship.update_ship(_xjoystick,_yjoystick); |
ikenna1 | 9:241a1a7d8527 | 47 | _weapons.update(); |
ikenna1 | 10:c33d7593a275 | 48 | // _menu.update(_d); |
ikenna1 | 7:ed5870cfb3e0 | 49 | } |
ikenna1 | 9:241a1a7d8527 | 50 | void RosenEngine::get_pos() |
ikenna1 | 9:241a1a7d8527 | 51 | { |
ikenna1 | 9:241a1a7d8527 | 52 | |
ikenna1 | 9:241a1a7d8527 | 53 | Vector2D ship_pos = _ship.get_pos(); |
ikenna1 | 9:241a1a7d8527 | 54 | ship_xpos = ship_pos.x; |
ikenna1 | 9:241a1a7d8527 | 55 | ship_ypos = ship_pos.y; |
ikenna1 | 9:241a1a7d8527 | 56 | ship_width = 9; |
ikenna1 | 9:241a1a7d8527 | 57 | _weapons.init(ship_xpos, ship_ypos, ship_width); |
ikenna1 | 10:c33d7593a275 | 58 | _ycursor = _menu.get_cursor(); |
ikenna1 | 9:241a1a7d8527 | 59 | } |
ikenna1 | 9:241a1a7d8527 | 60 | void RosenEngine::title(N5110 &lcd) |
ikenna1 | 9:241a1a7d8527 | 61 | { |
ikenna1 | 10:c33d7593a275 | 62 | _menu.title(lcd); |
ikenna1 | 10:c33d7593a275 | 63 | _menu.update(_d); |
ikenna1 | 10:c33d7593a275 | 64 | } |
ikenna1 | 10:c33d7593a275 | 65 | int RosenEngine::get_cursor() |
ikenna1 | 10:c33d7593a275 | 66 | { |
ikenna1 | 10:c33d7593a275 | 67 | _ycursor = _menu.get_cursor(); |
ikenna1 | 10:c33d7593a275 | 68 | return _ycursor; |
ikenna1 | 9:241a1a7d8527 | 69 | } |