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@13:e114d362186d, 2019-04-10 (annotated)
- Committer:
- ikenna1
- Date:
- Wed Apr 10 12:04:07 2019 +0000
- Revision:
- 13:e114d362186d
- Parent:
- 12:47578eb9ea73
- Child:
- 14:88ca5b1a111a
Can now switch ships and border if fixed;
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 | 13:e114d362186d | 21 | |
ikenna1 | 3:f9cd1a38d5c6 | 22 | } |
ikenna1 | 4:740e14ebbc97 | 23 | |
ikenna1 | 5:bb6edc5b5be3 | 24 | void RosenEngine::read_input(Gamepad &pad) |
ikenna1 | 4:740e14ebbc97 | 25 | { |
ikenna1 | 4:740e14ebbc97 | 26 | Vector2D mapped_coord = pad.get_coord(); |
ikenna1 | 8:87a845b8575e | 27 | _xjoystick = mapped_coord.x; |
ikenna1 | 8:87a845b8575e | 28 | _yjoystick = mapped_coord.y; |
ikenna1 | 9:241a1a7d8527 | 29 | _d = pad.get_direction(); |
ikenna1 | 9:241a1a7d8527 | 30 | // printf("_xjoystick ,_yjoystick = %f , %f\n",_xjoystick, _yjoystick); |
ikenna1 | 4:740e14ebbc97 | 31 | } |
ikenna1 | 4:740e14ebbc97 | 32 | |
ikenna1 | 7:ed5870cfb3e0 | 33 | void RosenEngine::draw(N5110 &lcd) |
ikenna1 | 7:ed5870cfb3e0 | 34 | { |
ikenna1 | 13:e114d362186d | 35 | if(_xcursor == 0){ |
ikenna1 | 13:e114d362186d | 36 | _ship.set_ship(9,6); |
ikenna1 | 13:e114d362186d | 37 | _ship.draw_ship(lcd); |
ikenna1 | 13:e114d362186d | 38 | _weapons.draw(lcd); |
ikenna1 | 13:e114d362186d | 39 | } |
ikenna1 | 13:e114d362186d | 40 | if(_xcursor == 1){ |
ikenna1 | 13:e114d362186d | 41 | _ship.set_ship(7,10); |
ikenna1 | 13:e114d362186d | 42 | _ship.draw_imperion(lcd); |
ikenna1 | 13:e114d362186d | 43 | _weapons.draw(lcd); |
ikenna1 | 13:e114d362186d | 44 | } |
ikenna1 | 11:73cd744ffa80 | 45 | } |
ikenna1 | 7:ed5870cfb3e0 | 46 | |
ikenna1 | 7:ed5870cfb3e0 | 47 | void RosenEngine::update(Gamepad &pad) |
ikenna1 | 7:ed5870cfb3e0 | 48 | { |
ikenna1 | 8:87a845b8575e | 49 | _ship.update_ship(_xjoystick,_yjoystick); |
ikenna1 | 9:241a1a7d8527 | 50 | _weapons.update(); |
ikenna1 | 10:c33d7593a275 | 51 | // _menu.update(_d); |
ikenna1 | 7:ed5870cfb3e0 | 52 | } |
ikenna1 | 9:241a1a7d8527 | 53 | void RosenEngine::get_pos() |
ikenna1 | 9:241a1a7d8527 | 54 | { |
ikenna1 | 9:241a1a7d8527 | 55 | |
ikenna1 | 9:241a1a7d8527 | 56 | Vector2D ship_pos = _ship.get_pos(); |
ikenna1 | 9:241a1a7d8527 | 57 | ship_xpos = ship_pos.x; |
ikenna1 | 9:241a1a7d8527 | 58 | ship_ypos = ship_pos.y; |
ikenna1 | 9:241a1a7d8527 | 59 | ship_width = 9; |
ikenna1 | 9:241a1a7d8527 | 60 | _weapons.init(ship_xpos, ship_ypos, ship_width); |
ikenna1 | 13:e114d362186d | 61 | _ycursor = _menu.get_ycursor(); |
ikenna1 | 9:241a1a7d8527 | 62 | } |
ikenna1 | 9:241a1a7d8527 | 63 | void RosenEngine::title(N5110 &lcd) |
ikenna1 | 9:241a1a7d8527 | 64 | { |
ikenna1 | 10:c33d7593a275 | 65 | _menu.title(lcd); |
ikenna1 | 10:c33d7593a275 | 66 | _menu.update(_d); |
ikenna1 | 10:c33d7593a275 | 67 | } |
ikenna1 | 13:e114d362186d | 68 | int RosenEngine::get_ycursor() |
ikenna1 | 10:c33d7593a275 | 69 | { |
ikenna1 | 13:e114d362186d | 70 | _ycursor = _menu.get_ycursor(); |
ikenna1 | 10:c33d7593a275 | 71 | return _ycursor; |
ikenna1 | 12:47578eb9ea73 | 72 | } |
ikenna1 | 13:e114d362186d | 73 | int RosenEngine::get_xcursor() |
ikenna1 | 13:e114d362186d | 74 | { |
ikenna1 | 13:e114d362186d | 75 | _xcursor = _menu.get_xcursor(); |
ikenna1 | 13:e114d362186d | 76 | return _xcursor; |
ikenna1 | 13:e114d362186d | 77 | } |
ikenna1 | 12:47578eb9ea73 | 78 | void RosenEngine::ship_select(N5110 &lcd) |
ikenna1 | 12:47578eb9ea73 | 79 | { |
ikenna1 | 12:47578eb9ea73 | 80 | _menu.update(_d); |
ikenna1 | 12:47578eb9ea73 | 81 | _menu.disp_ships(lcd); |
ikenna1 | 9:241a1a7d8527 | 82 | } |