Ship Shooter 0.12

Ship Shooter on GitHub

Here is a list of changes that I have made over the past little while

  1. Added in power ups that have a chance of spawning pseudo randomly. I did this by adding a script to my game controller object that holds an array of GameObjects. This way I can edit which ones power ups to use in the inspector. So far I have a power up that increases the firing rate of the player, but is set up so that I can I also make it a debuf to the player if I wanted to in the future.  I also have one that adds health to the Earth so that the player can last longer.
  2. Added in some background art, like the Earth itself and some stars in the background. I got the stars background off of Google, and I was messing around in Photoshop to make the earth myself.
  3. Changed it so that the player dies on first contact. I feel that this makes the game a lot harder, but I can still change it for a power up that I want to add soon which will be like a shield that will just take a hit for you.
  4. The buttons scale to different resolutions! It might not be done in the best way, but I did a lot of research into this and it seems that the scaling of the UI elements in Unity is really weird and a lot of people struggle with this issue. However, it now works with all the resolutions available in the Unity Game window in the editor.
  5. Lowered the volume of the sound effects. They were very loud and annoying last time around. I eventually want to get different sound effects in the game and also a background track, but I’m not worried about that right now.

Issues that I am working on and aware of

  1. The “GAME OVER” is very fuzzy. I am still looking into the best way to scale this image, but I’m sure I will figure it out eventually.
  2. The waves of enemies really are not that great. I haven’t changed the way that they spawn at all yet, but I am going to make it non-uniform distribution, similar to the way that I spawned the dinosaurs in this demo.
  3. The background image is not scaled very well, and I want a new one. I am struggling to find one that matches the ascetic that I want for the game, and I might end up making one in Photoshop.
  4. The way that the power ups go up and down rapidly is supposed to happen. I just need to change how it happens because it look awful. Like, really bad. I’m aware of this and I’m looking into better ways to do this. I want to make them move up and down so that it is not as easy to hit them. This way when the player actually gets them them they will feel like the power up actually worth it.

That’s about it for now


Random Distribution Demo

Random Distribution Demo on GitHub

random demo screen capThis is a school project that I did a lot more than I had to do. The main goal of this project is to show my understanding of using different random distributions in code.

I used Perlin noise to generate the terrain, and I can change it to whatever kind of shape I want just in the editor. For the dinosaurs, I used a non-uniform distribution to make it so that there are more towards the front, and less in the back. The leaders(little animated guys standing on two legs) are scaled in the Y axis using a Gaussian distribution. The walk pattern that they have is also randomized to the left and right a little bit. The trees and rocks are just randomly generated within the bounds of the terrain itself. There is a problem with that which I have not fixed yet, which is that they spawn inside of the rocks and other things too.

What made me go above and beyond on this project, was that I turned it into a small game. I added a first person controller from Unity, and gave the player a basic shoot/reload sequence.

For the shooting I used ray casts. Each dinosaur has 3 hit points, and on the third hit they are destroyed. To play the animation of the small explosion going off, I used the RaycastHit variable’s point property to make a new explosion wherever the raycast hit.

I also did more than I had to when it came to aesthetics. I added in rocks around the border of  the terrain. Because the terrain is generated randomly, and the Z value will always be different, I had to make a small script so that every time the game starts, the transforms of anything with that script on it will be set to the terrains Z value at the X and Y coordinates of that object.

All assets that I imported or used in any way for this project are listed in the documentation file for it on GitHub.

Trigonometry Demo

Trigonometry Demo on GitHub

Trig Demo on YouTube

trig demo screen capThe is a simple little demo that I did for one of my programming classes which shows that I know how to use basic trigonometry in code. There were two main goals for this project.

  1. Have the hand on the clock follow the mouse cursor through code.
  2. Have the numbers of the clock be generated through code as well.

To have the mouse follow the cursor hand I used the following code:

void RotateToMouse()
// Gets the mouse location from the screen
Vector3 mouseWorldPos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
// Use the Mathf.Atan2 function to get the angle at which we need to rotate
float angleFromCenter = Mathf.Atan2(mouseWorldPos.y, mouseWorldPos.x);

// Since the angle input from Atan2 is returned in radians, we have to
// convert it to degrees in order to use the Quaternion.Euler method.
float degrees = angleFromCenter * Mathf.Rad2Deg + 180;

transform.rotation = Quaternion.Euler(0, 0, degrees);

As you can see from the YouTube video, both of my goals were achieved. How I generated the angle interval for between the numbers is like so:

angleInterval = (-1) Mathf.PI / ((numberOfObjects) / 2);

The reason that I multiplied by -1 in order to get the numbers to go in a clockwise direction when instantiating them, instead of a counter-clockwise direction.

I also have a float called startAngle, which is (PI/2), so that the generation starts at the top like a clock would. Obviously this is adjustable through the code.