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:
SeanBuckingham
Date:
Fri Oct 28 01:06:01 2016 +0000
Parent:
6:7f8c3169483a
Parent:
8:56a24df93680
Child:
10:92538c02e6c8
Commit message:
recent commit w most updated version;

Changed in this revision

Obstacle.h Show annotated file Show diff for this revision Revisions of this file
Obstacle.h.orig Show diff for this revision Revisions of this file
main.cpp Show diff for this revision Revisions of this file
--- a/Bullet.h	Fri Oct 28 01:00:49 2016 +0000
+++ b/Bullet.h	Fri Oct 28 01:06:01 2016 +0000
@@ -1,4 +1,48 @@
 class Bullet {
     
-    
-};
\ No newline at end of file
+        int x, topY, bottomY;
+        int length = 3;
+        int speed = 3;
+        uLCD_4DGL uLCD;
+        struct Coordinate {
+            int x1, y1, x2, y2;
+        }
+        
+    public:   
+        Bullet(uLCD_4DGL uLCD);
+        void drawBullet(int x, int bottomY);
+        void eraseBullet();
+        void move();            
+};
+
+Bullet::Bullet(uLCD_4DGL uLCD) {
+    this->uLCD = uLCD;
+}
+
+/*Bullet::Bullet(int x, int bottomY, uLCD_4DGL uLCD) {
+    this->x = x;
+    this->bottomY = bottomY;
+    this->topY = bottomY + length;
+    this->uLCD = uLCD;
+}*/
+
+void Bullet::drawBullet(int x, int bottomY) {
+    this->x = x;
+    this->bottomY = bottomY;
+    this->topY = bottomY + length;
+    uLCD.line(x,topY,x,bottomY, 0xFFFFFF);
+}
+
+void Bullet::move() {
+    bottomY+= speed;
+    drawBullet(x, bottomY);
+}
+
+void Bullet::eraseBullet() {
+    uLCD.line(x,topY,x,bottomY, 0x000000);
+}
+
+Coordinate Bullet::getLocation() {
+    Coordinate coor = {x, topY, x, bottomY;}
+    return coor;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MainGame.cpp	Fri Oct 28 01:06:01 2016 +0000
@@ -0,0 +1,69 @@
+#include "mbed.h"
+#include "Speaker.h"
+#include "uLCD_4DGL.h"
+#include "SDFileSystem.h"
+#include "wave_player.h"
+#include "Nav_Switch.h"
+#include "rtos.h"
+
+/*INSTANTIATION*/
+DigitalOut myled(LED1);
+uLCD_4DGL uLCD(p9,p10,p11); // serial tx, serial rx, reset pin;
+Nav_Switch myNav( p24, p25, p26, p27, p28); //up, down, left, right, fire
+SDFileSystem sd(p5, p6, p7, p8, "sd");
+AnalogOut DACout(p18);
+wave_player waver(&DACout);
+
+/*LOCAL VARIABLES*/
+int numTries;
+int levelNum;
+int bulletLocation;
+int obstacleLocations;
+int targetLocations;
+
+void startGame() {
+    uLCD.locate(34,34);
+    uLCD.set_font_size(4, 4); 
+    uLCD.printf("\nSharp Shooter!!\n");
+    
+    FILE *wave_file;
+    wave_file=fopen("/sd/wavfiles/def_swar.wav","r");
+    waver.play(wave_file);
+    fclose(wave_file);
+}
+
+void createTargets();
+
+void checkIfHit();
+
+void gameOver();
+
+void initializeLevel();
+
+void handleObstacleHit();
+
+void handleTargetHit();
+
+void redrawTarget();
+
+/*if(myNav.fire()) myled=!myled;
+        if(myNav.up()) myled=!myled;
+        if(myNav.down()) myled=!myled;
+        if(myNav.right()) myled=!myled;
+        if(myNav.left()) myled=!myled;
+        */
+
+int main() {
+    myled=0;
+    while(1) {
+        
+        startGame();
+        
+        
+        
+        
+        
+        
+        
+    }
+}
--- a/Obstacle.h	Fri Oct 28 01:00:49 2016 +0000
+++ b/Obstacle.h	Fri Oct 28 01:06:01 2016 +0000
@@ -41,4 +41,4 @@
 
 void Obstacle::setDirection(bool a) {
     direction = a;
-}
\ No newline at end of file
+}
--- a/Obstacle.h.orig	Fri Oct 28 01:00:49 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-class Obstacle
-{
-    Joe
-};
\ No newline at end of file
--- a/main.cpp	Fri Oct 28 01:00:49 2016 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-#include "mbed.h"
-#include "Speaker.h"
-#include "uLCD_4DGL.h"
-#include "SDFileSystem.h"
-#include "wave_player.h"
-#include "Nav_Switch.h"
-#include "rtos.h"
-
-DigitalOut myled(LED1);
-
-/*uLCD instantiation*/
-uLCD_4DGL uLCD(p9,p10,p11); // serial tx, serial rx, reset pin;
-
-Nav_Switch myNav( p24, p25, p26, p27, p28); //up, down, left, right, fire
-
-Mutex mutex;
-
-/* wave player instantiation*/
-SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card
-AnalogOut DACout(p18);
-wave_player waver(&DACout);
-
-/*play wav file on sd and when playing led1 turns on*/
-void wav_thread3(void const *args) {
-    while (1) {
-        FILE *wave_file;
-        wave_file=fopen("/sd/wavfiles/alarm.wav","r");
-        waver.play(wave_file);
-        fclose(wave_file);
-    }
-}
-
-void switch_thread5(void const *args) {
-    while (true) {
-        if(myNav.fire()) myled=!myled;
-        if(myNav.up()) myled=!myled;
-        if(myNav.down()) myled=!myled;
-        if(myNav.right()) myled=!myled;
-        if(myNav.left()) myled=!myled;
-        //Thread::wait(500);   
-    }
-}
-
-int main() {
-    myled=0;
-    //Thread thread2(switch_thread5);
-    //Thread thread3(wav_thread3);
-    while(1) {
-        uLCD.rectangle(0,0,128,10,0xFFFFFF);
-        }
-}