If (winter storm warning)
{
let students go an hour early
}
Stupid weather. Barely 3 inches of snow, and none happened till much later! Still, when you’re teaching at night and you see a giant blue blob of snow on the radar map, well, you cut everyone out early. Still, I battled on for over 2 hours, so they could try their hand at some simple comparisons complete with score keeping!
It’s fairly simple, and runs on 57 lines of code (49 if you don’t count empty lines)! And some of those lines weren’t actually used (set-up for some extra stuff we never got to). In this, I tried to show how variables interact and change based on conditions set. The values of money above each character’s head changes based on variables set based on which face gets clicked on.
Then the faces change based on a comparison of the money amounts. So every time a face gets clicked, the money amounts change and are checked. If Bob’s got more money, he gets all smug. When Bob has less, he gets mad.
It’s all taken care of in a bitty function called checkForJerk.
function checkForJerk():void
{
if (bobsMoney > myMoney)
{
me.gotoAndStop(2);
bob.gotoAndStop(2);
}
else if (myMoney > bobsMoney)
{
me.gotoAndStop(1);
bob.gotoAndStop(3);
}
else
{
me.gotoAndStop(1);
bob.gotoAndStop(1);
}
}
I’m sure this could have been done easier with a switch/case format, but let’s get through the basics first, shall we?
Oh, and in case you didn’t notice, yes, I appropriated little troll faces for fun – no idea who made them, but if I knew, I’d give credit where it’s due.