# Bounce off edge?

**URL:** <https://forum.code.org/t/bounce-off-edge/34726>\
**Category:** Coding and Debugging Help\
**Tags:** csd-unit-3\
**Created:** [May 17, 2021, 3:23pm UTC](https://forum.code.org/t/bounce-off-edge/34726 "2021-05-17T15:23:04Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![GordonBrune](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/gordonbrune/32/4752_2.png) [@GordonBrune](https://forum.code.org/u/GordonBrune)\
**Post date:** [May 17, 2021, 3:23pm UTC](https://forum.code.org/t/bounce-off-edge/34726/1 "2021-05-17T15:23:04Z")

</div>

I have a student who is beginning to design her game. She wants the “player” sprite to bounce off the edge of the background. We know how to make a sprite bounce off another sprite but can we code a bounce off the edge of the screen\background. She worked around it by coding conditions for the x and y locations and changing the velocity depending on its location but we’re still wondering about coding a bounce off the edge of the background. Here is what she has so far:

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

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![mwood](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/mwood/32/4941_2.png) [@mwood](https://forum.code.org/u/mwood)\
**Post date:** [May 17, 2021, 3:29pm UTC](https://forum.code.org/t/bounce-off-edge/34726/2 "2021-05-17T15:29:44Z")

</div>

@GordonBrune,

Have them look at the documentation for the createEdgeSprites block.

[https://studio.code.org/docs/gamelab/createEdgeSprites/](https://studio.code.org/docs/gamelab/createEdgeSprites/)

I think this is what they are after.

Mike

---

<div class="post-metadata">

**Author:** ![GordonBrune](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.code.org/gordonbrune/32/4752_2.png) [@GordonBrune](https://forum.code.org/u/GordonBrune)\
**Post date:** [May 17, 2021, 4:37pm UTC](https://forum.code.org/t/bounce-off-edge/34726/3 "2021-05-17T16:37:45Z")

</div>

Thanks so much. I will show her.
