Joseph Boettcher / ECE4180_Lab4_Sharpshooter

Dependencies:   4DGL-uLCD-SE SDFileSystem mbed-rtos mbed wave_player

Files at this revision

API Documentation at this revision

Comitter:
jboettcher
Date:
Fri Oct 28 20:07:38 2016 +0000
Parent:
10:92538c02e6c8
Child:
12:2f358065ba3f
Commit message:
First compile;

Changed in this revision

Bullet.h Show annotated file Show diff for this revision Revisions of this file
MainGame.cpp Show annotated file Show diff for this revision Revisions of this file
Obstacle.h Show annotated file Show diff for this revision Revisions of this file
Shooter.h Show annotated file Show diff for this revision Revisions of this file
--- a/Bullet.h	Fri Oct 28 19:02:28 2016 +0000
+++ b/Bullet.h	Fri Oct 28 20:07:38 2016 +0000
@@ -1,22 +1,30 @@
+extern uLCD_4DGL uLCD;
+
+struct BulletLocation {
+    int x, topY, bottomY;   
+};
+
 class Bullet {
     
         int x, topY, bottomY;
-        int length = 3;
-        int speed = 3;
-        uLCD_4DGL uLCD;
-        struct Coordinate {
-            int x1, y1, x2, y2;
-        }
+        int length;
+        int speed;
+        
         
     public:   
-        Bullet(uLCD_4DGL uLCD);
+        Bullet();
         void drawBullet(int x, int bottomY);
         void eraseBullet();
-        void move();            
+        void move();   
+        BulletLocation getLocation();         
 };
 
-Bullet::Bullet(uLCD_4DGL uLCD) {
-    this->uLCD = uLCD;
+Bullet::Bullet() {
+    length = 3;
+    speed = 3;
+    x=1;
+    topY=2;
+    bottomY=3;
 }
 
 /*Bullet::Bullet(int x, int bottomY, uLCD_4DGL uLCD) {
@@ -42,7 +50,7 @@
     uLCD.line(x,topY,x,bottomY, 0x000000);
 }
 
-Coordinate Bullet::getLocation() {
-    Coordinate coor = {x, topY, x, bottomY;}
+BulletLocation Bullet::getLocation() {
+    BulletLocation coor {x, topY, bottomY};
     return coor;
 }
--- a/MainGame.cpp	Fri Oct 28 19:02:28 2016 +0000
+++ b/MainGame.cpp	Fri Oct 28 20:07:38 2016 +0000
@@ -5,6 +5,9 @@
 #include "wave_player.h"
 #include "Nav_Switch.h"
 #include "rtos.h"
+#include "Obstacle.h"
+#include "Shooter.h"
+#include "Bullet.h"
 
 DigitalOut myled1(LED1);
 DigitalOut myled2(LED2);
@@ -23,16 +26,16 @@
 /*STRUCT INITIALIZATION*/
 struct ObstLocation {
     int x1, y1, x2, y2;
-}
+};
 
 struct TargetLocation {
     int x,y,r;
-}
-
+};
+/*
 struct BulletLocation {
     int x, topY, bottomY;   
-}
-
+};
+*/
 /*LOCAL VARIABLES*/
 int numTries;
 int levelNum;
@@ -59,10 +62,9 @@
     numTries = 10;
     //draw header (level #, numTries) at the top
     
-    
-    createTargets();
-    createObstacles(level);
-    createShooter();
+    //createTargets();
+    //createObstacles(level);
+    //createShooter();
 }
 
 void createTargets() {
@@ -73,7 +75,7 @@
 void createShooter() {
     
 }
-
+/*
 void createObstacles(int num) {
     Obstacle obsArr[num];
     obstaclePtr = new ObstLocation[num];
@@ -92,7 +94,7 @@
         obstaclePtr[i] = obsArr[i].getLocation();
     }
 }
-
+*/
 void shoot() {
     
 }
@@ -118,6 +120,9 @@
         initializeLevel(currLevel);
         bool play = true;
         
+        wait(100);
+        
+        /*
         while (play) { //actual game play code
             //handle controls (5 tactile swtich)
             if(myNav.fire()) shoot();
@@ -128,7 +133,7 @@
             
         }
         
-        
+        */
         
         
         
--- a/Obstacle.h	Fri Oct 28 19:02:28 2016 +0000
+++ b/Obstacle.h	Fri Oct 28 20:07:38 2016 +0000
@@ -1,23 +1,24 @@
+extern uLCD_4DGL uLCD;
+
+
 class Obstacle
 {
     int x1,x2,y1,y2;
-    uLCD_4DGL uLCD;
     bool direction;
 
 public:
-    Obstacle(int x1, int x2, int y1, int y2, uLCD_4DGL uLCD);
+    Obstacle(int x1, int x2, int y1, int y2);
     void drawObstacle();
     void move(int speed);
     void changeDirection();// need change direction when hitting wall
     void setDirection(bool direction);
 };
 
-Obstacle::Obstacle(int a, int b, int c, int d, uLCD_4DGL e) {
+Obstacle::Obstacle(int a, int b, int c, int d) {
     x1 = a;
     x2 = b;
     y1 = c;
     y2 = d;
-    this->uLCD = e;
 }
 
 void Obstacle::drawObstacle() {
@@ -36,7 +37,7 @@
 }
 
 void Obstacle::changeDirection() {
-    direction = !direction
+    direction = !direction;
 }
 
 void Obstacle::setDirection(bool a) {
--- a/Shooter.h	Fri Oct 28 19:02:28 2016 +0000
+++ b/Shooter.h	Fri Oct 28 20:07:38 2016 +0000
@@ -1,7 +1,8 @@
+extern uLCD_4DGL uLCD;
+
 class Shooter
 {
     int x;
-    uLCD_4DGL uLCD;
 
 public:
     Shooter();