Check out a free preview of the full Get Kids into Coding with Scratch course

The "Adjusting the Difficulty" Lesson is part of the full, Get Kids into Coding with Scratch course featured in this preview video. Here's what you'd learn in this lesson:

Steve adjusts the game difficulty by creating an enemy clone every three points instead of every point.

Preview
Close

Transcript from the "Adjusting the Difficulty" Lesson

[00:00:00]
>> Cool. So like we've got a bunch of those kind of pieces in place. And we can have that there. Like there are other ways that we can do this. Now, we said before, what if the game only got faster every like 10 points or something like that, or every five points.

[00:00:19]
Every three points, right? And so we need a way to figure out. What we should do in this case, right? And so we need some math to be like every three times, right? And this is there is a thing that we can use, and it's called the modulo.

[00:00:37]
Check this out. And so modulo, it's kinda like division, but it tells you how many numbers are leftover, right? So for instance, how many times does three go into six? Two. What's the remainder?
>> Three [INAUDIBLE].
>> Right, cause it goes into there's nothing left over. How many times does two go into seven or three go into seven?

[00:01:04]
>> Two.
>> Two, and what's leftover?
>> One.
>> One and so the module in that case would be one. So we know that zeros every third time, right and so we could say, for any of the logic here, right? For like the creating a clone, see I started writing code inside Evad.

[00:01:26]
We could say only create a clone every time the score had some multiple of three right and so we could do is I say if, Let's do equals, If the score, Module three, nope. I put my module away. It's a score, module three. Zero, which means it's either 3, 6, 9, 12, so on and so forth.

[00:02:18]
Then, we'll create a clone of Evad. Let's try it out. I'm taking off that edge mechanic. I'm not doing it anymore, I'm not living like this. Evad's the problem, not the edge. All right, so we got one taco. We got two tacos. We get three tacos. I don't see any Evad.

[00:02:54]
>> Equals 50.
>> Did I not change it cuz I was too busy moving stuff around?
>> Yeah.
>> So I had to get, equals zero. It'll never equal 50 cuz you will never get 50 left over. Did my code do what I wanted it to? No, did it do what I told it to do?

[00:03:11]
Yes, it did. All right, one, So they chase only when they get close, and they come in one every three times, right? So we've got a game, this game works. There's a ton of ways you can improve. You can have the speed go on a module as well.

[00:03:34]
You can do a lot of things like a little bit right here, there's a lot of ways that you can expand this game and you totally should.

Learn Straight from the Experts Who Shape the Modern Web

  • In-depth Courses
  • Industry Leading Experts
  • Learning Paths
  • Live Interactive Workshops
Get Unlimited Access Now