# Few questions

**URL:** <https://forum.kirupa.com/t/few-questions/315536>\
**Category:** Uncategorized\
**Created:** [October 28, 2010, 9:22am UTC](https://forum.kirupa.com/t/few-questions/315536 "2010-10-28T09:22:39Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sykez](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@Sykez](https://forum.kirupa.com/u/Sykez)\
**Post date:** [October 28, 2010, 9:22am UTC](https://forum.kirupa.com/t/few-questions/315536/1 "2010-10-28T09:22:39Z")

</div>

I’m making my first flash game which is a keep it up football game.  
Link to the game: [http://www.newgrounds.com/dump/item/71fd23146ce741a9e01ef89ef41f6e53.I](http://www.newgrounds.com/dump/item/71fd23146ce741a9e01ef89ef41f6e53.I) got a script of a tutorial but when you click the football it keeps going of the screen and I want to keep it in. here is the script for the ball[URL=“[Keep it up game](http://www.newgrounds.com/dump/item/71fd23146ce741a9e01ef89ef41f6e53)”]:

> onClipEvent (load) {  
> ySpeed = 0;  
> gravity =2;  
> bounce = .7;  
> ground = 355;  
> }

onClipEvent (enterFrame) {  
if (\_y\<ground) {  
ySpeed += gravity;  
} else if (ySpeed\>gravity\*4) {  
\_y = ground;  
ySpeed \*= -bounce;  
} else {  
ySpeed = 0;  
\_y = ground;  
}  
\_y += ySpeed;  
}

onClipEvent (enterFrame) {  
if (\_x\<0 || \_x\>550) {  
xSpeed \*= -1;  
}  
\_x += xSpeed;  
xSpeed \*= .95;  
}

onClipEvent (mouseDown) {  
if (hitTest(\_root.\_xmouse, \_root.\_ymouse, true)) {  
xSpeed = (\_x-\_root.\_xmouse)/2;  
\_y–;  
ySpeed = (\_y-\_root.\_ymouse-\_height)/1.5;  
}  
}

So, How should I modify it to keep it in the screen?

Also, I have rectangle that is the ground and the ball keeps going under/over it how can I make it so that the ball is just on top and when it bounces back down that it doesn’t go under the block.
