Skip to content

Commit

Permalink
Finished up game. Added sounds.
Browse files Browse the repository at this point in the history
  • Loading branch information
AidanHockey5 committed Jun 5, 2017
1 parent 59e4863 commit e04901d
Show file tree
Hide file tree
Showing 42 changed files with 455 additions and 19 deletions.
14 changes: 7 additions & 7 deletions InterfaceWithCSharp/InterfaceWithCSharp.ino
Expand Up @@ -25,7 +25,7 @@

bool connectedToClient = false;
static bool isButtonDown = false;
int shortBuzzTime = 50;
int shortBuzzTime = 25;
unsigned long buzzMillis = 0;

struct Vector3
Expand All @@ -38,8 +38,8 @@ byte RGBPins[3] = {11,10,9};
Vector3 localRGBColor = {255,255,255};
Vector3 gameRGBColor = {255,255,255};
float redBias = 1;
float greenBias = 0.5;
float blueBias = 0.5;
float greenBias = 0.25;
float blueBias = 0.25;

//Equality operator overloads for Vector3
inline bool operator==(const Vector3& lhs, const Vector3& rhs){ if(lhs.x == rhs.x && lhs.y == rhs.y && lhs.z == rhs.z)return true; else return false; }
Expand Down Expand Up @@ -129,7 +129,7 @@ void loop()
}
}
//Send Commands
isButtonDown = !digitalRead(BUTTON); //Even though the button is on an interupt system, the pin still needs to be checked to ensure the interupt has the correct button state.

bool isBuzzing = buzzMillis+shortBuzzTime > millis();
if(!isBuzzing)
{
Expand All @@ -150,7 +150,8 @@ void loop()
}


delay(16.6); //Delay to match 60 updates per second. Otherwise, the serial bus would be flooded with commands.
delay(16.2); //Delay to match 60 updates per second. Otherwise, the serial bus would be flooded with commands.
isButtonDown = !digitalRead(BUTTON); //Even though the button is on an interupt system, the pin still needs to be checked to ensure the interupt has the correct button state.
rgbCount++;
}

Expand Down Expand Up @@ -227,7 +228,7 @@ void SendGyroData()
Serial.println("");
lastAccl = accl;
}
delay(16.6); //Delay for 60 updates per second.
//delay(16.6); //Delay for 60 updates per second.
}

float VectorDistance(Vector3 a, Vector3 b)
Expand Down Expand Up @@ -259,7 +260,6 @@ void SendButton()
Serial.println(isButtonDown == false ? BUTTON_DOWN_COMMAND : BUTTON_UP_COMMAND);
buzzMillis = interrupt_time;
isButtonDown = !isButtonDown;
randomSeed(interrupt_time);
}
last_interrupt_time = interrupt_time;
}
Expand Down
Binary file added Unity/.vs/Unity/v15/Browse.VC.db
Binary file not shown.
9 changes: 9 additions & 0 deletions Unity/Assets/Audio.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Unity/Assets/Audio/Music.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
22 changes: 22 additions & 0 deletions Unity/Assets/Audio/Music/Because You're The Number One.ogg.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Unity/Assets/Audio/Music/Don't Go Off.ogg
Binary file not shown.
22 changes: 22 additions & 0 deletions Unity/Assets/Audio/Music/Don't Go Off.ogg.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.
22 changes: 22 additions & 0 deletions Unity/Assets/Audio/Music/Remember Of _Knight Of Legend.ogg.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Unity/Assets/Audio/Music/music_credit.txt
@@ -0,0 +1 @@
Music from Thunder Force IV 1994
8 changes: 8 additions & 0 deletions Unity/Assets/Audio/Music/music_credit.txt.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Unity/Assets/Audio/breakTarget.ogg
Binary file not shown.
22 changes: 22 additions & 0 deletions Unity/Assets/Audio/breakTarget.ogg.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Unity/Assets/Audio/click.ogg
Binary file not shown.
22 changes: 22 additions & 0 deletions Unity/Assets/Audio/click.ogg.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Unity/Assets/Audio/fireGrapplingHook.ogg
Binary file not shown.
22 changes: 22 additions & 0 deletions Unity/Assets/Audio/fireGrapplingHook.ogg.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Unity/Assets/Audio/hitObsticle.ogg
Binary file not shown.
22 changes: 22 additions & 0 deletions Unity/Assets/Audio/hitObsticle.ogg.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Unity/Assets/Audio/level_up.ogg
Binary file not shown.
22 changes: 22 additions & 0 deletions Unity/Assets/Audio/level_up.ogg.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Unity/Assets/Materials/AbstractSkybox.mat
Binary file not shown.
Binary file modified Unity/Assets/Prefabs/ArduinoInterface.prefab
Binary file not shown.
Binary file added Unity/Assets/Prefabs/Bound.prefab
Binary file not shown.
8 changes: 8 additions & 0 deletions Unity/Assets/Prefabs/Bound.prefab.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Unity/Assets/Prefabs/Killzone.prefab
Binary file not shown.
15 changes: 10 additions & 5 deletions Unity/Assets/Scripts/GameController.cs
Expand Up @@ -9,6 +9,7 @@ public class GameController : MonoBehaviour
{
public GameObject target;
public GameObject killZone;
public GameObject bounds;
public GameObject player;
public Text targetCountText, levelCountText;
List<GameObject> targetList = new List<GameObject>();
Expand All @@ -17,10 +18,13 @@ public class GameController : MonoBehaviour
int score = 0;
int level = 1;
public Vector2 stageSize = new Vector2(50, 50);

public AudioClip levelUpSound;
AudioSource audioSource;

void Start ()
{
StartCoroutine(TargetCheck());
audioSource = GetComponent<AudioSource>();
}

IEnumerator TargetCheck()
Expand All @@ -36,6 +40,7 @@ IEnumerator TargetCheck()
targetCountText.text = "Targets: " + score.ToString() + "/" + targetsToSpawn.ToString();
levelCountText.text = "Level " + level.ToString();
yield return new WaitUntil(() => targetList.Count == 0);
audioSource.PlayOneShot(levelUpSound, 0.25f);
level++;
targetsToSpawn += 3;
killzonesToSpawn += 2;
Expand Down Expand Up @@ -90,13 +95,13 @@ void GenerateStage()
}

//Generate stage bounds
GameObject l = Instantiate(killZone, new Vector2(-stageSize.x-5, 0), Quaternion.identity) as GameObject;
GameObject l = Instantiate(bounds, new Vector2(-stageSize.x-5, 0), Quaternion.identity) as GameObject;
l.transform.localScale = new Vector2 (1, stageSize.y);
GameObject r = Instantiate(killZone, new Vector2(stageSize.x+5, 0), Quaternion.identity) as GameObject;
GameObject r = Instantiate(bounds, new Vector2(stageSize.x+5, 0), Quaternion.identity) as GameObject;
r.transform.localScale = new Vector2 (1, stageSize.y);
GameObject u = Instantiate(killZone, new Vector2(0, stageSize.y+5), Quaternion.identity) as GameObject;
GameObject u = Instantiate(bounds, new Vector2(0, stageSize.y+5), Quaternion.identity) as GameObject;
u.transform.localScale = new Vector2 (stageSize.x, 1);
GameObject d = Instantiate(killZone, new Vector2(0, -stageSize.y-5), Quaternion.identity) as GameObject;
GameObject d = Instantiate(bounds, new Vector2(0, -stageSize.y-5), Quaternion.identity) as GameObject;
d.transform.localScale = new Vector2 (-stageSize.x, 1);
}

Expand Down
32 changes: 32 additions & 0 deletions Unity/Assets/Scripts/GravityObject.cs
@@ -0,0 +1,32 @@
using UnityEngine;
using System.Collections;

public class GravityObject : MonoBehaviour
{

private double G;
public float mass = 100f;
Rigidbody2D playerRb;
void Start()
{
G = 6.674f * (10 ^ 11);
playerRb = GameObject.FindGameObjectWithTag("Player").GetComponent<Rigidbody2D>();
}

// Update is called once per frame
void Update()
{
Gravity(mass, playerRb);
}

void Gravity(float m, Rigidbody2D b)
{
Vector3 direction = b.transform.position - transform.position;
float r = direction.magnitude;
if (r == 0) //Normalize
return;
direction /= r;
float force = ((float)G * m * b.mass) / (r * r);
b.AddForce(-direction * force);
}
}
12 changes: 12 additions & 0 deletions Unity/Assets/Scripts/GravityObject.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e04901d

Please sign in to comment.