Ok so im pretty new to dark basic... but its very easy!! SO FAR IM LOVING IT!
Anyway so I did chris k's tutorial for pong and decided it was lacking alot! So im going to share with you my source for my pong game! There is no download necessary.. sorry about the lack of commenting and messy code ("Im new " ) but it has a title menu , it has 2 levels ... level 2 just loops I havnt finished it ...
Trust me for pong you wont be disappointed!
Also has a pause menu and a help menu .. anyway pong it up with
... UBER PONG!
Rem Project: understand
Rem Created: 10/5/2008 3:29:04 PM
REM REMEMBER TO MAKE A PAUSE DINGY!
SYNC ON : SYNC RATE 60
RESTART:
color backdrop rgb(0,0,0)
Rem ***** Main Source File *****
make object box 4,10,0.1,10;
position object 4,0,-0.55,0;
color object 4,rgb(0,255,0);
set object wireframe 4,1;
make object box 5,10,2,1
position object 5,0,0.55,5.45
color object 5,rgb(0,255,0);
set object wireframe 5,1
make object box 6,10,2,1
position object 6,0,0.55,-5.45
color object 6,rgb(0,255,0);
set object wireframe 6,1
MAKE OBJECT BOX 1,0.5,0.5,3
color object 1,rgb(255,0,0)
set object wireframe 1,1
make object box 2,0.5,0.5,3
color object 2,rgb(0,0,255)
set object wireframe 2,1
make object sphere 3,0.5
color object 3,rgb(0,100,0)
set object wireframe 3,1
rem Setup light
set ambient light 30
set point light 0,0,10,-10;
set light range 0,500
rem Setup color lights
`// DECLARE ALL THE VARIABLES///
balla# = 90;
Time# = 100;
Score# = 0;
player1score# = 0;
player2score# = 0;
count$="Ready!";
tX# = 0;
tY# = 0;
bTime# = 100;
start# = 0
xS# = camera position x(0);
yS# = camera position y(0);
zS# = camera position z(0);
xaS# = camera angle x(0);
yaS# = camera angle y(0);
zaS# = camera angle z(0);
ballzaS# = 0;
Start = 0
balla# = 90;
Main:
DO
tY# = rnd(14);
tX# = rnd(14);
tY2# = rnd(5);
tX2# = rnd(5);
ballza# = 0;
zrotate object 3,ballza#;
ballza#=wrapvalue(ballza#)
set text size 55
ink rgb(0,90,0),0;
TEXT 200+tX#,20+tY#,"UBER PONG";
ink rgb(0,190,0),0;
TEXT 204+tX2#,24+tY2#,"UBER PONG";
SHOW MOUSE
SET TEXT SIZE 35
if Button(50,150,"New Game")=1 then Goto Level1
if Button(50,220,"Help")=1 then Goto Help
if Button(50,310,"Exit")=1 then END
balla# = balla# - 0.2;
yrotate object 3,balla#;
balla#=wrapvalue(balla#)
SYNC
LOOP
Pause:
DO
tY# = rnd(14);
tX# = rnd(14);
tY2# = rnd(5);
tX2# = rnd(5);
ballza# = 0;
zrotate object 3,ballza#;
ballza#=wrapvalue(ballza#)
set text size 55
ink rgb(0,90,0),0;
TEXT 200+tX#,20+tY#,"Pause";
ink rgb(0,190,0),0;
TEXT 204+tX2#,24+tY2#,"Pause";
SHOW MOUSE
SET TEXT SIZE 35
if Button(50,150,"Resume")=1 then Goto Level1
if Button(50,310,"Main menu")=1
DELETE OBJECTS 1,7
Goto RESTART
ENDIF
balla# = balla# - 0.2;
yrotate object 3,balla#;
balla#=wrapvalue(balla#)
SYNC
LOOP
Level1:
DO
IF Start = 0
bTime# = bTime#-1
IF bTime# <=0
Start = 1;
bTimer# = 0;
balla# = 90;
ballza# = 0;
ENDIF
nx# = rnd(5);
ny# = rnd(5);
IF bTime# =100 then count$ = "Ready..";
IF bTime# =50 then count$ = " Set";
IF bTime# =10 then count$ = " GO!";
ink rgb(0,0,100),0
SET TEXT FONT "book";
SET TEXT SIZE 40;
TEXT 245+nx#,145+ny#,count$;
ink rgb(0,0,255),0
SET TEXT FONT "book";
SET TEXT SIZE 40;
TEXT 250,150,count$;
ENDIF
HIDE MOUSE
`//SCORING..//
IF ballx#<-6
player2score#=player2score#+1
ballx#=0:ballz#=0
balla#=270
Score = 1;
position object 3,ballx#,0,ballz#;
ENDIF
REM PAUSE MENU
IF RETURNKEY()=1
Goto Pause;
ENDIF
REM END PAUSE
IF ballx#>6
player1score#=player1score#+1
ballx#=0:ballz#=0
balla#=90
Score = 1;
position object 3,ballx#,0,ballz#;
ENDIF
`//ENDOFSCOREING////////
`//BALL CODE//
ballx#=newxvalue(ballx#,balla#,0.3);
ballz#=newzvalue(ballz#,balla#,0.3);
`[Position the objects!!!]
`//Player 1//
position object 1,-5,0,p1p#;
`//Player 2//
position object 2,5,0,p2p#;
`//CAMERA//
position camera 0,10,-10;
point camera 0,0,playerZ#
`[END OF POSITION////////]
`[ CONTROLS ]
`//Up KEY
IF UPKEY()=1 and p1p#<3.4
p1p# = p1p#+0.5;
ENDIF
IF upkey()=1 and ballx#>4 and ballx#<4.5
balla#=balla#+8;
ENDIF
IF DOWNKEY()=1 and ballx#<-4 and ballx#>-4.5
balla#=balla#+8;
ENDIF
`//DOWN KEY
IF DOWNKEY()=1 and p1p#>-3.4
p1p# = p1p#-0.5;
ENDIF
`{///////////}
`///PLAYER 2 BAll CODE
IF ballx#>4 and ballx#<4.5
balla#=balla#+8;
ENDIF
IF ballx#<-4 and ballx#>-4.5
balla#=balla#+8;
ENDIF
REM AHHHHHHHHHHHHHHHHHH
IF Score = 0 and Start = 1
position object 3,ballx#,0,ballz#;
yrotate object 3,balla#;
ENDIF
IF Score = 1
Time# = Time#-1
IF Time# <=0
Score = 0;
Time# = 100;
ENDIF
nx# = rnd(5);
ny# = rnd(5);
IF Time# =100 then count$ = "Ready..";
IF Time# =50 then count$ = " Set";
IF Time# =10 then count$ = " GO!";
ink rgb(0,0,100),0
SET TEXT FONT "book";
SET TEXT SIZE 40;
TEXT 245+nx#,145+ny#,count$;
ink rgb(0,0,255),0
SET TEXT FONT "book";
SET TEXT SIZE 40;
TEXT 250,150,count$;
ENDIF
if ballx#>4 and ballx#<4.5 and ABS(p2p#-ballz#)<1.5 then balla#=360-balla#
if ballx#<-4 and ballx#>-4.5 and ABS(p1p#-ballz#)<1.5 then balla#=360-balla#
if ballz#>4 or ballz#<-4 then balla#=180-balla#
balla#=wrapvalue(balla#)
`//RETURN THE BALLS POSITION
ballX# = object position x(3);
ballY# = object position y(3);
ballZ# = object position z(3);
`//RETURN THE PLAYERS POSITION
playerX# = object position x(1);
playerY# = object position y(1);
playerZ# = object position z(1);
`//RETURN THE PLAYERS POSITION
player2X# = object position x(2);
player2Y# = object position y(2);
player2Z# = object position z(2);
camZ# = camera position z(0);
SET TEXT FONT "book";
SET TEXT SIZE 18;
ink rgb(255,0,0),0
TEXT 150,20,"Player1 Score: " + str$(player1score#);
ink rgb(0,0,255),0
TEXT 320,20,"Player2 Score: " + str$(player2score#);
ink rgb(0,255,0),0
TEXT 265,60,"Level 1";
IF ballZ#<3.4 and ballZ#> -3.4
IF ballZ# > player2Z# -0.8
p2p# = p2p#+0.008;
ENDIF
IF ballZ# < player2Z# +0.8
p2p# = p2p#-0.008;
ENDIF
ENDIF
IF player1score# >= 5
SET TEXT FONT "book";
SET TEXT SIZE 70;
INK RGB(0,255,255),0;
TEXT 200,145,"YOU WON!!!!";
SET TEXT SIZE 30;
TEXT 50,280,"Press Space";
Start = 0;
if spacekey()=1 then goto Level2
ENDIF
IF player2score# >=5
DELETE OBJECTS 1,7
GOTO RESTART
ENDIF
SYNC
LOOP
REM END OF LEVEL 1 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
``````````````````````````````````````````````````````````````````````````
Level2:
balla# = 90;
Time# = 100;
Score# = 0;
player1score# = 0;
player2score# = 0;
count$="Ready!";
tX# = 0;
tY# = 0;
bTime# = 100;
start# = 0
xS# = camera position x(0);
yS# = camera position y(0);
zS# = camera position z(0);
xaS# = camera angle x(0);
yaS# = camera angle y(0);
zaS# = camera angle z(0);
ballzaS# = 0;
Start = 0
balla# = 90;
DO
IF Start = 0
bTime# = bTime#-1
IF bTime# <=0
Start = 1;
bTimer# = 0;
balla# = 90;
ballza# = 0;
ENDIF
nx# = rnd(5);
ny# = rnd(5);
IF bTime# =90 then count$ = "Ready..";
IF bTime# =50 then count$ = " Set";
IF bTime# =10 then count$ = " GO!";
ink rgb(0,0,100),0
SET TEXT FONT "book";
SET TEXT SIZE 40;
TEXT 245+nx#,145+ny#,count$;
ink rgb(0,0,255),0
SET TEXT FONT "book";
SET TEXT SIZE 40;
TEXT 250,150,count$;
ENDIF
HIDE MOUSE
`//SCORING..//
IF ballx#<-6
player2score#=player2score#+1
ballx#=0:ballz#=0
balla#=270
Score = 1;
position object 3,ballx#,0,ballz#;
ENDIF
REM PAUSE MENU
IF RETURNKEY()=1
Goto Pause;
ENDIF
REM END PAUSE
IF ballx#>6
player1score#=player1score#+1
ballx#=0:ballz#=0
balla#=90
Score = 1;
position object 3,ballx#,0,ballz#;
ENDIF
`//ENDOFSCOREING////////
`//BALL CODE//
ballx#=newxvalue(ballx#,balla#,0.3);
ballz#=newzvalue(ballz#,balla#,0.3);
`[Position the objects!!!]
`//Player 1//
position object 1,-5,0,p1p#;
`//Player 2//
position object 2,5,0,p2p#;
`//CAMERA//
position camera 0,10,-10;
point camera 0,0,playerZ#
`[END OF POSITION////////]
`[ CONTROLS ]
`//Up KEY
IF UPKEY()=1 and p1p#<3.4
p1p# = p1p#+0.5;
ENDIF
IF upkey()=1 and ballx#>4 and ballx#<4.5
balla#=balla#+8;
ENDIF
IF DOWNKEY()=1 and ballx#<-4 and ballx#>-4.5
balla#=balla#+8;
ENDIF
`//DOWN KEY
IF DOWNKEY()=1 and p1p#>-3.4
p1p# = p1p#-0.5;
ENDIF
`{///////////}
`///PLAYER 2 BAll CODE
IF ballx#>4 and ballx#<4.5
balla#=balla#+8;
ENDIF
IF ballx#<-4 and ballx#>-4.5
balla#=balla#+8;
ENDIF
REM AHHHHHHHHHHHHHHHHHH
IF Score = 0 and Start = 1
position object 3,ballx#,0,ballz#;
yrotate object 3,balla#;
ENDIF
IF Score = 1
Time# = Time#-1
IF Time# <=0
Score = 0;
Time# = 100;
ENDIF
nx# = rnd(5);
ny# = rnd(5);
IF Time# =100 then count$ = "Ready..";
IF Time# =50 then count$ = " Set";
IF Time# =10 then count$ = " GO!";
ink rgb(0,0,100),0
SET TEXT FONT "book";
SET TEXT SIZE 40;
TEXT 245+nx#,145+ny#,count$;
ink rgb(0,0,255),0
SET TEXT FONT "book";
SET TEXT SIZE 40;
TEXT 250,150,count$;
ENDIF
if ballx#>4 and ballx#<4.5 and ABS(p2p#-ballz#)<1.5 then balla#=360-balla#
if ballx#<-4 and ballx#>-4.5 and ABS(p1p#-ballz#)<1.5 then balla#=360-balla#
if ballz#>4 or ballz#<-4 then balla#=180-balla#
balla#=wrapvalue(balla#)
`//RETURN THE BALLS POSITION
ballX# = object position x(3);
ballY# = object position y(3);
ballZ# = object position z(3);
`//RETURN THE PLAYERS POSITION
playerX# = object position x(1);
playerY# = object position y(1);
playerZ# = object position z(1);
`//RETURN THE PLAYERS POSITION
player2X# = object position x(2);
player2Y# = object position y(2);
player2Z# = object position z(2);
camZ# = camera position z(0);
SET TEXT FONT "book";
SET TEXT SIZE 18;
ink rgb(255,0,0),0
TEXT 150,20,"Player1 Score: " + str$(player1score#);
ink rgb(0,0,255),0
TEXT 320,20,"Player2 Score: " + str$(player2score#);
ink rgb(0,255,0),0
TEXT 265,60,"Level 2";
IF ballZ#<3.4 and ballZ#> -3.4
IF ballZ# > player2Z# -0.8
p2p# = p2p#+0.2;
ENDIF
IF ballZ# < player2Z# +0.8
p2p# = p2p#-0.2;
ENDIF
ENDIF
SYNC
LOOP
REM END OF LEVEL 2!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Help:
DO
ink rgb(255,255,255),0;
set text size 14
Text 10,100,"Hi Welcome to Uber Pong If you ever played pong before.."
TEXT 10,110,"You will have no problem"
Text 10,120,"It's easy to score bounce the ball past the other player"
TEXT 10,140,"the other bat you player1 are the red bat"
Text 10,200,"CONTROLS"
Text 10,220,"UP KEY: MOVE UP";
TEXT 10,240,"Down KEY: MOVE DOWN";
TEXT 10,260,"RETURN/ENTER KEY: Pause";
set text size 40
If Button(50,350,"Main Menu")=1 then Goto Main
ballza# = ballza# - 1;
zrotate object 3,ballza#;
ballza#=wrapvalue(ballza#)
Sync
Loop
REM FUNCTIONS////////
function Button(x1,y1,WORDS$) rem button function
Pressed=0
newX# =0;
newY# =0;
x2=Text Width(WORDS$)
y2=Text Height(WORDS$)
if mousex()>x1 and mousex()<x1+x2
if mousey()>y1-y2 and mousey()<y1+y2
Pressed=1
endif
endif
if pressed=1
newX# = rnd(3);
newY# = rnd(3);
ink rgb(255,0,0),0
else
ink rgb(0,190,0),0;
newY# = 0;
newX# = 0;
ENDIF
if pressed=1
Pressed=Mouseclick()
else
pressed = 0
endif
text x1+newX#,y1+newY#,WORDS$
endfunction pressed
ps.. Feel free to use just dont copy me exactly ^_^
~Ellusion Games~
xXxLife is like a box of chocalate's there's always one's you dont likexXx