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 / My First Pong Game

Author
Message
Killonyas Slayer
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Mozerok,Eartreg
Posted: 14th Apr 2005 06:35
help!!! I followed the pong tutorial exactly, but my ball doesn't move.
it was moving before, but after the last couple of codes, it stopped.
Killonyas Slayer
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Mozerok,Eartreg
Posted: 14th Apr 2005 06:36
help!!! I followed the pong tutorial exactly, but my ball doesn't move.
it was moving before, but after the last couple of codes, it stopped.
Unique Forum Name
19
Years of Service
User Offline
Joined: 20th Apr 2005
Location:
Posted: 21st Apr 2005 02:32
Hey everyone! I just started using Dark Basic & have the classic version! I've (finally) finished putting together a working pong game! Thanks for the tutorial!

Anyways, I was designing a Pong game similar to the Pong I played on the Odyssey as a kid (my paddles move on the y-axis instead of the z-axis). So if I sound like I'm on the wrong axis, that's why!

I also have the "sticky paddle" glitch, but I think I have an idea for how to fix it. Currently, my paddles will not deflect the ball if it strikes the top or bottom of the paddle. I'm pretty sure that making the top & bottom of the paddle "solid" will correct the sticky paddle glitch.

The problem I'm having is two-fold:

1) Making the top & bottom of the paddle solid as well. Would it be easier to make the entire paddle solid? If so, does anyone have any suggestions about how to do this?
2) Calculating the reaction of the ball if it strikes the top or bottom. Since the ball can hit the paddle from just about any angle, how would I adjust the reaction to fit the action?

Thanks!

Mike
Unique Forum Name
19
Years of Service
User Offline
Joined: 20th Apr 2005
Location:
Posted: 21st Apr 2005 02:43
Oh yeah:
time splitter23987, your ball is not moving because the ball's position is not being correctly updated.

This probably means that one or more of the variables that control your ball's position are misspelled (most likely), or the calculations you are using are now producing a zero value.

Mike
Unique Forum Name
19
Years of Service
User Offline
Joined: 20th Apr 2005
Location:
Posted: 21st Apr 2005 15:46
noslenfl,

It looks like this portion of your code is the problem:

position object 2,ballx#,0,ballz#

By assigning a value of zero to the y-axis, it will continue to go up & down in a straight line.

Mike
Unique Forum Name
19
Years of Service
User Offline
Joined: 20th Apr 2005
Location:
Posted: 21st Apr 2005 15:57
If you want to randomly determine who has the first serve & randomly determine an angle for the serve, then try this code BEFORE the main loop:



The ball's angle (balla#) is assigned a random value from 45 - 135 degrees or 225 - 315 degrees respectively. This means you'll probably never get the same serve twice.

Also: when you do a serve, start the ball off-centered to give the opposing player time to see it coming. This is more realistic.

Mike
Unique Forum Name
19
Years of Service
User Offline
Joined: 20th Apr 2005
Location:
Posted: 21st Apr 2005 16:03
For some camera fun, try this:

position camera player2pos#, player1pos#, -10
point camera 0,0,0

Mike
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 24th Apr 2005 03:07
Don't bother labouring over your pong games, guys.

There's no point trying to iron out the last few glitches because its actually quite hard.

As soon as you've got it working to a playable level, and you understand it entirely, move on to the Binary Moon (Limit Rush) tutorial.

My Showcase - It's DBpro-tastic
Metel Artz
19
Years of Service
User Offline
Joined: 13th Apr 2005
Location: Vermont USA
Posted: 2nd May 2005 06:36
i can't download it is there something wrong with geocities or did you remove it? cuz id really like to see how you did.

Eray
19
Years of Service
User Offline
Joined: 26th Apr 2005
Location: United Kingdom
Posted: 7th May 2005 00:26
hi.. guys ive been foloing this gr8 tutiral to but i have a few Q`s

* the ai is still relying on me to move it
* no one can win or lose
* how do i change the ball into somthing like a spikey thing

here is my code


by the way most exelent tut but shame about those
guys confusing me at the end by giving the wrong code
_______
thanxs |help me|

e-ray has STOPPED talking
MeBiNiCi
18
Years of Service
User Offline
Joined: 2nd Jun 2005
Location: Cali
Posted: 3rd Jun 2005 08:05
Hi,

Thanks for everything everyone! Great to be a n00b in such a great environment. I can't wait to get home and apply all this knowledge and make something work finally!

Only in our dreams!
tjg92
19
Years of Service
User Offline
Joined: 25th Mar 2005
Location: Texas
Posted: 12th Jun 2005 15:08
Where is this binary moon (limit rush) tutorial? I NEEDZ IT!
By the way great tutorial.

crap
Chris K
20
Years of Service
User Offline
Joined: 7th Oct 2003
Location: Lake Hylia
Posted: 15th Jun 2005 03:45
The InTIMidator
18
Years of Service
User Offline
Joined: 22nd Jun 2005
Location: Somerset, UK
Posted: 23rd Jun 2005 02:03
Hi I have a solution to the person who had trouble restarting and I have a solution.
[/code]if object exist(1)=1 then delete object 1
if object exist(2)=1 then delete object 2
if object exist(3)=1 then delete object 3
if object exist(4)=1 then delete object 4

And then to quit you would...

if spacekey()=1 then gosub menu

And for your menu you could have something like...

Menu:
cls
Print "Pong"
Print "Press 1 to play 1 player"
Print "Prees 2 to play 2 player"
Print "Press escape at any time to go to Windows"
Print "Press space to change mode at any time"
sync
Do
If keystate(2)=1 then gosub 1player
If keystate(3)=1 then gosub 2player
if spacekey()=1 then gosub menu
loop
[code]
or something like that.
I hope this helps

Tim

"Press any key ... where's the any key"
The InTIMidator
18
Years of Service
User Offline
Joined: 22nd Jun 2005
Location: Somerset, UK
Posted: 23rd Jun 2005 02:38
[/center]Oh yeah Binary Moon is herecenter]
http://developer.thegamecreators.com/?f=t02/bm_tutorial_index
Hope this helps.
It sure helped me.
Tim

"Press any key ... where's the any key"
Avalanche_ Akshay
18
Years of Service
User Offline
Joined: 27th Jun 2005
Location:
Posted: 29th Jun 2005 01:31
hello i am a newbie and this tutorial has helped me the most. there is a slight errot in my game that whenever i sart to play it freezes and makes some very strange camera angles.
here is my code.
i dont know how the code thingy works.


REM Project: pong
REM Created: 6/27/2005 7:54:42 PM
REM
REM ***** Main Source File *****
REM pong
sync rate 40
hide mouse
backdrop off
make object box 1,1,1,3
color object 1,rgb(255,0,0)
make object box 2,1,1,3
color object 2,rgb(0,225,0)
make object sphere 3,1
color object 3,rgb(0,0,50)
make object box 4,10,0.1,10
position object 4,0,-0.55,0
print "pong v1.0. press a key then wait 3 seconds to start."
wait key
wait 3000
balla#=90
sync on
do
_main_action:
ballx#=newxvalue(ballx#,balla#,0.3)
ballz#=newzvalue(ballz#,balla#,0.3)

if ballx#>-6.5 then player2score#=player2score#+1:goto _restart_game1
if ballx#<6.5 then player1score#=player1score#+1: goto _restart_game2

if player1score#=20 and player2score#<20 then goto _player1_wins
if player2score#=20 and player1score#<20 then goto _player2_wins

set cursor 300,50:print player1score#
set cursor 320,50:print "-"
set cursor 340,50:print player2score#

if upkey()=1 and player1pos#<3.5 then player1pos#=player1pos#+0.5
if downkey()=1 and player1pos#>-3.5 then player1pos#=player1pos#-0.5
if upkey()=1 and ballx#>4 and ballx#<4.5 then balla#=balla#+8
if downkey()=1 and ballx#>4 and ballx#<4.5 then balla#=balla#-8

if keystate(17)=1 and player2pos#<3.5 then player2pos#=player2pos#+0.5
if keystate(31)=1 and player2pos#>-3.5 then player2pos#=player2pos#-0.5
if keystate(17)=1 and ballx#<-4 and ballx#>-4.5 then balla#=balla#+8
if keystate(31)=1 and ballx#<-4 and ballx#>-4.5 then balla#=balla#-8

if ballx#>4 and ballx#<4.5 and abs(player1pos#-ballz#)<1.5 then balla#=360-balla#
if ballx#<-4 and ballx#>-4.5 and abs(player2pos#-ballz#)<1.5 then balla#=360-balla#
if ballz#>4 or ballz#<-4 then balla#=180-balla#

balla#=wrapvalue(balla#)

position object 1,-5,0,player1pos#
position object 2,5,0,player2pos#
position object 3,ballx#,0,ballz#
yrotate object 3,balla#
position camera 0,10,-10
point camera 0,0,0
sync
loop

_restart_game1:
wait 1000
position object 1,-5,0,0
position object 2,5,0,0
sync
ballx#=0:ballz#=0:balla#=270
goto _main_action

_restart_game2:
wait 1000
position object 1,-5,0,0
position object 2,5,0,0
sync
ballx#=0:ballz#=0:balla#=90
goto _main_action

_player1_wins:
set cursor 0,0:print "player 1 wins. press a key to play again. press escape to quit"
wait key
player1score#=player2score#=0
wait 5000
sync
goto _main_action

_player2_wins:
set cursor 0,0: print "player 2 wins. press a key to play again. press escape to quit"
wait key
player1score#=player2score#=0
wait 5000
sync
goto _main_action
dart
18
Years of Service
User Offline
Joined: 5th Jul 2005
Location:
Posted: 7th Jul 2005 02:55
just wanna say thankx for making a wicked tut, its been brill making my first real game.. so thankx

if only i could find a hammer,then all my problems would be solved!!
The Ringmaster
19
Years of Service
User Offline
Joined: 19th Mar 2005
Location: Cyberspace
Posted: 20th Jul 2005 05:26
Hey! Some guys have been asking for a txt document of this tut. I have it in the attachment

Clouds float the exact same way bricks don't
- Douglas Adams

Attachments

Login to view attachments
Darkbasic MADPSP
18
Years of Service
User Offline
Joined: 15th Jun 2005
Location: Uk
Posted: 1st Aug 2005 16:09
post it then

life's a game and a games a life More games at www.freewebs.com/halorc
PingBall
18
Years of Service
User Offline
Joined: 12th Aug 2005
Location:
Posted: 13th Aug 2005 05:39
Im new but not to forums
Im waiting till i get laptop its coming soon... about 3-4 months....
PingBall
18
Years of Service
User Offline
Joined: 12th Aug 2005
Location:
Posted: 13th Aug 2005 05:40
this is a test
Avalanche_ Akshay
18
Years of Service
User Offline
Joined: 27th Jun 2005
Location:
Posted: 16th Aug 2005 02:47
no one ever awnsers my questions...even after a 2 months of waiting. great tut.
Non Official Company Owner
18
Years of Service
User Offline
Joined: 1st Jul 2005
Location: ???????????
Posted: 27th Aug 2005 18:06
HELP Player two's side wont move I press 1 and it goes down when it is suppose to move up and when I use it to go up it is stuck!!!!!

Y wat' up
Specters
18
Years of Service
User Offline
Joined: 30th Sep 2005
Location: idaho
Posted: 8th Oct 2005 18:08
Look, Avalance and Company Owner.
Just go to the beginning and repaste their code into your game.
And Avalanche, for one, why would we help you, I mean, you just gave us your problem and didn't say at all how you tried to fix it. I am not trying to be a jerk, but I'm just saying if you want someone to help you, try to do some work to fix the problem first.

Current Project : Legend of Lantis
Avalanche_ Akshay
18
Years of Service
User Offline
Joined: 27th Jun 2005
Location:
Posted: 25th Oct 2005 05:39
Finally...oh
i wont be that much of a jerk anymore
cant edit my code thing now
comp crash
Coder#05
18
Years of Service
User Offline
Joined: 26th Oct 2005
Location: Denmark
Posted: 23rd Nov 2005 19:51
thanks for the tutorial chris k.
here is my version of the pong game
its not done, but works prety god.. You can beat the AI. but its very hard..
im trying to make difrent lvls (easy,medium,hard)
and the rounds thing dosent work (yet)
bla bla bla
here it is:
notice:
you need to dowload the media files and put em in a map called media, vere the code is. its sounds and stuff.
its a zip file.

Not that much a noob, but still a noob

Attachments

Login to view attachments
Coder#05
18
Years of Service
User Offline
Joined: 26th Oct 2005
Location: Denmark
Posted: 23rd Nov 2005 20:08
By the way im working on the AI part thats why it may seem a bit confusing, just testing some different things to see how it works.
sorry for all the mis spelling but, im not the worlds greates speller, some thing like that

key instructions:
Player one:
upkey- move up
downkey- move down
numpad + -makes bat move faster
numpad - -makes bat move slower

player two:
w -move up
s -move down
e -fast bat speed
f -slow bat speed

if code dosent work, check the path to the different media sounds etc.

And plz remember that this code isent done, and that im a noob hehe

Not that much a noob, but still a noob
stranfc
18
Years of Service
User Offline
Joined: 25th Nov 2005
Location:
Posted: 25th Nov 2005 15:03
I am also creating a game of pong. I have nearly finished it, all i need to do is allow the computer to play against the user and to save high scores? can anybody please help?
Mulderman
20
Years of Service
User Offline
Joined: 8th Jan 2004
Location: C:\\
Posted: 1st Dec 2005 11:53 Edited at: 1st Dec 2005 11:54
Nobody answered so i will. Make first simple program where ball is bouncing and also make box (paddle) in left or right side of screen/play area. It depends what type of pong u have, i mean paddle(s) are (is) in top/down or left/right. For example paddle is on left side. Make ball bouncing back from right side. In left side the paddle must follow ball moving direction (up or down) so it will not let ball go outside the screen in left side. I mean make it move automatically. Then if it works like u want, put it in your pong game. Its a bit hard to explain with words. Maybe some pic should help. Scoring saving is easy, just read DB help about file functions/procedures and save scores from your scores variable to file and later read from it, for example if u want display some highscore table.
Im always doing new program snippet for functions/procedures that i want to include in my final app and if it works like i want then i put it in my app. So i dont mess up original source. Of course u can make backups of sources etc., but thats the way im doing it. In every progr. language i use.

uSER
Charlie
18
Years of Service
User Offline
Joined: 6th Nov 2005
Location:
Posted: 30th Dec 2005 04:12
Exellent tutorial. It shows how easy is to work in DarkBasic. In just 40 lines you can make a 3d pong. It helped me very much. Continue like that and thanks.

Carlos

Have a nice day
Acolyte Entertainment
19
Years of Service
User Offline
Joined: 28th Dec 2004
Location: Oregon, US
Posted: 6th Jan 2006 05:11
yo. i am modding somone elses (cant remember whos) code cause im a total noob.
so im understanding it and all. but for some reason when it says



the game just stops and freazes. even if i use the return command.

here is the code im using:



please help,
thanks,
-Marlin Studios

O
M
G!
Zedane
19
Years of Service
User Offline
Joined: 3rd Nov 2004
Location: Milky Way, Earth
Posted: 6th Jan 2006 05:28 Edited at: 6th Jan 2006 05:33
Its an infinate loop, thats the problem. What i think is happening is that, you go to start1: which is at the top, and since none of the variable's are reset, it goes through all the gosubs..all the way back to the line of code that checks if you have won, sees that you have won, and gooes all the way back up. I can suggest a few thigns.

a) Make your gosubs a bit easier to read, the style there is very aqward to me. Sorry, if thats mean but your using gosub like a goto command, and it will lead to hard to read code.

a gosub should look more like this

do
gosub say_hi!
gosub say_bye!
loop
say_hi!:
print "HI!"
return
say bye!:
print "Bye!"
return


b) You need to reset all the variables at start1.

c) You should put a return at the end of your gosubs, regarless of the fact they they are going into another gosub. your code although is going to cause a huge recurrsive function if played over and over, will work if you just fix these up


--My recommmendation is that you try and fix this, but next time, code it in a different style. Check out code by many of the advanced forum-goers (ric, van-B) to see how to do this. Be elequent and use functions, and have the gosubs called from within the main program, and exited out of afterwards, it is bad coding to go from gosub to gosub throught your program.

Oh and BTW : this was just a really quick, im eyeballing. I may be wrong o.0

and also, your program looks pretty cool .


around here.. normal's just a setting on a hair dryer
Acolyte Entertainment
19
Years of Service
User Offline
Joined: 28th Dec 2004
Location: Oregon, US
Posted: 6th Jan 2006 16:16
thank you

O
M
G!
DarkBasic Pro Guy
19
Years of Service
User Offline
Joined: 4th Jun 2004
Location: Broomfield, Colorado
Posted: 7th Jan 2006 09:41
tut is the best. I am working on making the paddles have curved edges, and a neat design. I will post when I am done with that

Shadowed Lightning
19
Years of Service
User Offline
Joined: 10th Nov 2004
Location:
Posted: 21st Jan 2006 00:58
Sounds cool, I'd like to see you progress on that.

AMD Athlon 64 3200 - GeForce 6800 GT - 320GB Hard Drive
1024MB RAM
Acolyte Entertainment
19
Years of Service
User Offline
Joined: 28th Dec 2004
Location: Oregon, US
Posted: 21st Jan 2006 03:32
i modeled some curved pallets but trashed um when it didnt change the angle (i was a noob then)
now i come back with wrath and revenge. MUAHAHAHAHAHAHAHA. i shall prevail

(DBP guy (this isnt a challenge ))

[href]http://snowfall.homestead.com [/href]
DarkBasic Pro Guy
19
Years of Service
User Offline
Joined: 4th Jun 2004
Location: Broomfield, Colorado
Posted: 3rd Feb 2006 02:14
I guess for curved paddles, you could just use cylinders with sphere's. it would triple the movement code I think but it would work. also to make some cool electric textured paddles make a texture, I can't come up with that code though.

DB newbie
18
Years of Service
User Offline
Joined: 13th Nov 2005
Location: um..... i dont remember.
Posted: 19th Feb 2006 00:18
im having some problems with the tut! some of the time when im playing it it works fine and the ball bounces off the paddle but when i sometimes move the paddle it will go through one of the problems can someone help! here is my code!


Check out my site!(unfinished)
http://www.freewebs.com/dbnewbie/
Spunky sk8er
18
Years of Service
User Offline
Joined: 22nd Feb 2006
Location: Ehm.... no
Posted: 24th Feb 2006 01:10
OK so i read this and loved it, great job here. Im now working on making a breakout like you suggested but im tired of making all these stinking objects!

so is there any way to do it without me having to make every single one like this or what? and how please
Spunky sk8er
18
Years of Service
User Offline
Joined: 22nd Feb 2006
Location: Ehm.... no
Posted: 24th Feb 2006 05:30
Also i cant have my paddle move left... somethings wrong and its not syntax

Login to post a reply

Server time is: 2024-05-02 15:02:29
Your offset time is: 2024-05-02 15:02:29