Meteor defense project

Dependencies:   N5110 mbed

Committer:
jasper0712
Date:
Mon Mar 20 22:06:50 2017 +0000
Revision:
1:f5cda0674f24
Parent:
0:5fbc0fbc9d30
Child:
2:2c60c92bf65b
Array fail. Might be the problem with movingspawn

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jasper0712 0:5fbc0fbc9d30 1 #include "mbed.h"
jasper0712 0:5fbc0fbc9d30 2 #include "N5110.h"
jasper0712 0:5fbc0fbc9d30 3 #include "Gamepad.h"
jasper0712 0:5fbc0fbc9d30 4 #include "Weapon.h"
jasper0712 0:5fbc0fbc9d30 5 #include "Spawn.h"
jasper0712 0:5fbc0fbc9d30 6
jasper0712 0:5fbc0fbc9d30 7 #define PI 3.14159265
jasper0712 0:5fbc0fbc9d30 8 //Y rows and X columns
jasper0712 1:f5cda0674f24 9 #define Rows 48
jasper0712 1:f5cda0674f24 10 #define Cols 84
jasper0712 0:5fbc0fbc9d30 11
jasper0712 0:5fbc0fbc9d30 12 N5110 lcd(PTC9,PTC0,PTC7,PTD2,PTD1,PTC11);
jasper0712 0:5fbc0fbc9d30 13 Gamepad pad;
jasper0712 0:5fbc0fbc9d30 14 Weapon weap;
jasper0712 0:5fbc0fbc9d30 15 Spawn spa;
jasper0712 0:5fbc0fbc9d30 16
jasper0712 0:5fbc0fbc9d30 17 int gamefps = 1;
jasper0712 0:5fbc0fbc9d30 18 void init();
jasper0712 0:5fbc0fbc9d30 19 void render();
jasper0712 0:5fbc0fbc9d30 20
jasper0712 0:5fbc0fbc9d30 21 int main()
jasper0712 0:5fbc0fbc9d30 22 {
jasper0712 0:5fbc0fbc9d30 23
jasper0712 0:5fbc0fbc9d30 24 init();
jasper0712 0:5fbc0fbc9d30 25 while (true) {
jasper0712 1:f5cda0674f24 26 spa.randomizeSpawn();
jasper0712 1:f5cda0674f24 27 spa.moveSpawn(spa.spawnArray);
jasper0712 1:f5cda0674f24 28 spa.updateSpawn(spa.spawnArray, lcd);
jasper0712 0:5fbc0fbc9d30 29
jasper0712 0:5fbc0fbc9d30 30 weap.drawWeapon(pad, lcd);
jasper0712 0:5fbc0fbc9d30 31
jasper0712 0:5fbc0fbc9d30 32 if (pad.buttonhold == 1) {
jasper0712 0:5fbc0fbc9d30 33 printf("hi im working \n");
jasper0712 0:5fbc0fbc9d30 34 weap.fireWeapon(pad, lcd);
jasper0712 0:5fbc0fbc9d30 35 }
jasper0712 0:5fbc0fbc9d30 36
jasper0712 0:5fbc0fbc9d30 37 render();
jasper0712 0:5fbc0fbc9d30 38 }
jasper0712 0:5fbc0fbc9d30 39 }
jasper0712 0:5fbc0fbc9d30 40
jasper0712 0:5fbc0fbc9d30 41 void init()
jasper0712 0:5fbc0fbc9d30 42 {
jasper0712 0:5fbc0fbc9d30 43 // need to initialise LCD and Gamepad
jasper0712 0:5fbc0fbc9d30 44 lcd.init();
jasper0712 0:5fbc0fbc9d30 45 pad.init();
jasper0712 0:5fbc0fbc9d30 46
jasper0712 0:5fbc0fbc9d30 47 // initialise the game
jasper0712 0:5fbc0fbc9d30 48 }
jasper0712 0:5fbc0fbc9d30 49
jasper0712 0:5fbc0fbc9d30 50 void render()
jasper0712 0:5fbc0fbc9d30 51 {
jasper0712 0:5fbc0fbc9d30 52 // clear screen, re-draw and refresh
jasper0712 0:5fbc0fbc9d30 53 lcd.refresh();
jasper0712 0:5fbc0fbc9d30 54 wait(1.0/gamefps);
jasper0712 0:5fbc0fbc9d30 55 lcd.clear();
jasper0712 0:5fbc0fbc9d30 56 }