Bug in Student Game

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?

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.