![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
201199550 Li Boyuan PlaneWar Game on K64f
Dependencies: mbed Gamepad N5110
engine.cpp
- Committer:
- LBY
- Date:
- 2020-05-14
- Revision:
- 0:36c99c50e688
File content as of revision 0:36c99c50e688:
#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; }