Game Development 1

OVERVIEW:

This course is designed to introduce students to game design and development through classroom discussions and hands-on programming. Students will learn the specific commands needed to make a game while navigating through the game development levels. This will culminate in a final project in which each student designs and creates their own unique game and collects peer feedback for improvement.

LEVELS:

KEY TERMS:

Player - The person who plays the game and controls the game piece (example: In Tetris, the person who presses a button to drop the blocks into place.)

Goal - A task that a player must perform to win (or progress in) a game (example: The player must collect all the gems before progressing to the next level.)

Mechanic - The rules that govern how a player interacts with a game and how the game interacts with a player (example: In platform games, the player presses a button that makes the hero jump.)

Spawnable - An object in a game that a student can add to their game using the spawn command. (example: scenery, characters, and gems)

Property - A characteristic of an object. (example: The x-position of the gem that is being spawned.)

Lesson 1: Spawnables and Mechanics

Summary:

These levels provide students with the tools they need to add spawnable objects to their game and goals to the levels they design. Students will learn about basic game mechanics and designing levels with clear goals.

Learning Objectives:

  • Use correct syntax when writing code.

  • Use proper sequencing when writing code.

  • Use arguments to input information into a method.

  • Use suitable methods for spawning objects and defining game goals.

  • Define basic vocabulary: spawnable, mechanic, and goal.

Level 1: Over the Garden Wall

This is the first game development level.

You will learn how to make your own games!

You need to spawn 4 more "fence"s (for a total of 8, including the ones given to you) to protect these villagers from marauding ogres.

You should spawnXY fences at the same x coordinate (39), but vary the y coordinate.

Each fence segment should be 4 meters more than the previous "fence"s y position.

Over the Garden WallSolution

// Use game.spawnXY() to build a fence around the farm!

game.spawnXY("fence", 39, 16);

// Spawn 2 more fences 4 meters apart...

// Spawn a "fence" at y 20

game.spawnXY("fence", 39, 20);

// Spawn a "fence" at y 24

game.spawnXY("fence", 39, 24);

game.spawnXY("fence", 39, 28);

game.spawnXY("fence", 39, 32);

// Spawn 2 more fences 4 meters apart...

// Spawn a "fence" at y 36

game.spawnXY("fence", 39, 36);

// Spawn a "fence" at y 40

game.spawnXY("fence", 39, 40);

game.spawnXY("fence", 39, 44);

Level 2: Click Gait

To play your game, click the PLAY button under the code window.

In this level, we've added the code required to make this mini-game work.

All you need to do is click Test Level, then move the hero around the house by clicking with the mouse.

To win, you have to move to all the red X marks!

Click Gait Solution

// Don't change any code. Just click PLAY button!

// Move to all the red X marks to win.

game.spawnPlayerXY("knight", 5, 8);

game.addMoveGoalXY(10, 18);

game.addMoveGoalXY(10, 38);

game.addMoveGoalXY(48, 41);

Level 3: Hero's Journey

Every game needs a goal for the player.

One type of goal is a move goal - somewhere the player needs to get to.

Hero's Journey Solution

// Each game must have a player and a goal.

// Use game.spawnPlayerXY("captain", x, y)

// to add a player to your game:

game.spawnPlayerXY("captain", 9, 9);

// Use game.addMoveGoalXY(x, y)

// to add a movement goal to your game:

// it should be 10m away from the player.

game.addMoveGoalXY(53, 45);

// If you want to, use spawnXY("fence", x, y)

// to make a maze with fences...

// Then, click "Test Level" to try your first playable game!

Level 4: A-maze-ing

Now you can use game.spawnXY() to spawn a "forest" tile, and a "chest" of gems!

Also, you can add a goal to collect all gems with game.addCollectGoal().

A-maze-ing Solution

// Alejandro likes a challenge!

// Add more "forest" objects to the level to create a long maze.

// Set up the game's goal.

game.addCollectGoal();

// Spawn a hero and chest to collect.

game.spawnPlayerXY("duelist", 9, 59);

game.spawnXY("chest", 8, 14);

game.spawnXY("forest", 26, 51);

// Add 2 more "forest" objects. Make sure not to block the gems completely!

game.spawnXY("forest", 34, 22);

game.spawnXY("forest", 50, 22);

Level 5: Gemtacular

Add a collection goal, then spawn some gems for the player to collect!

Gemtacular Solution

// Anya is searching for gems!

// Add gems to the level for the player to find.

// You must be able to beat your level to continue.

game.spawnPlayerXY("captain", 9, 18);

// Add a goal to collect the gems using game.addCollectGoal()

game.addCollectGoal();

game.spawnXY("gem", 28, 28);

// Spawn 3 gems across the level for the player to collect:

game.spawnXY("gem", 69, 10);

game.spawnXY("gem", 9, 36);

game.spawnXY("gem", 45, 44);

Lesson 2: Goal Changes

Summary

These levels provide students with practice modifying goals and spawning different types of objects needed in order to meet those goals.

Learning Objectives

  • Use correct syntax when writing code.

  • Use proper sequencing when writing code.

  • Use arguments to input information into a method.

  • Differentiate between different kinds of goals and spawnable objects.

Level 6: Vorpal Mouse

When playing a game, you can click on the ground to move and an ogre to attack it!

This level, all you need to do is click PLAY, then defeat all the ogres!

Vorpal MouseSolution

// When playing, click an ogre to attack!

// No need to type any code for this level, just click Test Level!


// The following code spawns a playable hero:

game.spawnPlayerXY("guardian", 40, 40);

// These add goals to the level:

game.addDefeatGoal();

game.addSurviveGoal();

// This spawns some enemies to fight:

game.spawnXY("munchkin", 40, 25);

game.spawnXY("munchkin", 15, 15);

game.spawnXY("munchkin", 65, 15);

// This spawns a maze for the player:

game.spawnXY("forest", 30, 54);

game.spawnXY("forest", 50, 54);

game.spawnXY("forest", 30, 48);

game.spawnXY("forest", 50, 48);

game.spawnXY("forest", 30, 40);

game.spawnXY("forest", 50, 40);

game.spawnXY("forest", 30, 32);

game.spawnXY("forest", 50, 32);

game.spawnXY("forest", 30, 26);

game.spawnXY("forest", 50, 26);

game.spawnXY("forest", 30, 10);

game.spawnXY("forest", 50, 10);

game.spawnXY("forest", 22, 26);

game.spawnXY("forest", 58, 26);

game.spawnXY("forest", 14, 26);

game.spawnXY("forest", 66, 26);

Level 7: Crushing It

Practice making a simple ogre-fighting game:

Remember to

  1. Add a hero for the player to control.

  2. Add a goal to defeat the ogres.

  3. Spawn some munchkins!

Crushing It Solution

// If you forget any commands, look to the left of the code window!

// Spawn a hero using game.spawnPlayerXY(type, x, y).

game.spawnPlayerXY("champion", 20, 20);

game.addSurviveGoal();

// Add a goal to defeat ogres with game.addDefeatGoal()

game.addDefeatGoal();

game.spawnXY("munchkin", 40, 10);

// Spawn at least 3 more munchkins.

game.spawnXY("munchkin", 34, 49);

game.spawnXY("munchkin", 51, 40);

game.spawnXY("munchkin", 64, 21);

Level 8: Give and Take

To make your games a little more interesting, try adding some "fire-trap"s and "potion-small"s!

Give and Take Solution

// Move to all the X-marks.

// Those fire-traps hurt!

game.spawnPlayerXY("samurai", 40, 50);

game.addSurviveGoal();

game.addMoveGoalXY(25,40);

game.spawnXY("fire-trap", 25, 40);

game.addMoveGoalXY(55,40);

game.spawnXY("fire-trap", 55, 40);

game.addMoveGoalXY(40,20);

game.spawnXY("fire-trap", 40, 20);

// Spawn some "potion-small" objects to heal the player!

game.spawnXY("potion-small", 30, 39);

game.spawnXY("potion-small", 40, 25);

Level 9: Army Training

Spawn new unit types:

game.spawnXY("thrower", 10, 10); // Ogre Spear Thrower

game.spawnXY("soldier", 10, 10); // Human Soldier

game.spawnXY("archer", 10, 10); // Human Archer

Army Training Solution

// Spawn a hero and add a goal.

game.spawnPlayerXY("champion", 40, 15);

game.addDefeatGoal();

// Spawn at least 2 "munchkin"s.

game.spawnXY("munchkin",32,32);

game.spawnXY("munchkin",29,43);

// Spawn at least 2 "thrower"s.

game.spawnXY("thrower",21,34);

game.spawnXY("thrower",23,46);

// Spawn at least 2 "soldier"s.

game.spawnXY("soldier",52,31);

game.spawnXY("soldier",51,41);

// Spawn at least 2 "archer"s.

game.spawnXY("archer",62,35);

game.spawnXY("archer",59,42);

Level 10: Ranger Danger

Archers are powerful ranged units! Use them instead of soldiers to deal lots of damage.

Be careful, though, as archers don't have as much health as soldiers do!

When adding units to your level, remember there are different types of units which have different stats!

Archers are long-ranged damage dealers, but they have low health.

Soldiers are close-ranged tanky units, with lots of health.

In this level, compare the brawler's health between 3 soldiers and 1 archer, versus 1 soldier and 3 archers!

Ranger Danger Solution

// Archers are powerful ranged units!

// While soldiers have health, archers provide damage.

// Too many soldiers, not enough archers!

game.spawnXY("soldier", 20, 40);

game.spawnXY("archer", 10, 30);

// Add 2 more archers:

game.spawnXY("archer", 20, 30);

game.spawnXY("archer", 20, 20);

Level 11: Hedge Magic

Spawn a maze with:

game.spawnMaze("forest", 1)

Change the number 1 to a different number, and you'll get different mazes.

The maze for each number will always be the same!

If you change "forest" for any other type of spawnables, then ... you'll see. Have a fun!

Hedge Magic Solution

// Spawn a maze. Change the number for a different maze!

game.spawnMaze("forest", 1234567890);

// Spawn a hero with spawnPlayerXY(type, x, y)

game.spawnPlayerXY("duelist", 12, 13);

// Add at least one goal!

game.addMoveGoalXY(60, 59);

Lesson 3: Changing Properties

Summary:

These levels allow students to apply their knowledge of objects from Introduction to Computer Science in the context of game development. They also introduce students to the concept of properties.

Learning Objectives:

  • Apply knowledge of object properties to game development.

  • Change properties in order to modify game behavior for desired goal.

Level 12: Forest Incursion

When you call spawnPlayerXY(), it returns a player object for you to modify.

You can then change properties of the player, like maxSpeed, maxHealth, health, and attackDamage!

Forest Incursion Solution

// Okar needs to stomp out these annoying little munchkins!

// Unfortunately he is slow, and his attacks do little damage.

// Fortunately, as a game developer, you have full control over the world!

// Set Okar's properties to buff him up for ogre slaying!

// You can find default values for units on the doc panel.

game.addDefeatGoal();

game.addSurviveGoal();

var player = game.spawnPlayerXY("goliath", 12, 10);

// Increase the player's maxSpeed ( > 4), so he runs faster.

player.maxSpeed = 25;

// Increase the player's maxHealth ( > 500), so he lasts longer.

player.maxHealth = 2000;

// Increase the player's attackDamage ( > 7.68), so he can quickly take down

the ogres.

player.attackDamage = 99;

Level 13: Throwing Fire

Some game objects can be configured by setting their properties.

A "fire-spewer" shoots a bunch of fireballs!

By default it shoots them "horizontal"ly.

You can change it to shoot "vertical"ly like this:

Throwing Fire Solution

// Game objects can be configured by setting properties

// Don't change this, it sets up the game.

var player = game.spawnPlayerXY("knight", 40, 10);

game.addCollectGoal();

game.addSurviveGoal();

game.spawnXY("gem", 32, 55);

game.spawnXY("gem", 51, 55);

var fs1 = game.spawnXY("fire-spewer", 12, 25);

var fs2 = game.spawnXY("fire-spewer", 70, 30);

var fs3 = game.spawnXY("fire-spewer", 12, 35);

var fs4 = game.spawnXY("fire-spewer", 70, 40);

// Change fs1.direction to "vertical":

fs1.direction = "vertical";

// Now set fs2.direction to "vertical":

fs2.direction = "vertical";

// Do the same for fs3 and fs4:

fs3.direction = "vertical";

fs4.direction = "vertical";

// Now play the game and collect the gems!

Level 14: Them Bones

A "generator" is a building that spawns enemies every so often.

By default, the "generator" spawns "skeleton"s, a powerful enemy that will attack both humans and ogres!

But "skeleton"s have a weakness to "lightstone"s.

If the player picks up a "lightstone", skeletons will flee from the player, buying enough time to destroy the "generator".

Them Bones Solution

// Generators spawn enemies over time.

// Skeletons are afraid of lightstones.

var player = game.spawnPlayerXY("champion", 15, 35);

player.attackDamage = 60;

player.maxSpeed = 8;

game.addSurviveGoal();

game.addDefeatGoal();

// Spawn a "generator"

game.spawnXY("generator", 45, 35);

// Spawn a "lightstone"

game.spawnXY("lightstone", 25, 45);

// Now beat your game!

Level 15: Behavior Driven Development

You can change a unit's behavior by setting its behavior property.

skeleton3.behavior = "Scampers" will make the skeleton stored in the skeleton3 variable move around randomly.

skeleton3.behavior = "AttacksNearest" will attack the nearest enemy.

skeleton3.behavior = "Defends" will attack only if an enemy comes close.

skeleton3.behavior = "RunsAway" will make the unit run away from the player.

Make sure to pick the right variable, like skeleton3, ogre2, ogre3, or archer1!

Behavior Driven Development Solution

// Assign behaviors to units with the behavior property.

var skeleton1 = game.spawnXY("skeleton", 60, 48);

var skeleton2 = game.spawnXY("skeleton", 60, 30);

var skeleton3 = game.spawnXY("skeleton", 60, 12);

skeleton1.behavior = "Scampers";

skeleton2.behavior = "Scampers";

// Assign "Scampers" to skeleton3.behavior

skeleton3.behavior = "Scampers";

var ogre1 = game.spawnXY("ogre", 70, 50);

var ogre2 = game.spawnXY("ogre", 70, 30);

var ogre3 = game.spawnXY("ogre", 70, 10);

ogre1.behavior = "AttacksNearest";

// Assign "AttacksNearest" to ogre2.behavior

ogre2.behavior = "AttacksNearest";

// Assign "AttacksNearest" to ogre3.behavior

ogre3.behavior = "AttacksNearest";

var archer1 = game.spawnXY("archer", 14, 30);

// Assign "Defends" to archer1.behavior

archer1.behavior = "Defends";

// Don't need to change anything below here.

// But feel free to take a look!

var player = game.spawnPlayerXY("raider", 20, 30);

player.attackDamage = 10;

player.maxHealth = 9001;

game.addSurviveGoal();

game.addDefeatGoal();

game.spawnXY("forest", 40, 10);

game.spawnXY("forest", 40, 18);

game.spawnXY("forest", 40, 26);

game.spawnXY("forest", 40, 42);

game.spawnXY("forest", 40, 50);

game.spawnXY("forest", 40, 58);

game.spawnXY("lightstone", 30, 45);

game.spawnXY("lightstone", 30, 20);

game.spawnXY("lightstone", 30, 55);

game.spawnXY("lightstone", 30, 10);

game.spawnXY("potion-medium", 10, 50);

game.spawnXY("potion-medium", 10, 15);

Level 16: Time To Live

game.addSurviveGoal() sets up a goal for the player to survive until all other goals are complete.

You can pass an number as an argument like: game.addSurviveGoal(20) to configure it so that the player has to survive for 20 seconds.

Time To Live Solution

// Pass an argument to addSurviveGoal() to specify a time.

// This means the player must survive for 20 seconds.

game.addSurviveGoal(20);

// Spawn a generator with spawnXY

// Use the variable to configure the generator below.

var generator = game.spawnXY("generator", 60, 40);

// Set the generator's spawnType to "munchkin"

generator.spawnType = "munchkin";

// Use spawnPlayerXY to spawn a hero for the player.

var player = game.spawnPlayerXY("knight", 15, 15);

// Set the player's maxHealth to at least 100

player.maxHealth = 100;

// Set the player's attackDamage to at least 10

player.attackDamage = 10;

// Play the game!

Lesson 4: Changing Properties

Summary

This level is a blank slate. Encourage students to get creative with all the techniques they've learned throughout the course! The students should each design a game combining the game objects, goals, and mechanics they've learned in creative ways. The game should at least:

  1. Spawn a player.

  2. Add one or more goals for the player to complete.

  3. Use some combination of obstacles, enemies, collectables, and other pieces to create a fun challenge for the player.

Learning Objectives

  • Apply the tools and concepts introduced throughout the Game Development 1 Course to a creative game.

  • Explain in words the design decisions that led them to their specific program and game.

Level 17: Tabula Rasa

Now it's time to build your own game!

Be creative - combine all the commands you've learned into a fun mini-game.

When you're done, you can share your game with your friends and it will be posted on our website. Your game will also be judged by a representative from code combat.