Check out a free preview of the full Build a Game Project: Feed-A-Star-Mole course

The "Hungry Interval" Lesson is part of the full, Build a Game Project: Feed-A-Star-Mole course featured in this preview video. Here's what you'd learn in this lesson:

Brian codes a function that causes the moles to be hungry for a stretch of time.

Preview
Close

Transcript from the "Hungry Interval" Lesson

[00:00:00]
>> Speaker 1: So let's go define our hungry interval.
>> Speaker 1: Function, get hungry interval. So how long should we give our users, like the how long of a window should they have to get there, clicking?
>> Speaker 2: Two to five seconds.
>> Speaker 1: That's pretty good. I think I had in here just two seconds, but if you want to do two to five.

[00:00:29]
>> Speaker 1: Yeah, let's do that. That sounds fun to me. +Math.floor(Math.random) times 3,000 + 2000.
>> Speaker 1: Right, this will give us two to five seconds.
>> Speaker 1: Cuz this will be a number of between zero and 3,000 and this will always be 2,000, right? So you will get anywhere from 2,000 to 5,000.

[00:01:13]
>> Speaker 1: Now we have, where are we? GetHungryInterval, that's gonna be good.
>> Speaker 1: Last thing up here is we need a break. We're gonna do case hungry, which is our last case.

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