201199550 Li Boyuan PlaneWar Game on K64f

Dependencies:   mbed Gamepad N5110

Committer:
LBY
Date:
Thu May 14 10:14:48 2020 +0000
Revision:
0:36c99c50e688
From:201199550 Li Boyuan; Game name: PlaneWar

Who changed what in which revision?

UserRevisionLine numberNew contents of line
LBY 0:36c99c50e688 1 #include "engine.h"
LBY 0:36c99c50e688 2
LBY 0:36c99c50e688 3
LBY 0:36c99c50e688 4 void engine::init(){
LBY 0:36c99c50e688 5 }
LBY 0:36c99c50e688 6
LBY 0:36c99c50e688 7 void engine::fire(int x,int y, bullet &b){
LBY 0:36c99c50e688 8 b.x = x;
LBY 0:36c99c50e688 9 b.y = y;
LBY 0:36c99c50e688 10 }
LBY 0:36c99c50e688 11 events engine::evet_check(plane &p, bomb &b, Gamepad &pad, bullet &bu){
LBY 0:36c99c50e688 12 xy pxy = p.getxy();
LBY 0:36c99c50e688 13 int width = p.getwidth();
LBY 0:36c99c50e688 14 int height = p.getheight();
LBY 0:36c99c50e688 15 if(b.x>-1){
LBY 0:36c99c50e688 16 if(((pxy.x - b.width < b.x)&&(pxy.x+width>b.x)) &&((pxy.y-b.height<b.y)&&(pxy.y+height>b.y))){
LBY 0:36c99c50e688 17 return DEAD;
LBY 0:36c99c50e688 18 }
LBY 0:36c99c50e688 19 }
LBY 0:36c99c50e688 20 if(pad.check_event(Gamepad::B_PRESSED) == true){
LBY 0:36c99c50e688 21 return FIRE;
LBY 0:36c99c50e688 22 }
LBY 0:36c99c50e688 23 if(bu.x>-1&&b.x>-1){
LBY 0:36c99c50e688 24 if(((bu.x - b.width < b.x)&&(bu.x+2>b.x)) &&((bu.y-b.height<b.y)&&(bu.y+2>b.y))){
LBY 0:36c99c50e688 25 return ELMININATE;
LBY 0:36c99c50e688 26 }
LBY 0:36c99c50e688 27 }
LBY 0:36c99c50e688 28 return NONE;
LBY 0:36c99c50e688 29 }
LBY 0:36c99c50e688 30
LBY 0:36c99c50e688 31
LBY 0:36c99c50e688 32 int engine::randombomb(){
LBY 0:36c99c50e688 33 int a = 5;
LBY 0:36c99c50e688 34 int b = 35;
LBY 0:36c99c50e688 35 int y = (rand() % (b-a+1))+ a;
LBY 0:36c99c50e688 36 return y;
LBY 0:36c99c50e688 37 }