Honors 104.502 Lecture 3 – Matching
Agenda
- what ?s
- design this
- a matching game
TODO
- Watch Unity’s Roll-a-ball tutorial. For maximal learning, follow along in Unity.
- Read chapter 3.
- On a 1/4 sheet for next lecture, write down 2-3 questions or observations from your rolling experience or reading.
Note
Last week we sampled the technical side of game development. This side won’t go away, but it’s not all there is. Game designers have to figure out how to engineer fun. So, let’s start with a Design This:
Consider those matching games you played as a kid. You turned over two tiles. If they matched, you scored a point. If they didn’t, you flipped them back over and it was your opponent’s turn.
With a neighbor, argue or agree as you answer the following questions: What was the designer’s intention in making this game? Was this game fun? What tweaks could have made it more fun or produced a richer experience for the players?
Our goal this week is to implement a matching game with a twist in Unity. As we do, we’ll hit upon a few core ideas of coding that we didn’t get to last week:
- functions
- types
- objects
As we implement our game, we’ll learn how to stage our code in Unity’s functions Update
and OnTriggerEnter2D
, query for user input, and add behaviors to our game objects using components.
Code
CursorController.cs
using UnityEngine;
using System.Collections;
public class CursorController : MonoBehaviour {
public float speed;
void Update() {
float horizontal = Input.GetAxis("Horizontal");
float vertical = Input.GetAxis("Vertical");
transform.position = transform.position + speed * new Vector3(horizontal, vertical, 0);
}
}