Game codes for Pokemon Academy Yiu Fai Kwok - 201198802 I have read the University Regulations on Plagiarism and state that the work covered by this declaration is my own and does not contain any unacknowledged work from other sources.
Dependencies: mbed FXOS8700CQ mbed-rtos
Start/Start.cpp
- Committer:
- yfkwok
- Date:
- 2019-04-03
- Revision:
- 2:464c7e62d97d
- Child:
- 5:bc0691d02fd5
File content as of revision 2:464c7e62d97d:
#include "Start.h" Start::Start() { } Start::~Start() { } void Start::init() { _pos_x = 2; _pos_y = 8; _pos_cy = 5; _pos_sy = 9; _pos_by = 13; _alt = 0; } void Start::starter_draw(N5110 &lcd) { lcd.clear(); _c1.draw_cha1_sprite(60, _pos_cy, lcd); _s1.draw_cha1_sprite(32, _pos_sy, lcd); _b1.draw_cha1_sprite(4, _pos_by, lcd); lcd.drawRect(_pos_x, _pos_y, 25, 25, FILL_TRANSPARENT); static int instruct_data[] = { 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,1,1,0,0,0,0,0,0, 1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,1,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0, 1,0,0,1,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1,0,0,0,0,1,0,0,1,0,0,0,0,1,1,1,0,1,1,1,1,0,1,1,1,1,0,0,0,0,1,0,1,1,1,1,0,1,1,1,0,1,1,1,1,0, 1,1,1,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,0,0,1,0,0,0,0,0,0,0,1,1,1,1,0,0,0,0,0,1,0,0,1,0,0,1,0,1,0,0,1,0,0,0,0,1,0,1,0,0,1,0,0,1,0,0,1,0,0,1,0, 1,0,0,0,0,1,0,0,0,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,1,0,0,1,0,0,0,0,1,0,0,0,0,1,0,0,1,0,1,0,1,0,0,1,0,1,0,0,1,0,1,0,0,0, 0,0,0,1,0,0,0,1,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0,1,0,0,1,0,0,0,0,1,1,1,1,0,1,1,1,1,0,1,0,1,1,1,1,0,1,0,0,0,0,1,0,0,0, 0,0,0,1,0,0,0,1,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,0,0,0,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0,0,0,0,0,1,0,1,0,0,0,0,1,0,1,0,0,0,0,1,0,0,1,0,1,0,0,1, 1,1,1,1,0,0,0,1,0,0,0,1,0,0,1,0,1,0,0,1,0,0,0,1,0,0,0,0,0,0,1,1,1,1,0,1,1,1,1,0,0,0,0,1,1,1,1,0,1,1,1,1,0,1,0,1,1,1,1,0,1,1,1,1,0,1,1,1,1 }; lcd.drawSprite(5, 33, 15, 69, instruct_data); lcd.refresh(); } void Start::starter_update(Gamepad &pad) { update_select(pad); update_animation_b(pad); update_animation_c(pad); update_animation_s(pad); update_alt(); } Vector2D Start::update_select(Gamepad &pad) { if(pad.get_direction() == E && _pos_x < 58){_pos_x = _pos_x + 28; _pos_y = _pos_y - 4;} else if(pad.get_direction() == W && _pos_x > 2){_pos_x = _pos_x - 28;_pos_y = _pos_y + 4;} Vector2D p = {_pos_x, _pos_y}; return p; } int Start::update_animation_b(Gamepad &pad) { if(_alt == 0 && _pos_x == 2){_pos_by = 13;} else if(_alt == 1 && _pos_x == 2){_pos_by = 11;} int pos_by = _pos_by; return pos_by; } int Start::update_animation_c(Gamepad &pad) { if(_alt == 0 && _pos_x == 58){_pos_cy = 3;} else if(_alt == 1 && _pos_x == 58){_pos_cy = 5;} int pos_cy = _pos_cy; return pos_cy; } int Start::update_animation_s(Gamepad &pad) { if(_alt == 0 && _pos_x == 30){_pos_sy = 7;} else if(_alt == 1 && _pos_x == 30){_pos_sy = 9;} int pos_sy = _pos_sy; return pos_sy; } int Start::update_alt() { if(_alt == 0){_alt = 1;} else {_alt = 0;} int alt = _alt; return alt; } void Start::set_pos(Vector2D p) { _pos_x = p.x; _pos_y = p.y; } void Start::set_pos_csb(int pos_cy, int pos_sy, int pos_by) { _pos_cy = pos_cy; _pos_sy = pos_sy; _pos_by = pos_by; } void Start::set_alt(int alt) { _alt = alt; } int Start::get_select(Vector2D p) { int select = 0; int x = p.x; if(x == 2) {select = 0;} else if(x == 30) {select = 1;} else if(x == 58) {select = 2;} return select; } void Start::intro(int select,Gamepad &pad, N5110 &lcd) { if(select == 2){_c1.description(pad, lcd);} else if(select == 1){_s1.description(pad, lcd);} else if(select == 0){_b1.description(pad, lcd);} }