Category Archives: Game Design

Lesson 6: High Score

In this lesson, we will access the “High Score” and display it on the Lose_Scene

HighScore

Use the code below to create a new script called HighScore. You will create an empty gameobject called High Score that you will attach this script to. You will then assign a new text object to the scripts variable as in the video below the code.

Wire Up the High Score

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class HighScore : MonoBehaviour {
    public Text highScore;
	// Use this for initialization
	void Start () {
        highScore.text = "Jumps: " + PlayerPrefs.GetInt("High Score").ToString();
    }
}

Project Files

If you cannot troubleshoot your way past any problems. The link below provides a download to the project files up to this point:

Lesson 3: Menu System

In this lesson we are going to add a start menu and lose scene. You’ll follow the directions in the video and use the code below:

Create a Start Menu

LevelManager.cs

Create a Lose Scene

Follow similar steps as you did to create a start menu to build a lose scene. You will have to modify the code in your BirdScript on line 42 to change to your Lose_Scene instead of restarting the MainScene.

Lesson 4: Menu System

In this lesson you’re going to refer back to the FlappyBird Clone build and add a menu system by making minor adjustments that are suitable for this game.

Create a Start Menu

LevelManager.cs

using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using UnityEngine.SceneManagement;
public class LevelManager : MonoBehaviour {
    public Text highScore;
    void Start(){
        if (SceneManager.GetActiveScene ().name != "Start_Menu") {
        }
    }
    public void LoadLevel (string name){
        SceneManager.LoadScene(name);
    }
}

Create a Lose Scene

Follow similar steps as you did to create a start menu to build a lose scene. You will have to modify the code in your NinjaScript on line 18 to change to your Lose_Scene instead of restarting the MainScene.

//Change this:
SceneManager.LoadScene (SceneManager.GetActiveScene ().buildIndex);
//To this:
SceneManager.LoadScene ("Lose_Scene");

Project Files

If you cannot troubleshoot your way past any problems. The link below provides a download to the project files up to this point:

Mod Scripts

WASD Script

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Movement : MonoBehaviour {
    public float speed = 20f;
    void Update () {
        Vector3 pos = transform.position;
        if (Input.GetKey ("w")) {
            pos.y += speed * Time.deltaTime;
        }
        if (Input.GetKey ("s")) {
            pos.y -= speed * Time.deltaTime;
        }
        if (Input.GetKey ("d")) {
            pos.x += speed * Time.deltaTime;
            transform.localRotation = Quaternion.Euler(0, 0, 0); //flip sprite
        }
        if (Input.GetKey ("a")) {
            pos.x -= speed * Time.deltaTime;
            transform.localRotation = Quaternion.Euler(0, 180, 0); //flip sprite
        }
        transform.position = pos;
    }
}

Collision With Tag

void OnCollisionEnter2D(Collision2D coll) {
	if (coll.gameObject.tag == "MyTag") {
		Debug.Log ("Boom", gameObject);
		animator.SetBool ("Collision", true); //this changes the bool parameter to true and triggers the "Boom" animation
		Invoke ("ChangeLevel", .5f);
	}
}

FrameRate.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FrameRate : MonoBehaviour {
	private Animator anim;
	void Start ()
	{
		anim = gameObject.GetComponent<Animator> ();
	}
	void Update ()
	{
		if(Input.GetMouseButton(0))
		{
			anim.speed = 2f;
		}
		else
		{
			anim.speed = 1f;
		}
	}
}

Spring Ninja Counter

//Attach this script to your Ninja Prefab
//Assign the Text Game Object as the "CountText"
//Manually move the Ninja prefab into your hierarchy
//Delete "Instantiate(ninjaObject);" from the Start() function of the MainScript
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Counter : MonoBehaviour {
    public Text CountText;
    public static int count;
	// Use this for initialization
	void Start () {
        PlayerPrefs.DeleteAll(); //DELETE THIS LINE AND SEE WHAT HAPPENS
        count = PlayerPrefs.GetInt("High Score", -1);
    }
    void OnCollisionEnter2D(Collision2D coll)
    {
        if (coll.gameObject.tag == "Pole")
        {
            count = count + 1;
            PlayerPrefs.SetInt("High Score", count);
            SetCountText();
        }
    }
    void SetCountText(){
        CountText.text = "Jumps: " + count.ToString();
    }
}

Random Spawner

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RandomSpawner : MonoBehaviour
{
    public GameObject Projectile;
    float randY;
    Vector2 whereToSpawn;
    public float spawnRate = 2f;
    float nextSpawn = 0.0f;
    // Update is called once per frame
    void Update()
    {
        if (Time.time > nextSpawn)
        {
            {
                nextSpawn = Time.time + spawnRate;
                randY = Random.Range(-40f, 30f);
                whereToSpawn = new Vector2(transform.position.x, randY);
                Instantiate(Projectile, whereToSpawn, Quaternion.identity);
            }
        }
    }
}

Projectile

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Projectile : MonoBehaviour {
    // this global variable will be set from the inspector. Represents pipe velocity
    public Vector2 pipeVelocity = new Vector2();
    public float destroy = -100;
    // function to be executed once the pipe is created
    void Start()
    {
        // setting the velocity of the rigid body component attached to the pipe
        GetComponent<Rigidbody2D>().velocity = pipeVelocity;
    }
    // function to be executed at each frame
    void Update()
    {
        // checking x position
        if (transform.position.x < destroy)
        {
            // destroying the pipe and freeing memory and resources
            Destroy(gameObject);
        }
    }
}

Lesson 5: Counter

Simple Counter

Create a new script called “Counter,” and then add the code below. Attach this to your ninja game object.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Counter : MonoBehaviour {
    // add this global variable to assign a GameObject in the editor
    public Text CountText;
    // add this to keep track of the actual score
    public static int count;
    //add this to void Start()
    private void Start()
    {
        PlayerPrefs.DeleteAll(); //DELETE THIS LINE AND SEE WHAT HAPPENS
        count = PlayerPrefs.GetInt("High Score", 0);
        SetCountText();
    }
    void Update()
    {
        if (Input.GetButtonDown("Fire1"))
        {
            count = count + 1;
            PlayerPrefs.SetInt("High Score", count);
            SetCountText();
            print(count);
        }
    }
    //add this to display a dynamic score
    void SetCountText()
    {
        CountText.text = "Jumps: " + count.ToString();
    }
}

Wire up the Simple Counter

Collision Counter

To create a more complicated, but perhaps more accurate counter, use the code below:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class Counter : MonoBehaviour
{
    public Text CountText;
    public static int count;
    // Use this for initialization
    void Start()
    {
        PlayerPrefs.DeleteAll();
        count = PlayerPrefs.GetInt("High Score", -1);
    }
    void OnCollisionEnter2D(Collision2D coll)
    {
        if (coll.collider.tag == "Pole")
        {
            print("foo");
            count = count + 1;
            PlayerPrefs.SetInt("High Score", Counter.count);
            SetCountText();
        }
    }
    void SetCountText()
    {
        CountText.text = "Jumps: " + Counter.count.ToString();
    }
}

Project Files

If you cannot troubleshoot your way past any problems. The link below provides a download to the project files up to this point:

Game Design and Development

This course is designed for students interested in learning how to build video games. The curriculum will engage learners with hands-on activities and exercises to develop the skills necessary to manage the game creation process. Problem solving, critical thinking, and creativity will be emphasized in this course as well.

Syllabus

Click the following link to download the Course Syllabus

Google_Classroom_LogoGoogle Classroom

We will use Google’s classroom management tool Google Classroom to communicate, distribute, and collect assignments and resources.  You will need a join code in order to join this class.

  • Join Code: 3ddpc4v

Initial Course Survey

Table of Contents:

2D Code Snippets

The code snippets below are intended to be used in Unity’s 2D development environment.

CameraScript.cs

using UnityEngine;
using System.Collections;
public class CameraScript : MonoBehaviour {
	public GameObject player;
	// Update is called once per frame
	void Update () {
		this.gameObject.transform.position = new Vector3(player.gameObject.transform.position.x,this.gameObject.transform.position.y,this.gameObject.transform.position.z);
	}
}

Fading.cs

Import the file: black.jpg into your sprites folder and adjust the settings to match the image below, then add the script below to a GameObject in your scene (LevelManager for example). Drag black.jpg into “Fade Out Text.”
black
black-settings

using UnityEngine;
using System.Collections;
public class Fading : MonoBehaviour {
	public Texture2D fadeOutTexture;	// the texture will overlay the screen. This can be a black image or a loading graphic
	public float fadeSpeed = 0.8f;		// the fading spped
	private int drawDepth = -1000;		// the textire's order in the drawing hierarchy: a low number means it renders on top
	private float alpha = 1.0f;			// the texture's alpha between 0 and 1
	private int fadeDir= -1;			// the direction to fade: in = -1 or out = 1
	void OnGUI (){
		// fade out/in the alpha value using a direction, a speed and Time.deltatime to convert the operation to seconds
		alpha += fadeDir * fadeSpeed * Time.deltaTime;
		// force (clamp) the number between 0 and 1 because GUI.color uses alpha values between 0 and 1
		alpha = Mathf.Clamp01 (alpha);
		// set color of our GUI (in this case our texture). All color values remain the same & the Alpha is set to the alpha variable
		GUI.color = new Color (GUI.color.r, GUI.color.g, GUI.color.b, alpha);				// set the aplha value
		GUI.depth = drawDepth;																// make the balck texture render on top (draw last)
		GUI.DrawTexture (new Rect (0, 0, Screen.width, Screen.height), fadeOutTexture );	// draw the texture to fit the enture screen area
	}
	// set fadeDir to the direction parameter making the scene fade in if -1 and out if 1
	public float BeginFade (int direction) {
		fadeDir = direction;
		return (fadeSpeed);		// return the fadeSpeed variable so it's easy to time the Application.LoadLevel();
	}
	// OnLevelWasLoaded is called when a level is loaded. It takes loaded level index (int) as a parameter so you can limit the fade in to certain scenes
	void OnLevelWasLoaded (){
		//alpha = -1;		// use this if the alpha is not set to 1 by default
		BeginFade (-1);		// call the fade in function
	}
}

LevelAdvance.cs

Create an empty GameObject called LevelManager and add this script to advance between levels.

using UnityEngine;
using System.Collections;
public class LevelAdvance : MonoBehaviour {
	// Update is called once per frame
	void Update () {
		if (Input.anyKey)
			Application.LoadLevel(Application.loadedLevel + 1);
	}
}

Unit 3: Career Exploration

In this mini-unit, you’ll explore the career opportunities that exist in the gaming industry in the greater Chicagoland area.

Requirements

Create an informational slide deck that addresses each of the requirements below:

  • Describe the landscape of the video game design/development industry in the city of your choice
    • This should be a broad overview describing the types of studios that reside here
    • Introduce any “big name” games and/or studios that are in that city
  • Research a smaller game design studio in your city
    • How big are they?
    • What are they best known for?
    • What career opportunities exist here?
  • Find a current job vacancy in the Video Game sector in your city
    • Describe the job responsibilities
    • What is the salary?
    • What added benefits or other interesting information can you find about this opportunity?

Resources

Use the links below as a starting point to learn about Game Design job vacancies in Chicago and conduct valid searches for other cities as needed:

Slide Deck Requirements

Your report can come in a variety of shapes and sizes (Prezi, Google Slides, PowToon, Canva, etc.), but should follow these guidelines:

  • Summarize your research, do NOT write block paragraphs.
  • Use bullet points or short sentences to express your findings.
  • Cite all of your source of information. The web site address is sufficient for your citation, do not worry about MLA formatting.
  • Include at least 5 visuals in your report (pictures, graphs, charts) to provide visual interest and support to your information.

Exemplar

Rubric

Consult the rubric here for grading requirements:

Submit via Google Classroom. Google_Classroom_Logo