![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
201199550 Li Boyuan PlaneWar Game on K64f
Dependencies: mbed Gamepad N5110
Diff: engine.cpp
- Revision:
- 0:36c99c50e688
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/engine.cpp Thu May 14 10:14:48 2020 +0000 @@ -0,0 +1,37 @@ +#include "engine.h" + + +void engine::init(){ +} + +void engine::fire(int x,int y, bullet &b){ + b.x = x; + b.y = y; +} +events engine::evet_check(plane &p, bomb &b, Gamepad &pad, bullet &bu){ + xy pxy = p.getxy(); + int width = p.getwidth(); + int height = p.getheight(); + if(b.x>-1){ + if(((pxy.x - b.width < b.x)&&(pxy.x+width>b.x)) &&((pxy.y-b.height<b.y)&&(pxy.y+height>b.y))){ + return DEAD; + } + } + if(pad.check_event(Gamepad::B_PRESSED) == true){ + return FIRE; + } + if(bu.x>-1&&b.x>-1){ + if(((bu.x - b.width < b.x)&&(bu.x+2>b.x)) &&((bu.y-b.height<b.y)&&(bu.y+2>b.y))){ + return ELMININATE; + } + } + return NONE; + } + + +int engine::randombomb(){ + int a = 5; + int b = 35; + int y = (rand() % (b-a+1))+ a; + return y; +} \ No newline at end of file