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 needing an editor!

Author
Message
Static
20
Years of Service
User Offline
Joined: 4th Apr 2004
Location: United Kingdom
Posted: 26th Apr 2004 21:55
Hi
I'm quite new and started a bit to over ambitious but anyway i've just made my first game (a pong game). I have a few problems with it though:
- I can't get the scores to show.
- The collision needs working on (It can get stuck behind the bat the come back infront)
- more random start so that it's not always exactly the same thing each time.
Here's the code:
[set display mode 800,600,32
randomize timer()
sync on
hide mouse
type bat
x as integer
y as integer
speedy as integer
score as integer
endtype
player1 as bat
player2 as bat
player1.score=0
player1.speedy=2
player2.score=0
player2.speedy=1
type ball
x as integer
y as integer
speedx as integer
speedy as integer
endtype
ball1 as ball
begining:
Initialize_game()
do
sync
cls
Test_keyboard()
Test_AI()
Move_ball()
Draw_HUD()
Draw_bats()
Draw_ball()
loop
function Initialize_game()
player1.x=50
player1.y=300
player2.x=750
player2.y=300
ball1.x=400
ball1.y=300
ball1.speedx=1
ball1.speedy=1
endfunction

function Test_keyboard()
if upkey()=1 then player1.y=player1.y-player1.speedy
if downkey()=1 then player1.y=player1.y+player1.speedy
if player1.y<50 then player1.y=50
if player1.y>550 then player1.y=550
endfunction
function Test_AI()
p=rnd(3)
if ball1.y<player2.y and p<>1 then player2.y=player2.y-player2.speedy
if ball1.y>player2.y and p<>1 then player2.y=player2.y+player2.speedy
endfunction
function Move_ball()
ball1.x=ball1.x+ball1.speedx
ball1.y=ball1.y+ball1.speedy
if ball1.y<10 or ball1.y>590 then ball1.speedy=-ball1.speedy
if ball1.x<player1.x+25 and ball1.y<player1.y+50 and ball1.y>player1.y-50 then ball1.speedx=-ball1.speedx
if ball1.x>player2.x-25 and ball1.y<player2.y+50 and ball1.y>player2.y-50 then ball1.speedx=-ball1.speedx
if ball1.x<0
player2.score=player2.score+1
goto begining
endif
if ball1.x>800
player1.score=player1.score+1
goto begining
endif
endfunction
function Draw_HUD()
center text 100,50,"Player 1: "+ player1.score
center text 700,50,"Player 2: "+ player2.score
endfunction
function Draw_bats()
box player1.x-15,player1.y-50,player1.x+15,player1.y+50
box player2.x-15,player2.y-50,player2.x+15,player2.y+50
endfunction
function Draw_ball()
circle ball1.x,ball1.y,10
endfunction]
Thanks
Static
20
Years of Service
User Offline
Joined: 4th Apr 2004
Location: United Kingdom
Posted: 26th Apr 2004 21:56
hey how does the code snippet thin work
dragon tail
21
Years of Service
User Offline
Joined: 23rd Jul 2003
Location: United Kingdom
Posted: 26th Apr 2004 22:19
[ code ] code in here [ /code ] but with out the spaces inside the square brackets

like this:


Static
20
Years of Service
User Offline
Joined: 4th Apr 2004
Location: United Kingdom
Posted: 27th Apr 2004 22:35
testing
Static
20
Years of Service
User Offline
Joined: 4th Apr 2004
Location: United Kingdom
Posted: 27th Apr 2004 22:36
good it works thanks!

Login to post a reply

Server time is: 2024-11-26 14:17:34
Your offset time is: 2024-11-26 14:17:34