# Game Lab Unit 3 Lesson 14

**URL:** <https://forum.code.org/t/game-lab-unit-3-lesson-14/26148>\
**Category:** Coding and Debugging Help\
**Tags:** csd-unit-3-lesson-14\
**Created:** [April 5, 2019, 6:18pm UTC](https://forum.code.org/t/game-lab-unit-3-lesson-14/26148 "2019-04-05T18:18:57Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pomerjul](https://avatars.discourse-cdn.com/v4/letter/p/df788c/32.png) [@pomerjul](https://forum.code.org/u/pomerjul)\
**Post date:** [April 5, 2019, 6:18pm UTC](https://forum.code.org/t/game-lab-unit-3-lesson-14/26148/1 "2019-04-05T18:18:57Z")

</div>

I have a student who has the animation created for sonic the hedge hog but then when he sees it in game lab it doesn’t appear to be moving like it shows it is in the animation tab. What is he doing wrong?

> **[Check out what I made](https://studio.code.org/projects/gamelab/eckxhAgu5BEkrxtI98D1jD2K9Vw4dAxnL8v8DRXS5W8)**
>
> I wrote the code myself with Code.org

---

<div class="post-metadata">

**Author:** ![bradleywellsashley](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/bradleywellsashley/32/522_2.png) [@bradleywellsashley](https://forum.code.org/u/bradleywellsashley)\
**Post date:** [April 6, 2019, 3:49pm UTC](https://forum.code.org/t/game-lab-unit-3-lesson-14/26148/2 "2019-04-06T15:49:42Z")

</div>

Ms. Pomerenke,

Great question, First all the setup for the level (background and sonic sprite creation) needs to be done outside of the draw loop, otherwise it’s creating a new one each time. So the only blocks of code you should have in the `draw()` loop is the `if` statement, `sonic.setAnimation` and `sonic.scale`. Once that is done, sonic does change to the gif version for a brief while, but then stops - so still not answering your question completely, but getting closer (problem solving steps!).

As for the gif of Sonic, I’m asking the developers because I know that gifs haven’t been supported in the past, but I’m curious as to why this sonic gif seems to work just briefly. Hopefully we’ll get an answer before school on Monday!

Brad

---

<div class="post-metadata">

**Author:** ![pomerjul](https://avatars.discourse-cdn.com/v4/letter/p/df788c/32.png) [@pomerjul](https://forum.code.org/u/pomerjul)\
**Post date:** [April 9, 2019, 6:10pm UTC](https://forum.code.org/t/game-lab-unit-3-lesson-14/26148/3 "2019-04-09T18:10:04Z")

</div>

Thanks for the reply. It shouldn’t be a gif as he created images in the animation tab and over layed them to show movement. I didn’t look obviously at the draw loop so that fixed it somewhat like you said. Any further help will be much appreciated.

---

<div class="post-metadata">

**Author:** ![edavis](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/edavis/32/4927_2.png) [@edavis](https://forum.code.org/u/edavis)\
**Post date:** [April 10, 2019, 10:13pm UTC](https://forum.code.org/t/game-lab-unit-3-lesson-14/26148/4 "2019-04-10T22:13:12Z")

</div>

It looks to me that Sonic just needs to be moved along with changing the way he looks when hitting the right arrow. His x position would need to be added to for every press of the right arrow along with the change in animation. I don’t know much about the .gif files either though. I’ll share this with the powers that be to see if they might have some ideas for you though.

---

<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:** [April 15, 2019, 6:45pm UTC](https://forum.code.org/t/game-lab-unit-3-lesson-14/26148/5 "2019-04-15T18:45:36Z")

</div>

Hi, were you able to get this to work? In the linked version, I still see everything being set up in the draw loop, so I’m not sure whether the student is working on a different draft.

Thanks,  
Elizabeth

---

<div class="post-metadata">

**Author:** ![pomerjul](https://avatars.discourse-cdn.com/v4/letter/p/df788c/32.png) [@pomerjul](https://forum.code.org/u/pomerjul)\
**Post date:** [April 15, 2019, 7:43pm UTC](https://forum.code.org/t/game-lab-unit-3-lesson-14/26148/6 "2019-04-15T19:43:03Z")

</div>

No, I have changed everything in the code up to that it still only spins once…Here is an uploaded share  
[https://studio.code.org/projects/gamelab/u7n4F6rPGB10TR52lk1i6pXlWAFrKxTPzFqstzDLL6U](https://studio.code.org/projects/gamelab/u7n4F6rPGB10TR52lk1i6pXlWAFrKxTPzFqstzDLL6U)

---

<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:** [April 16, 2019, 5:00am UTC](https://forum.code.org/t/game-lab-unit-3-lesson-14/26148/7 "2019-04-16T05:00:37Z")

</div>

The reason that sonic isn’t animating when he runs is because the sprite is getting its animation reset every time the draw loop runs while the right key is being held down. That means that it’s only showing the first frame of the animation every time. The student needs to set the animation only once when the key first goes down. They will probably need more than one conditional.

Elizabeth
