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: RosenEngine/RosenEngine.cpp
- Revision:
- 24:ab821bfeb383
- Parent:
- 23:0301effce801
- Child:
- 25:faba9eb44514
diff -r 0301effce801 -r ab821bfeb383 RosenEngine/RosenEngine.cpp --- a/RosenEngine/RosenEngine.cpp Sun Apr 14 11:34:14 2019 +0000 +++ b/RosenEngine/RosenEngine.cpp Sun Apr 14 18:11:32 2019 +0000 @@ -64,6 +64,7 @@ // _menu.update(_d); check_enemy_ship_collision(); + check_enemy_projectile_collision(); // printf("collision check complete"); } void RosenEngine::get_pos() @@ -143,9 +144,45 @@ } void RosenEngine::check_enemy_projectile_collision() { + Vector2D ship_pos = _ship.get_pos(); + int lazer_x[3]; + int seeker_x[9]; + int seeker_y[38]; + bool xcol = false; + + // get seekers x any y values and put into arrays Vector2D seeker_pos = _enemy.get_seekerpos(); + for(int countx = 0; countx<=9; countx=countx+1) { + seeker_x[countx] = seeker_pos.x + countx; + } + for(int county = 0; county<=6; county=county+1) { + seeker_y[county] = seeker_pos.y + county; + } + // kestrel canon + if(_shipno == 0) { + + } - if(_shipno == 0){ - + // imperion lazer + if(_shipno == 1) { + for(int countx = 0; countx<=3; countx=countx+1) { + lazer_x[countx] = (ship_pos.x + 2) + countx; + } + // ony register collision if seeker is above ship + if(seeker_pos.y + 6 < ship_pos.y) { + // check all values of ship position against all values of seekers x position + for(int nx = 0; nx<=3; nx=nx+1) { + for(int mx = 0; mx<=9; mx=mx+1) { + if(lazer_x[nx] == seeker_x[mx]) { + xcol = true; + } + } + } + } + if(xcol == true && A == true) { + _enemy.reset_seeker(); + } + } + } \ No newline at end of file