# Little bug

**URL:** <https://forum.makecode.com/t/little-bug/503>\
**Category:** Arcade\
**Created:** [August 31, 2019, 5:51pm UTC](https://forum.makecode.com/t/little-bug/503 "2019-08-31T17:51:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![TomisOps](https://avatars.discourse-cdn.com/v4/letter/t/e9a140/32.png) [@TomisOps](https://forum.makecode.com/u/TomisOps)\
**Post date:** [August 31, 2019, 5:51pm UTC](https://forum.makecode.com/t/little-bug/503/1 "2019-08-31T17:51:45Z")

</div>

let mySprite = sprites.create(img`. . . . . . . . . . . c c c c c 6 6 6 6 6 . . . . . . . . . . . . . . . . . . . c c c 4 4 4 4 4 4 4 4 4 4 6 6 6 . . . . . . . . . . . . . . c c 4 4 4 4 4 4 4 4 4 b b 4 4 4 4 4 6 6 . . . . . . . . . . . c b 4 4 4 4 b b 4 4 4 4 b 5 b 4 4 4 4 4 4 b . . . . . . . . . e b 4 4 4 4 b 5 b 4 4 4 4 4 b 4 4 4 4 4 4 4 4 b . . . . . . . e b b 4 4 4 4 4 b 4 4 4 4 4 4 4 4 4 4 b 4 4 4 4 4 6 . . . . . e b 6 b b 4 4 4 4 4 4 4 4 4 b b 4 4 4 b 5 b 4 4 4 4 4 6 . . . . e 6 b b 5 b 4 4 4 4 4 4 4 4 b 5 b 4 4 4 b 4 4 b b 4 4 e . . . e 6 6 b 4 b 4 4 4 4 4 4 4 4 4 4 b 4 4 4 4 4 4 4 b 5 b 4 4 e . . e 6 b b 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 b b 4 4 e . e b 6 6 b 4 4 4 4 4 b b 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 b e e b 6 6 b b 4 4 4 b 5 b 4 4 4 4 4 4 4 4 b b 4 4 4 4 4 4 4 4 b e f b 6 6 6 b 4 4 4 b b 4 4 4 4 4 4 4 4 4 b 5 b 4 4 4 4 4 4 4 b f f c b 6 6 6 b 4 4 4 4 4 4 4 4 4 4 4 4 4 4 b b 4 4 4 4 4 4 b c f . f b b 6 6 6 6 b 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 b f . . e f b b 6 6 6 6 6 b b 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 b f e . . 8 6 f c b b 6 6 6 6 6 b b b 4 4 4 4 4 4 4 4 4 4 4 b c c 6 8 8 8 7 7 2 e f f c b b b b b b b b b b b b b b b b c f c 2 2 7 7 8 8 7 7 2 2 2 2 2 c c c c c c c c c c c c c c c c 2 2 2 2 6 6 7 8 f 8 6 6 6 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 7 6 6 8 6 f f e f 8 6 6 6 7 7 7 6 6 6 6 7 7 7 7 7 7 6 6 6 7 7 7 7 f f f e f f b f f 8 7 7 7 6 8 f 8 6 7 7 7 7 7 7 6 6 6 7 7 6 f f f f f b f f b e f f e e f f f e f f 7 7 6 6 6 8 8 e f f e e e e f e b 6 f f 6 b f f f e f f e e e e e e e e e e e e e f e e e e e b b 6 e f 6 6 d d f f f f f e e e f f e f f e e e e e f f e e d b 4 6 e . c 6 6 d d d 4 e f f f f f f e e e e e f f f f 4 d d b 4 6 e . . f c 6 b 4 d d d d d d d d d d d d d d d d d d d b 4 4 4 e e . . . f f 6 b b 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 e e . . . . . . f f b b b b 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 e e . . . . . . . . . . f f e b b b b b b 4 4 4 4 4 4 4 4 e e e . . . . . . . . . . . . . . . f f f f f f f c c c c c e e . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .`, SpriteKind.Player)  
let velx = 40  
let vely = 60  
mySprite.vx = velx  
mySprite.vy = vely  
mySprite.setFlag(SpriteFlag.StayInScreen, false)  
forever(function () {  
if (mySprite.x \>= 110) {  
vely = mySprite.vy \* -1  
velx = mySprite.vx \* 1  
mySprite.vx = velx  
mySprite.vy = vely  
}  
})

What im trying to do is change the sprites direction after it hits the bottom of the screen (trying to recreate it without using the bounce on wall thingy) but it bugs out, the sprite starts to shake, any help? thanks

---

<div class="post-metadata">

**Author:** ![mmoskal](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/mmoskal/32/20_2.png) [@mmoskal](https://forum.makecode.com/u/mmoskal)\
**Post date:** [August 31, 2019, 6:06pm UTC](https://forum.makecode.com/t/little-bug/503/2 "2019-08-31T18:06:51Z")

</div>

Your sprite gets over the edge, you flip the direction, it flies a tiny little bit but not enough to cross the edge, and you flip it again.

Only flip vy if it’s positive.

---

<div class="post-metadata">

**Author:** ![TomisOps](https://avatars.discourse-cdn.com/v4/letter/t/e9a140/32.png) [@TomisOps](https://forum.makecode.com/u/TomisOps)\
**Post date:** [August 31, 2019, 6:09pm UTC](https://forum.makecode.com/t/little-bug/503/3 "2019-08-31T18:09:15Z")

</div>

I understand what you mean, but i still dont get how i could fix it, could your provide me with an example? thank you

---

<div class="post-metadata">

**Author:** ![AlexK](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/alexk/32/33339_2.png) [@AlexK](https://forum.makecode.com/u/AlexK)\
**Post date:** [August 31, 2019, 6:47pm UTC](https://forum.makecode.com/t/little-bug/503/4 "2019-08-31T18:47:59Z")

</div>

Focus on the following line:

```auto
if (mySprite.x >= 110) {

```

Change it to a compound conditional (i.e. use &&) and only change values if `mySprite.x` is in the turnaround zone _and_ `mySprite.vx` is positive.

You also have

```auto
velx = mySprite.vx * 1

```

I’m thinking you have a typo there.

---

<div class="post-metadata">

**Author:** ![TomisOps](https://avatars.discourse-cdn.com/v4/letter/t/e9a140/32.png) [@TomisOps](https://forum.makecode.com/u/TomisOps)\
**Post date:** [August 31, 2019, 7:15pm UTC](https://forum.makecode.com/t/little-bug/503/5 "2019-08-31T19:15:48Z")

</div>

Thank you!, just what i needed.
