Lesson 13 Activity 2



I am having some difficulty with this activity. I can set the animation to follow the mouse with a World.mouseX and World.mouseY, but the program draws multiple versions of the bee. When I try and copy the example information and use game.mouseX and game.mouseY I am told that the “game” identifier has not been declared.

Please advise.


When it is drawing multiple bees, was your “Background” block inside the draw loop? If it isn’t, it isn’t being redrawn after each bee so each move of the mouse will draw a new bee and not a new background. When you put the draw background inside the draw loop, it should redraw the background before checking for the new Mouse X and Mouse Y values.


Ahh! Exactly right. Thank you.

How about the fact that the Example Solution specs out “Game” instead of “World”…should that be changed?


So, I’m not a Javascript expert, but it looks like in their programming exemplar, they have used a class called Game rather than world. In our environment (and the students’ environment), they are supposed to use world as the class. Anyone more knowledgable about Javascript care to comment? This may be another “bug” to point out. I hadn’t looked at the exemplar solution before seeing your question and hadn’t noticed that.


This is actually a remnant from an older version of Game Lab, when the global object was Game. We switched the global object to World to encourage students to think more broadly about what they might make. We still support Game for backwards compatibility. I’ll update that exemplar and poke around to see if we have other old ones that need updated.


The “game” confused me up too… this is the solution I got

var bee = createSprite(200, 200);

World.frameRate = 20;

function draw(){

bee.x = randomNumber(World.mouseX - 50, World.mouseX + 50);
bee.y = randomNumber(World.mouseY - 50, World.mouseY + 50);




Your solution is fun because you get a little bit of random movement going but the bee still follows the movement of the mouse.


This helped! thank You!


Please do. And yes, there are more things to update. This is a little frustrating for us newbies who want to be sure we’re on the right track. :frowning: