Sky Hawks

Year:
Dec 2012- Aug 2013

 

Play Game:
http://marvinhawkins.itch.io/sky-hawks

Tools:
Unity 3d/ Javascript

Role:
Programmer /3d art

Description:

Sky Hawks is a top down arcade shooter prototype that I created in Unity 3D. Using the tutorial from Design3 as a base, I pushed the demo further by adding a menu, power ups, UI elements and more.  I created of the background/level art  the UI elements. and designed the level.  Major game play elements include Player Movement, Enemy Generation, Enemy Shooting, Power ups, and a Boss Fight. I learned a great deal about programming in Javascript and Unity3D game development.

Personal Contribution

Sky  Hawks was a solo project. I did have some contributors with art, however. I had to communicate the project’s art needs, and establish a pipeline for the artist’s work. Code Wise, I handled the following:

  • Created a full game loop with win/loss condition

  • Created a player movement, scoring, shooting, and enemy shooting system

  • Created buildings and other props and placed them in level

  • Created Scrolling background that loaded next level when the player reached the end

  • Created Boss routine using Playmaker visual scripting language

  • Created multiple enemy types with unique behavior

 

Example Code

This is a sample of code of the player object. This contains collision detection for the player colliding with enemies and powerups.

var playerSpeed : float = 1;
var bulletprefab : GameObject;
var  explosionprefab : GameObject; 
var playerinvicedelay : float; 
var bombprefab : GameObject;
var BombExplosionprefab : GameObject;

var RocketProjprefab : GameObject; 
var Rocketprefab :GameObject;
var laserprefab : GameObject;
var isInvincible:boolean=false;  
var Thruster : ParticleEmitter; 

private var spawntime : float;
private var shipmoveonscreen : float = 5;
private var Blinkrate : float = .1;
private var numberoftimestoblink : float = 10;
private var blinkcount : float = 0;

//smoothing angle
var smooth : float = 1.0;
var tiltAngle : float = -65.0;
 

/////////////////////////////////////////////////////////////





//////////////////////////////////////////////////////////

enum State {    Playing, Explosion, Invincible}

var State : state ;
var  Score : float = 0;
var bullettype : int;
var bulletposition : Vector3;
var bulletposition2 : Vector3;
var  bombposition : Vector3; 
 

private var bulletTimer : float;
private var  rotatestate : int; 


//ADDED Input to fire on delay
public var shotDelay: float = 5;
public var readyToShoot = true;
 
////////////////////////////////////////////////////////////
   
 
function Awake(){

spawntime = Time.time; 
//DontDestroyOnLoad(this);

isInvincible=true;
    StartCoroutine(InvincibleToggle(10.0));
    StartCoroutine(Blink(10.0));
 
}


function Update () {

    

    var tiltAroundX= Input.GetAxis("Horizontal") * tiltAngle;
    var tiltAroundZ = Input.GetAxis("Vertical") * tiltAngle;
    var target = Quaternion.Euler (tiltAroundX, 180, tiltAroundZ);
    
    
    // Dampen towards the target rotation
    transform.rotation = Quaternion.Slerp(transform.rotation, target,
                                   Time.deltaTime * smooth);;
                                   
//

if(transform.position.x < 10){
    // move the ship on screen
    var amtTomove = shipmoveonscreen * Time.deltaTime ;
    transform.position = new Vector3(transform.position.x + amtTomove, transform.position.y, transform.position.z);
        
    }

    
if (Gamecontroller.isWin == true ){
            
            // move the ship on screen when  a boss dies
            
            var amtTomove2 = 100 * Time.deltaTime ;
            
            
            transform.position = new Vector3(transform.position.x + amtTomove2, transform.position.y, transform.position.z);
            }



if (State != state.Explosion)
{


var  playervertical  = (playerSpeed * Input.GetAxis ("Vertical") )* Time.deltaTime;
transform.Translate(Vector3.left * playervertical);
var  playerhorizontal  = (playerSpeed * Input.GetAxis ("Horizontal") )* Time.deltaTime;
var horizontalmove : Vector3  = new Vector3(0,0,1);
transform.Translate(horizontalmove * playerhorizontal);
transform.Rotate(playerhorizontal, 0, 0);


//Restrict the player's boundaries

//
if(Gamecontroller.isWin == false)
{
//the position of the player ship boundaries of the screen

    transform.position.z = Mathf.Clamp(transform.position.z, -60, 60);
    transform.position.y = Mathf.Clamp(transform.position.y, 114, 114);
    transform.position.x = Mathf.Clamp(transform.position.x, -25, 70);
}   




 /// weapons firing stuff
 
 bulletTimer -= 1 * Time.deltaTime;
 
 if (bulletTimer < 0){
    bullettype = 0;
  }
 
 
 if (Input.GetButton("Fire1") && readyToShoot)
            
        {   readyToShoot = false;
            Invoke("ResetReadyToShoot", shotDelay );
            Shoot();
            
            
        }
        //bomb Powerup
        if (Input.GetKeyDown("b") ||Input.GetKeyDown("joystick button 13") )  
        {
            
            if (Gamecontroller.Bombs >= 1){
            
            
            bombposition = gameObject.transform.TransformPoint(Vector3.forward * 3);    
            Instantiate (bombprefab, bombposition, transform.rotation );
            Instantiate (BombExplosionprefab, bombposition, transform.rotation );
            
            Gamecontroller.Bombs -=1;       
            }
                        
        }
        
    }
}

function PlayerShipRoll ()
{
//////Fix this!
// value = Input.GetKey ("W");
    if (Input.GetKey (KeyCode.A))
  { 
        
        
        transform.Rotate(0, 0,0);
        yield  WaitForSeconds;
            transform.rotation.x = Mathf.Clamp(transform.rotation.x, 25, 0);
            print ("Horizontal key was pressed");
       
    }
    if (Input.GetKeyDown (KeyCode.D))
    {
        transform.Rotate(-35,0, 0);
        transform.rotation.x = Mathf.Clamp(transform.rotation.x, 0 ,0 );
        yield WaitForSeconds(2) ;
        transform.Rotate (180,180,0);
    }

}

function Shoot(){


        bulletposition = gameObject.transform.TransformPoint(Vector3.forward * 3);
            bulletposition2 = gameObject.transform.TransformPoint(Vector3.forward * -3);
             //creates the missle
            
            if ( bullettype == 0 ){
            var newbullet : GameObject = Instantiate (bulletprefab, transform.position, transform.rotation);    
            
            
            }
            
            else if (bullettype == 1 ){
            Instantiate (bulletprefab, bulletposition, transform.rotation );
            Instantiate (bulletprefab, transform.position, transform.rotation  );
            Instantiate (bulletprefab, bulletposition2 , transform.rotation);
            }
            else if (bullettype == 2 ){
            Instantiate (bulletprefab, transform.position, Quaternion.Euler (Vector3(0, -200,0) ) );  //Adjusted the shooting angle 8/15/13
            Instantiate (bulletprefab, transform.position, transform.rotation);
            Instantiate (bulletprefab, transform.position, Quaternion.Euler (Vector3(0,  200,0) ) );
            Instantiate (bulletprefab, transform.position, Quaternion.Euler (Vector3(0,  -150,0) ) );
            Instantiate (bulletprefab, transform.position, Quaternion.Euler (Vector3(-90,  150,0) ) );
            }
            else if (bullettype ==3){
            
            Instantiate (Rocketprefab, transform.position, transform.rotation);
            
            }
            else if (bullettype ==4){
            
            //instantiate the bullet
            var myBeam : GameObject = Instantiate (laserprefab, transform.position, transform.rotation);
            myBeam.transform.parent = transform;
            
            }   

}



function OnTriggerEnter (  otherobject : Collider)

{
if ( otherobject.tag == "powerup")
    {
        powerUpLaser();
    }
    else if ( otherobject.tag == "bombpowerup")
    {
        
        powerUpBomb();
    }
    else if(otherobject.tag == "Spreadshot")
    {
        powerupSpreadshot();
    
    }
    else if (otherobject.tag == "lifepowerup")
    {
        powerUpLives();
    
    }
        else if (otherobject.tag == "Invincible")
    {
        powerUpInvincible();
        
    
    }
        else if (otherobject.tag == "ExtraScore")
    {
        powerUpPoints();
        
    
    }
        else if (otherobject.tag == "RocketPickup")
    {
        powerUpRocket();
        
    }
    else if (otherobject.tag == "LaserPickup")
    {
        powerUpBeam();
        
    }
    else if (otherobject.tag == "Repair")
    {
        powerUpRepair();
        
    }
    
    
    
    else if (otherobject.tag == "ShieldPowerUp") //make the player invincible 12-9-12
    {
        PowerUpShield(); //powerup shiled activate 
    
    }
    
    
    
    

else if  ( (otherobject.tag == "Enemy Bullet") && ( Time.time > spawntime + playerinvicedelay )  )
    {
    
      
    if(!isInvincible) 
    
    {
    audio.Play(); //Play audio when hit
    Blinky();
    Gamecontroller.Health -=1;
    hitInvincible();
    
    
    if(Gamecontroller.Health<0)
    {
    
    Gamecontroller.Lives -= 1 ; 
            if (Gamecontroller.Lives > 0){
            
                
                
//              state.Explosion;
                gameObject.Find("GameController").GetComponent(Gamecontroller).Respawn();
            }
            else
            {
                Gamecontroller.GameOver = true; //run the game over state in gamecontroller
            }
            
            Instantiate (explosionprefab, transform.position, Quaternion.identity);
            
            Destroy(gameObject);
            
                }
            }   
        }
    }




// powerup function calls 
// As the player collides with powerups, change the gameplay and modify the variables below 
function powerUpLaser(){
bullettype = 1;
bulletTimer = 999; 
bullettype  = Mathf.Clamp(bullettype,0,10);

//print ("POWERUP?");

}


//Repair powerup
function powerUpRepair()
{
    Gamecontroller.Health +=1;
}


function powerUpBomb()
{

    Gamecontroller.Bombs += 1;
}

function powerUpLives()
{

    Gamecontroller.Lives += 1;
}

function powerUpInvincible()
{
    playerinvicedelay += 10;
    
}

function hitInvincible()
{
    playerinvicedelay += 1;
    
}



function powerUpPoints()

{
    Gamecontroller.score += 50;
    
}



//works
function powerUpRocket()
{
bullettype = 3;
bulletTimer = 999; 
bullettype  = Mathf.Clamp(bullettype,0,10);
    shotDelay = 1;
    
}

function powerUpBeam()
{
bullettype = 4;
bulletTimer = 999; 
bullettype  = Mathf.Clamp(bullettype,0,10);
shotDelay = 2;

}


function powerupSpreadshot()
{
bullettype = 2;
bulletTimer = 999; 
bullettype  = Mathf.Clamp(bullettype,0,10);
shotDelay = .5;
    
    
}


function InvincibleToggle(){
    isInvincible=!isInvincible;
}

function InvincibleToggle(waitTime : float){
    yield WaitForSeconds (waitTime);
    isInvincible=!isInvincible;
}


function Blink(timeLenght : float){
    var start : float =Time.time;
    
    while(Time.time<(timeLenght+start)){
        
        renderer.material.color=Color.yellow;//this flashes the object
        yield WaitForSeconds(0.10);
        renderer.material.color = Color.white;
        yield WaitForSeconds(0.10);
        }
}

//Controlls the blink for the player hit
function Blinky(){
    yield WaitForSeconds(0.15);
    renderer.material.color=Color.red;//this flashes the object
    yield WaitForSeconds(0.15);
    renderer.material.color = Color.white;
}

function ResetReadyToShoot()
{
    readyToShoot = true;
    
}


function PowerUpShield(){
StartCoroutine(InvincibleToggle(10.0));
StartCoroutine(Blink(20.0));
}