# Using % in Game Lab

**URL:** <https://forum.code.org/t/using-in-game-lab/23588>\
**Category:** Unit and Lesson Discussion\
**Tags:** csd-unit-3, csd-unit-3-lesson-14\
**Created:** [December 18, 2018, 7:46pm UTC](https://forum.code.org/t/using-in-game-lab/23588 "2018-12-18T19:46:27Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sean.glantz](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@sean.glantz](https://forum.code.org/u/sean.glantz)\
**Post date:** [December 18, 2018, 7:46pm UTC](https://forum.code.org/t/using-in-game-lab/23588/1 "2018-12-18T19:46:27Z")

</div>

I have a student who is diving deep into her interactive card and she has me stumped! Can anyone offer help?

Does the % code work in gamelab? We are not sure if there is a bug in the code or if it is outside the scope of gamelab. I have included her description of the problem below:

I have a variable titled "time" that gets updated in this draw loop (time = time + 1;), and I want the sprite to change when the "time" variable is divisible by 5, using %.

if (time%5===0 && fire1.setAnimation("fire")) {

fire1.setAnimation("fire2");

fire2.setAnimation("fire2");

text("wow", 10, 390);

}

if (time%5 ===0 && fire1.setAnimation("fire2")) {

fire1.setAnimation("fire");

fire2.setAnimation("fire");

}

---

<div class="post-metadata">

**Author:** ![elizabeth\_admin](https://avatars.discourse-cdn.com/v4/letter/e/bb73d2/32.png) [@elizabeth\_admin](https://forum.code.org/u/elizabeth_admin)\
**Post date:** [December 18, 2018, 8:07pm UTC](https://forum.code.org/t/using-in-game-lab/23588/2 "2018-12-18T20:07:02Z")

</div>

Can you click the share link and paste the URL to the project here?

Also, what is the bug that she is experiencing?

---

<div class="post-metadata">

**Author:** ![sean.glantz](https://avatars.discourse-cdn.com/v4/letter/s/958977/32.png) [@sean.glantz](https://forum.code.org/u/sean.glantz)\
**Post date:** [January 7, 2019, 5:40am UTC](https://forum.code.org/t/using-in-game-lab/23588/3 "2019-01-07T05:40:40Z")

</div>

[https://studio.code.org/projects/gamelab/3A4R1jqSvUHHHqUFVJxcaHBFyWESJvMao-KSEutRc4g](https://studio.code.org/projects/gamelab/3A4R1jqSvUHHHqUFVJxcaHBFyWESJvMao-KSEutRc4g)

I’m not sure that I fully understand the bug, other than it did not work as she hoped. She said that she doesn’t think the % command works in game lab, but I am not familiar with what the % command does in javascript. I think she ended up working around it, so I do not believe this section of code is in her current program.

---

<div class="post-metadata">

**Author:** ![elizabeth\_admin](https://avatars.discourse-cdn.com/v4/letter/e/bb73d2/32.png) [@elizabeth\_admin](https://forum.code.org/u/elizabeth_admin)\
**Post date:** [January 7, 2019, 6:52pm UTC](https://forum.code.org/t/using-in-game-lab/23588/4 "2019-01-07T18:52:10Z")

</div>

Hi Sean,

The % operator does work in Game Lab, but it looks like she is trying to use the `setAnimation` method as a Boolean, which does not work. `setAnimation` will change a sprite’s animation, not return true or false depending on what its animation is.

Elizabeth
