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 / HELP IM PONG GAME..

Author
Message
kevin lor 12
20
Years of Service
User Offline
Joined: 8th Jun 2004
Location:
Posted: 11th Jun 2004 05:31
IN THE GAME I HAVE IT SO IT KEEPS SCORE... AND EVERYTHING BUT IS THERE A WAY TO "AUTOMATE" THE OTHER PLAYER.... UMM LIKE MAKE IT SO I CAN FACE THE COMPUTER.. RIGHT NOW I MOVE ONE BAT THINGGY BUT THE OVER STAYS STATIONARY IN THE MIDDLE HOW CAN I MAKE IT "PLAY BACK"?
comando 300
20
Years of Service
User Offline
Joined: 23rd Nov 2003
Location:
Posted: 11th Jun 2004 05:38
You have to make an AI, so make it to go up and go down when the ball is in a coordinate

pseudo code:

if bally>aiy and ballx=a_coordx:move down:endif
if bally<aiy and ballx=a_coordx:move up:endif


a little of ur code will be better to help you


CURRENT PROJECT: RETRO PAC-MAN
kevin lor 12
20
Years of Service
User Offline
Joined: 8th Jun 2004
Location:
Posted: 11th Jun 2004 23:02
sync on
sync rate 40

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,255,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

balla#=100

do

rem SCORING
if ballx#>6 then player2score#=player2score#+1:ballx#=0:ballz#=0:balla#=270
if ballx#<-6 then player1score#=player1score#+1:ballx#=0:ballz#=0:balla#=90
set cursor 300,50:print player2score#
set cursor 320,50:print "-"
set cursor 340,50:print player1score#
rem BALL MOVEMENT
ballx#=newxvalue(ballx#,balla#,0.3):ballz#=newzvalue(ballz#,balla#,0.3)
rem PLAYER 1 PADDLE MOVEMENT
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
rem PLAYER 2 PADDLE MOVEMENT
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
rem BOUNCING
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#
rem MAKE SURE balla# IS LESS THAN 360 AND MORE THAN 0
balla#=wrapvalue(balla#)
rem POSITION OBJECTS
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



my code

Login to post a reply

Server time is: 2024-09-22 12:43:14
Your offset time is: 2024-09-22 12:43:14