Michael McDonald / Mbed 2 deprecated LAME

Dependencies:   mbed 4DGL-uLCD-SE SDFileSystem PinDetect

Revision:
5:cf8ae4ca6f2b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/lame.cc	Mon Apr 25 01:52:31 2022 +0000
@@ -0,0 +1,215 @@
+#include "mbed.h"
+#include "uLCD_4DGL.h"
+#include "PinDetect.h"
+#include "Speaker.h"
+#include "MMA8452.h"
+#include "lame.h"
+#include "sprites.h"
+
+
+void ScreenObject::changexPos(int input) {
+    if (xPosition < 110 && direction == true)   {
+        xPosition += input;
+        if (xPosition >= 110)   {
+            direction = false;
+            xPosition = 109;
+        }
+    }
+    else if (xPosition < 110 && direction == false) {
+        xPosition -= input;
+        if (xPosition <= 10)    {
+            direction = true;
+            xPosition = 11;
+        }
+    }
+}
+//Clears the screen using the clear sprite, very useful cuz im lazy
+void ScreenObject::clearScreen(uLCD_4DGL& input)    {
+    input.BLIT(xPosition, yPosition, 15, 8, clear_sprite);
+    xPosition = 1;
+    yPosition = 1;
+}
+
+//Implementation of setters and getters!
+void ScreenObject::setxPosition(int input) { 
+        xPosition = input; 
+}
+
+void ScreenObject::setyPosition(int input) { 
+        yPosition = input; 
+}
+
+void ScreenObject::setDirec(bool input) {
+        direction = input;
+}
+
+void ScreenObject::setHit(bool input){ 
+        hit = input;
+}
+
+bool ScreenObject::getHit(){ 
+        return hit;
+}
+
+int ScreenObject::getxPosition() { 
+        return xPosition; 
+}
+
+int ScreenObject::getyPosition() { 
+        return yPosition; 
+}
+
+//---Ship---
+Ship::Ship() {
+    setxPosition(64);
+    setyPosition(110);
+}
+
+void Ship::draw(uLCD_4DGL& input)   {
+    input.BLIT(getxPosition(), getyPosition(), 27, 8, ship_sprite);
+}
+
+void Ship::update(uLCD_4DGL& input) {
+    input.BLIT(getxPosition(), getyPosition(), 27, 8, ship_sprite);
+}
+
+void Ship::moveRight() {
+    if (getxPosition() < 100)
+    {
+        setxPosition(getxPosition()+ 2);
+    }
+}
+
+void Ship::moveLeft() {
+    if (getxPosition() > 10)
+    {
+        setxPosition(getxPosition()- 2);
+    }
+}
+
+
+//---Bullet---
+Bullet::Bullet(): oneBullet(false) { }
+
+void Bullet::draw(uLCD_4DGL& input){ 
+    input.BLIT(getxPosition(), getyPosition(), 1, 3, bullet_sprite);
+    }
+void Bullet::update(uLCD_4DGL& input){ 
+    if (getyPosition() >= 4 && oneBullet == true) {
+        setyPosition(getyPosition() - 2);
+        input.BLIT(getxPosition(), getyPosition() + 2, 1, 3, nobullet_sprite);
+        input.BLIT(getxPosition(), getyPosition(), 1, 3, bullet_sprite);
+        if (getyPosition() < 4) {
+            input.BLIT(getxPosition(), getyPosition(), 1, 3, nobullet_sprite);
+            oneBullet = false;
+        }
+    }
+}
+
+void Bullet::fireBullet(Ship &input1, uLCD_4DGL& input2) {
+    setxPosition(input1.getxPosition()+ 8);
+    setyPosition(input1.getyPosition() - 4);
+    draw(input2); 
+}
+
+void Bullet::setBullet(bool input){
+     oneBullet = input;
+}
+
+bool Bullet::getBullet(){ 
+     return oneBullet;
+}
+
+int Bullet::getxBullet() {
+     return getxPosition();
+}
+
+int Bullet::getyBullet() { 
+     return getyPosition();
+}
+
+bool Bullet::hitTest(ScreenObject& input) {
+    setHit(((getxBullet() >= (input.getxPosition()-7)) && (getxBullet() <= (input.getxPosition() + 7)) 
+    && (getyBullet() >= (input.getyPosition()-5))
+    && (getyBullet() <= (input.getyPosition() + 5))));
+    return getHit(); //this guy was hit
+}
+
+//---Alice---
+AlienAlice::AlienAlice(int input) {
+    setxPosition(1 + rand() % 110);
+    setyPosition((10+10*(input-1)) + rand() % 2);
+    setDirec(true);
+}
+
+void AlienAlice::draw(uLCD_4DGL& input) {
+    input.BLIT(getxPosition(), getyPosition(), 15, 8, alienAlice_sprite);
+}
+
+void AlienAlice::update(uLCD_4DGL& input) {
+    changexPos(2);
+    input.BLIT(getxPosition(), getyPosition(), 15, 8, alienAlice_sprite);
+}
+
+
+//---Bob---
+AlienBob::AlienBob(int input) {
+    setxPosition(1 + rand() % 110);
+    setyPosition((10+10*(input-1)) + rand() % 2);
+    setDirec(true);
+}
+
+void AlienBob::draw(uLCD_4DGL& input) {
+    input.BLIT(getxPosition(), getyPosition(), 15, 8, alienBobUp_sprite);
+}
+
+void AlienBob::update(uLCD_4DGL& input) {
+    changexPos(1);
+    int res = getxPosition() % 2;
+    switch(res)
+    {
+        case(0):
+        {
+            input.BLIT(getxPosition(), getyPosition(), 15, 8, alienBobDown_sprite);
+            break;
+        }
+        case(1):
+        {
+            input.BLIT(getxPosition(), getyPosition(), 15, 8, alienBobUp_sprite);
+            break;
+        }
+    }
+}
+
+//---Jeff---
+AlienJeff::AlienJeff(int input) {
+    setxPosition(1 + rand() % 110);
+    setyPosition((10+10*(input-1)) + rand() % 2);
+    setDirec(true);
+}
+
+void AlienJeff::draw(uLCD_4DGL& input)  {
+    input.BLIT(getxPosition(), getyPosition(), 15, 8, alienJeff_sprite);
+}
+
+void AlienJeff::update(uLCD_4DGL& input) {
+    changexPos(2);
+    input.BLIT(getxPosition(), getyPosition(), 15, 8, alienJeff_sprite);
+}
+
+//---Mike---
+AlienMike::AlienMike(int input) {
+    setxPosition(1 + rand() % 110);
+    setyPosition((10+10*(input-1)) + rand() % 2);
+    setDirec(true);
+}
+
+void AlienMike::draw(uLCD_4DGL& input)  {
+    input.BLIT(getxPosition(), getyPosition(), 15, 8, alienMike_sprite);
+}
+
+void AlienMike::update(uLCD_4DGL& input)    {
+    changexPos(2);
+    input.BLIT(getxPosition(), getyPosition(), 15, 8, alienMike_sprite);
+}
+