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.

Newcomers DBPro Corner / Pong clone

Author
Message
Mizipzor
20
Years of Service
User Offline
Joined: 24th May 2004
Location: Sweden
Posted: 28th Sep 2004 23:43
Im making a game quite similar to pong using the stickied tutorial.

The basic pong was very easy. I decided to add a second "paddle" to each player. So both players has two paddles . Also I added sound.

You see in the code that the sound plays when the ball hit the paddle. If it is currently playing it wont start a new sound.

The problem here is that when the ball hits one side of one of the front paddles, the side facing outwards, the sound doesnt play. I havent got clue why.

Also another thing. The ball can get "stuck" onto the paddle. This
occurs when the paddle runs into the ball and not the ball hits the paddle. Cause there is this "zone" in which the ball bounces back. Normally the ball goes into the zone and bounce back but when the paddle and the zone places itself ontop of the ball... things go wrong. Ideas how to fix this?

Btw, to run the game you need to place wav file in the project folder and include it. "Blip.wav". Just make a new file, it can be empty. But if you want to help me out on the sound part it should be something that you can hear .

Thats it for now... thanks in advance! ;D
Mizipzor

Dreaming of creating a highly advanced AI mind
Ric
20
Years of Service
User Offline
Joined: 11th Jul 2004
Location: object position x
Posted: 29th Sep 2004 05:49
I've only had a quick look, but....

Firstly, the sound not playing seems odd. I replaced the sound with the text "HIT" when it collides, (as I couldn't be bothered setting up a sound file for it), and it works every time. I can only think that perhaps your sound has some 'silence' at the end of the wav, meaning it is still playing even though you can't hear anything, and the 'if sound playing(1)=0' section is preventing it from playing. My suggestion; get rid of the 'if sound playing' bit and see if it works.

Secondly, the ball getting embedded problem. The ball will change direction (or apply screw in your game) if the ball is in the collision zone - even if it has just changed on the previous sync. So long as it stays in the collision zone, it will keep changing direction and applying screw endlessly.

One solution is to move the ball in the code out of the collision zone when it hits. In your case, that wouldn't be quite so easy as normal pong, because you'd need to determine which way the ball was coming from in order to know which side of the paddle to move it.

The other solution - probably a bit simpler in your case, is to give each paddle a collision flag, ie. ball_just_hit_paddle_3 = 1. Then only allow a collision if it's flag is zero. (Don't forget, each time it collides with a paddle, to make sure you reset the flags for the other three paddles to zero).

Ah hell - I'm bored... I'll show you......



Hope that helps.


Login to post a reply

Server time is: 2024-09-23 01:25:59
Your offset time is: 2024-09-23 01:25:59