Top-down adventure in C# - Newly guides

Read the Key Quest script, map its parts to what happens on screen, then add a second room with its own key and a new rule.

Reading a game before changing it

Key Quest is a small adventure: find the key, dodge the slimes, open the door, reach the treasure. One C# script runs it. Before you change anything, you'll learn how it's put together.

1. Play it

Press Play. Move with the arrow keys or WASD. Get the key, open the door, touch a slime on purpose. Write down the rules you can see.

2. Read it in four parts

Open Game.cs. Every game script does four jobs. Find each one and mark it with a comment:

3. Map it

Take a screenshot of the room (or draw it). Draw an arrow from each object to the lines in the script that use it. If an object has no arrow, it's just scenery.

4. Add a second room

Plan first, on paper: where the new room goes, where its key is, what its door needs.

  1. Select the room's walls, floor, key and door in Your world, duplicate them, and drag the copies to make room two. Rename the copies: Key2, Door2. Find("Key") only ever finds the first one.
  2. In SETUP add var key2 = Find("Key2"); and var door2 = Find("Door2");.
  3. In RULES, extend the rule. Two ways:

- a second variable hasKey2 and a second door check, or
- a count: keys += 1 when any key is picked up, and doors check keys >= 1 and keys >= 2.

  1. Pick one, and write a comment above it saying why.

5. Write it up

Three sentences: what the rule checks, what it changes, and why you chose separate variables or a count.

Done when

Open on Newly