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 / My PONG -- Need Help

Author
Message
Inkybro
23
Years of Service
User Offline
Joined: 31st Dec 2002
Location: Where I live :)
Posted: 4th Nov 2003 17:47
How to use the RND command to when the ball bounces off a wall or bat? I couldn't find RND in the help menu, so if you can give me the syntax I think I can figure it out

Thanks.

Inkybro
23
Years of Service
User Offline
Joined: 31st Dec 2002
Location: Where I live :)
Posted: 4th Nov 2003 18:12
Also, I got the ball bouncing good enough but how do I make it move at a constant rate?

Here's my code.



Inkybro
23
Years of Service
User Offline
Joined: 31st Dec 2002
Location: Where I live :)
Posted: 4th Nov 2003 18:19
Also (yep another question), on these Text Commands, how can I get them to display what I want without geting an error?



Inkybro
23
Years of Service
User Offline
Joined: 31st Dec 2002
Location: Where I live :)
Posted: 4th Nov 2003 18:26
Inkybro
23
Years of Service
User Offline
Joined: 31st Dec 2002
Location: Where I live :)
Posted: 4th Nov 2003 18:32
Is my question THAT hard to answer? lol..

TheOneRing
22
Years of Service
User Offline
Joined: 28th Aug 2003
Location: Right here.
Posted: 4th Nov 2003 18:40
If I remember correctly, the random statement is RND(MaxNumber). It will return a value between 0 and the MaxNumber.
Inkybro
23
Years of Service
User Offline
Joined: 31st Dec 2002
Location: Where I live :)
Posted: 4th Nov 2003 18:42
Sounds about right, I got it turning though. How can I keep the ball moving?

Inkybro
23
Years of Service
User Offline
Joined: 31st Dec 2002
Location: Where I live :)
Posted: 4th Nov 2003 18:47
I got the ball moving, can ANYONE tell me how to get the scores displayed?

TheOneRing
22
Years of Service
User Offline
Joined: 28th Aug 2003
Location: Right here.
Posted: 4th Nov 2003 18:50 Edited at: 4th Nov 2003 18:51
Your position variables for a sprite need to be integers, not floats (pretty sure, anyway). So instead of plybatx#, use plybatx. Also, the text command... try



And be patient!!
Shadow Lord
22
Years of Service
User Offline
Joined: 26th Sep 2003
Location:
Posted: 4th Nov 2003 18:53
Quote: "How to use the RND command "

Var=RND(number) `where number is the highest integer you wish to return.

Quote: "Also (yep another question), on these Text Commands, how can I get them to display what I want without geting an error?

text 400,10,"Player 1: ",scr1#
"


scr1# is an Integer, and the 'Text' command can print only strings. So you have to change your convert your integer to a string for the text command to work, like so...

text 400,10,"Player 1: "+str$(scr1#)

Str$(number) This command will convert the number var to a string for the text command.

Also notice I deleted the comma and added a + sign. Now this line should work.

Quote: "if sprite collision (3,1) = 1
ballspd# = ballspd# + 1
"


If I understand your question correctly, you are increasing the ball speed by one ever time it collides with a paddle 1. If you don't want this delete this line:

ballspd# = ballspd# + 1

If I misunderstood your question, please let me know and I'll try agian.

I'm using DBPro to write "Suger Free Candyland", for diabetic children!
CattleRustler
Retired Moderator
22
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 4th Nov 2003 19:24
I'll give you a hint, multiplying any number by -1 will reverse it's value pos/neg. this little trick is key for ball movement in pong, both in X and Y.

then you can use rnd cleverly to alter angles.

I have complete pong code if/when you're interested. Ok back to vb.net to continue work on my Server-Client chat application.
(almost done!)

-RUST-
Inkybro
23
Years of Service
User Offline
Joined: 31st Dec 2002
Location: Where I live :)
Posted: 5th Nov 2003 19:32
CattleRustler, can you post up JUST the ball bouncing/moving portion of your code for me?

Inkybro
23
Years of Service
User Offline
Joined: 31st Dec 2002
Location: Where I live :)
Posted: 5th Nov 2003 19:57 Edited at: 5th Nov 2003 19:58
I'm very proud of myself, I got my ball movement/bouncing code done myself, with no help. There's a couple of bugs left in the 2 player pong I need help with.

On the scoring system, when the sprite hits the sprite it doesn't go over the sprite fast enough for it to hit up 1 more point, so sometimes it adds 2-5 to the score. If someone could tell me how to make it just score once and maybe disable scoring for one second thatd be great

My current code:



Inkybro
23
Years of Service
User Offline
Joined: 31st Dec 2002
Location: Where I live :)
Posted: 5th Nov 2003 20:47
IanM
Retired Moderator
23
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 5th Nov 2003 23:08
Use something like this to only increase the score when a new collision occurs

Login to post a reply

Server time is: 2026-07-26 19:46:30
Your offset time is: 2026-07-26 19:46:30