teaching machines

Honors 104.502 Lecture 3 – Matching

February 1, 2016 by . Filed under honors gamedev, lectures, spring 2016.

Agenda

TODO

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:

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);
  }
}