# Bug in Student Game

**URL:** <https://forum.code.org/t/bug-in-student-game/15803>\
**Category:** Unit and Lesson Discussion\
**Tags:** csd-unit-3, csd-unit-3-lesson-22\
**Created:** [April 25, 2018, 3:53pm UTC](https://forum.code.org/t/bug-in-student-game/15803 "2018-04-25T15:53:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kbell](https://avatars.discourse-cdn.com/v4/letter/k/49beb7/32.png) [@kbell](https://forum.code.org/u/kbell)\
**Post date:** [April 25, 2018, 3:53pm UTC](https://forum.code.org/t/bug-in-student-game/15803/1 "2018-04-25T15:53:57Z")

</div>

My student programmed his player sprite “dva” to collide with the platform. However, once the sprite is on top of platform or to the right of it and then tries to move away it continues moving the right. I have tried to remix the game myself and compared it to the code for the platform game but I am not seeing what could be causing the issue. Has anyone else come across this issue or know how to solve it?

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

---

<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 26, 2018, 12:05am UTC](https://forum.code.org/t/bug-in-student-game/15803/2 "2018-04-26T00:05:49Z")

</div>

Hi Kanjana,

The issue is with how the `collide` block works. In Game Lab, `sprite.collide(target)` will cause the sprite to take on the target’s velocity. Right now, the dva sprite is taking on the platform sprite’s velocity of 2.5 when it collides with the platform. (The student also has the problem of using collide in both directions - lines 87 & 88 should be deleted - but that’s irrelevant with the following change.)

The student should instead use the `displace` block, which doesn’t change the velocity of either of the sprites, only moves their positions while they are touching. For this, the platform should displace the dva sprite with the code `platform.displace(dva)`

This should keep the dva sprite from moving right after it’s no longer touching the platform.

There’s a lot of background that went in to making the blocks work this way. It was really hard to find something that would work for a bunch of different types of games, so there are some subtleties to them that can sometimes cause unexpected things to happen.

Elizabeth
