Programming for Game Designers, Part 2

Professor Ira Fay
Class 9
•
•
Game Guru
Programming for Game Designers

Observe
 Rules of the game
 Scoring
 Characters
 Animations
 Audio
 User interface
 Anything at all!
Average Value
 Game Guru: 4 (one person gave it a 1)
 Get to Know Hampshire: 2.6
 Dice: 3.8

Dice Hours Spent: 10.4




Install Dropbox (or something similar)
Find an interesting professor
Check out a boardgame from the library
Find a CEL-1 activity



Game Guru
In-class playtests
Dice project



Length of Dice project (too long)
In-class playtests
Nothing


Didn’t need help (9)
I have attended TA hours (4)

Due today! How many people completed it?
 Website
 Roll 1d6
 Pick one of the game options

What game option did you pick?



With a growth mindset, we can improve our
skills through practicing.
Learning happens over time, not instantly.
The process of learning is uncomfortable
when we’re not competent yet.

Lines of code are executed in order

= is an assignment operator

Programming is typo-intolerant
 You have to say the magic words exactly right
for the spell to work!

Variables hold information

Variables can change value while the
program is executing

Example
 $myRoll

Methods are like a factory:
 They take input, and spit out results

Example
 rand(1, 6);

+=

//

if ()

for ()
$totalScore = 0;
$myRoll = rand(1, 6);
$totalScore = $totalScore + $myRoll;
$totalScore = 0;
$myRoll = rand(1, 6);
$totalScore += $myRoll;
// Player starts with a score of 0
$totalScore = 0;
// Roll 1d6
$myRoll = rand(1, 6);
// Add the roll to the score
$totalScore += $myRoll;
// Player starts with a score of 0
$totalScore = 0;
// Roll 1d6
$myRoll = rand(1, 6);
// if the roll is greater than 4
if ($myRoll > 4) {
// Add the roll to the score
$totalScore += $myRoll;
}
> means greater than
< means less than
>= means greater than or equal to
<= means less than or equal to
== means equal
!= means not equal
Remember that = is an assignment operator!
How could I display the numbers 1 to 9?
How could I display the numbers 1 to 9?
echo
echo
echo
echo
echo
echo
echo
echo
echo
“1”;
“2”;
“3”;
“4”;
“5”;
“6”;
“7”;
“8”;
“9”;
How could I display the numbers 1 to 99?
1 to 999?
// Count from 1 to 9
for ($i = 1; $i < 10; $i += 1) {
echo $i;
}
// We could also use a while() loop
$i = 1;
while ($i < 10) {
echo $i;
$i += 1;
}
// Count from 1 to 99
for ($i = 1; $i < 100; $i += 1) {
echo $i;
}
// We could also use a while() loop
$i = 1;
while ($i < 100) {
echo $i;
$i += 1;
}
// Count from 1 to 999
for ($i = 1; $i < 1000; $i += 1) {
echo $i;
}
// We could also use a while() loop
$i = 1;
while ($i < 1000) {
echo $i;
$i += 1;
}

For the rest of this unit, we’ll have ample lab
time in class. Bring your computer!

Lisette: Kai S, Ben, Truman, Dakari
Meghan: Kai M, Grace, Zack
Gabriella: Helena, Ethan, Joel
George: Quinn, Bryan, Max



Read the syllabus to know what to do!
 Programming for Game Designers Part 2 due Weds
 Get to Know Hampshire project ongoing
Game Guru: Pick a game to show next class, submit written analysis before class