Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Please solve my Pong problem!

Author
Message
FieldDoc
23
Years of Service
User Offline
Joined: 30th May 2003
Location: London, UK
Posted: 6th Jun 2003 02:32 Edited at: 6th Jun 2003 02:34
I've almost finished making a very simple Pong clone to help teach me about sprites. Everything is working OK except when the ball collides with the paddle (it's OK when it collides with the border).
The problem is that it seems to stick to the paddle before being released! The code is below....please try it and you'll see!

EDIT: Also, what's with the smearing of the ball and paddle when they move?

Life is like a penis:
When it's soft you can't beat it, when it's hard you get screwed.
Andy Igoe
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United Kingdom
Posted: 6th Jun 2003 02:54
Just had a mommentary play and my immediate thoughts to your two problems:

1) Smearing
This is the cathode ray tube on your monitor. You are displaying an area of extreme contrast and moving it, the tube takes time to react - the spead of reaction (and therefor the amout of smearing) will depend on the quality of your CRT (monitor).

2) Ball Sticking
The ball is colliding, then it is colliding again, then again and then again.

Either reposition the ball after a collision so that it cannot redetect the collision, or use a variable to hold which bat was hit last and check against it every collision to ensure the same bat doesn't perform two hits in a row.

Pneumatic Dryll
FieldDoc
23
Years of Service
User Offline
Joined: 30th May 2003
Location: London, UK
Posted: 6th Jun 2003 03:33
Thanks PD....that's two things you've helped me out with 2nite. Careful, you'll get a good rep!


Life is like a penis:
When it's soft you can't beat it, when it's hard you get screwed.
Andy Igoe
23
Years of Service
User Offline
Joined: 6th Oct 2002
Location: United Kingdom
Posted: 6th Jun 2003 03:50 Edited at: 6th Jun 2003 03:51
I'll just have to duff you over a bit...

Pneumatic Dryll
Jammy
23
Years of Service
User Offline
Joined: 15th Jan 2003
Location: Scotland
Posted: 6th Jun 2003 06:55 Edited at: 6th Jun 2003 06:56
here is your code - with a function made by Ian M

and posted here

http://www.darkbasicpro.com/apollo/view.php?t=5209&b=4

seems to fix the problem

also you should look at player 2s movement - it affects player 1 and the keys are crap

Jammy
23
Years of Service
User Offline
Joined: 15th Jan 2003
Location: Scotland
Posted: 6th Jun 2003 07:07
woops

silly me

i used the function wrong - but this works now

it does

i not tell a lie

sorry

FieldDoc
23
Years of Service
User Offline
Joined: 30th May 2003
Location: London, UK
Posted: 6th Jun 2003 23:58 Edited at: 7th Jun 2003 00:00
Have solved most of the problems. Thanks guys. I got round the collision crap simply by making the paddles thinner (i'm sooo lazy!). However, take a look at the end of the source code (just after the ENDWHILE statement). How come the program doesn't display the message I want it to? Instead, it just waits for the user to press a key and then ends.

BTW, Player 1 keys are up and down arrows whilst player 2 keys are 8(up) and 2(down). First to 3

EDIT: Never mind......just needed to add an extra sync after the text is printed!

Life is like a penis:
When it's soft you can't beat it, when it's hard you get screwed.

Login to post a reply

Server time is: 2026-07-12 00:07:38
Your offset time is: 2026-07-12 00:07:38