# Pong

**URL:** <https://forum.kirupa.com/t/pong/9699>\
**Category:** Uncategorized\
**Created:** [December 16, 2002, 9:09pm UTC](https://forum.kirupa.com/t/pong/9699 "2002-12-16T21:09:06Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![BullDog\_Flash](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@BullDog\_Flash](https://forum.kirupa.com/u/BullDog_Flash)\
**Post date:** [December 16, 2002, 9:09pm UTC](https://forum.kirupa.com/t/pong/9699/1 "2002-12-16T21:09:06Z")

</div>

Ok i can mae the paddles and everthing else exept the one thing…

A ball

I need it o make i bounce off paddles and walls…

Any help

Becuase whn im done making my pong game ill change it to A Air Hocke game

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 16, 2002, 10:53pm UTC](https://forum.kirupa.com/t/pong/9699/2 "2002-12-16T22:53:33Z")

</div>

Check the gravity tutorial. You’ll find some explanation there.

pom :+)

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 16, 2002, 11:57pm UTC](https://forum.kirupa.com/t/pong/9699/3 "2002-12-16T23:57:09Z")

</div>

Ok i studied hard and set out to make a quick example.

Tutorial tought me…  
(1)How to make ball bounce  
(2)The floor area when to bounce…  
(3)I did not finish it yet.

I added  
(1)I added drawings  
(2) I made it so when it hits ground it will make Boping sound…

I will have to finish tutorial…

So ill see you soon…  
When im done tutorial i will show you the complete thing i did…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 17, 2002, 7:00am UTC](https://forum.kirupa.com/t/pong/9699/4 "2002-12-17T07:00:25Z")

</div>

Here is a paddle code that I use for my breaking blocks game… I think you might find it useful…

```php

if (_root.paddle.hitTest(_root.ball))
{
     dotx = _root.ball._x;
     padx = _root.paddle._x;

     xspeed = ((dotx - padx) / 10) * 2;
     yspeed *= -1;
}

```

This worked very well for a paddle that scrolled along the x axis… If you have paddles that move up and down howveer… Just change every instance of x you see in that code to a y and y to a x…

xspeed and yspeed are the speed that the ball is traveling… If you multiple it by -1… It will reverse it’s course… This works very very well 🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 17, 2002, 5:20pm UTC](https://forum.kirupa.com/t/pong/9699/5 "2002-12-17T17:20:55Z")

</div>

Thnaks marz that is helpful…Vvery…

But see iv’e been learning that tutorial on gravity and its super helpful.

All i need to basically do is the computer paddle first

I dont know how to…

well i have a hitTest but it wont work…

Ill show you…

```php
onClipEvent (load) {
    gravity = 1;
    bounce = 1;
    speedx = 29;
    speedy = 10;
    speedyy = 10;//I added this
}
onClipEvent (enterFrame) {
    speedy = speedy+gravity;
    this._y -= speedyy/5;//And this
    this._x += speedx/45;
    this._y += speedy/5;
    if (this.hitTest(_root.paddle)) {
        speedy *= -bounce;
        if (this.hitTest(_root.com)) {//Then this
            speedyy *= -bounce;
        }
    }
}
{

```

Those re the only things i added to try making a computer paddle actually allow the ball to bounce…

But he doesent sem to coaparate

Maybe somOne can help…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 17, 2002, 5:34pm UTC](https://forum.kirupa.com/t/pong/9699/6 "2002-12-17T17:34:02Z")

</div>

Easy man… Lower your x and y speeds down!

Hehe… The ball is jumping OVER the paddle and therefore isn’t technically hitting it… Make them around 4 or 5… And then make your frames per second somewhere around 40…

Faster frames per second with lower pixel rates… Will make for a very smooth game…

I’ll take another look at the code in a little while… But that is the first thing you might wanna change…

Peace

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 17, 2002, 5:48pm UTC](https://forum.kirupa.com/t/pong/9699/7 "2002-12-17T17:48:18Z")

</div>

Thnkas i have lowered the pixel speed and raised the FPS  
But nuttin changed

So ill give the fla.Since its only a learning FLA

And here you go…

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 17, 2002, 9:23pm UTC](https://forum.kirupa.com/t/pong/9699/8 "2002-12-17T21:23:28Z")

</div>

Any one

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [December 18, 2002, 8:29pm UTC](https://forum.kirupa.com/t/pong/9699/9 "2002-12-18T20:29:40Z")

</div>

Yeah sorry… Was off looking for jobs yesterday and ended up passing out before checking out any tuts or anything…

Umm… I’ll download the .fla and gte back to you man.

Peace
