Yeah so, got interested in the internal sounds I just found out about that DBP allows you to make with the use of some kernel dll, so I wipped up a pong game. Tried to keep it as classic as possible, meh.
`App Settings
SET CURSOR SCREEN WIDTH()/2,SCREEN HEIGHT()/2:PRINT "pong.":WAIT 5000
RANDOMIZE TIMER():INK RGB(255,255,255),RGB(255,255,255):SET TEXT FONT "Verdana":LOAD DLL "Kernel32",3:DISABLE SYSTEMKEYS:SET TEXT TO BOLD
`Player Setup
TYPE playerStat
paddleY#
paddleHeight#
paddleWidth#
paddleSpeed#
paddleDist#
score
direction
upKeystate
downKeystate
ENDTYPE
DIM players(2) AS playerStat
FOR p = 1 TO 2
players(p).paddleHeight# = 50
players(p).paddleWidth# = 10
players(p).paddleSpeed# = .5
players(p).paddleY# = (SCREEN HEIGHT()/2)-(players(p).paddleHeight#/2)
NEXT x
players(1).paddleDist# = 10
players(1).upKeystate = 17
players(1).downKeystate = 31
players(2).paddleDist# = SCREEN WIDTH()-20
players(2).upKeystate = 200
players(2).downKeystate = 208
`Ball Setup
TYPE ballStat
hit
x#,y#
xSpeed#,ySpeed#
acceleration#
wallFreq
wallDur
paddleFreq
paddleDur
ENDTYPE
GLOBAL ball AS ballStat
ball.x# = SCREEN WIDTH()/2
ball.y# = SCREEN HEIGHT()/2
ball.wallFreq = 300
ball.wallDur = 30
ball.paddleFreq = 100
ball.paddleDur = 30
ball.acceleration# = 1.05
spawnBall()
`Line Setup
#CONSTANT lineTotal = 40
#CONSTANT lineGap = 2
`Other junk
GLOBAL width
GLOBAL height
GLOBAL maxScore
width = SCREEN WIDTH()
height = SCREEN HEIGHT()
maxScore = 10
`Main Loop
WHILE NOT ESCAPEKEY()
CLS
`Cycle through both players, handling movement/paddle display
FOR p = 1 TO 2
DEC players(p).paddleY#,(KEYSTATE(players(p).upKeystate)-KEYSTATE(players(p).downKeystate))*players(p).paddleSpeed#
players(p).direction = KEYSTATE(players(p).upKeystate)-KEYSTATE(players(p).downKeystate)
IF players(p).paddleY# > HEIGHT-players(p).paddleHeight# THEN players(p).paddleY# = HEIGHT-players(p).paddleHeight#
IF players(p).paddleY# < 0 THEN players(p).paddleY# = 0
BOX players(p).paddleDist#,players(p).paddleY#,players(p).paddleDist#+players(p).paddleWidth#,players(p).paddleY#+players(p).paddleHeight#
NEXT p
`Move the ball
INC ball.x#,ball.xSpeed#
INC ball.y#,ball.ySpeed#
`Check if the ball is scored
IF ball.x# < 0 THEN ball.x# = 0:ball.xSpeed# = ABS(ball.xSpeed#):ball.x# = WIDTH/2:ball.y# = WIDTH/2:INC players(2).score,1:spawnBall()
IF ball.x# > WIDTH THEN ball.x# = WIDTH:ball.xSpeed# = -ball.xSpeed#:ball.x# = WIDTH/2:ball.y# = WIDTH/2:INC players(1).score,1:spawnBall()
`Check if the ball hits a top or bottom wall
IF ball.y# < 0 THEN ball.y# = 0:ball.ySpeed# = ABS(ball.ySpeed#):CALL DLL 3,"Beep",ball.wallFreq,ball.wallDur
IF ball.y# > HEIGHT THEN ball.y# = HEIGHT:ball.ySpeed# = -ball.ySpeed#:CALL DLL 3,"Beep",ball.wallFreq,ball.wallDur
`Check if the ball hits a paddle
FOR p = 1 TO 2
IF ball.x# > players(p).paddleDist# AND ball.x# < players(p).paddleDist#+players(p).paddleWidth#
IF ball.y# > players(p).paddleY# AND ball.y# < players(p).paddleY# + players(p).paddleHeight#
ball.xSpeed# = (-ball.xSpeed#)* ball.acceleration#
ball.ySpeed# = (ball.ySpeed# * ball.acceleration#)
IF players(p).direction
ball.ySpeed# = players(p).direction*(-(ABS(ball.ySpeed#)))
ENDIF
IF p = 1
ball.x# = players(p).paddleDist#+players(p).paddleWidth#
ELSE
ball.x# = players(p).paddleDist#-players(p).paddleWidth#
ENDIF
CALL DLL 3,"Beep",ball.paddleFreq,ball.paddleDur
ENDIF
ENDIF
`Check if a player wins
IF players(p).score >= maxScore
CLS
PRINT "Player "+STR$(p)+" wins."
WAIT 3000
PRINT "...yay."
WAIT 3000
END
ENDIF
NEXT p
`Display the ball
BOX ball.x#-5,ball.y#-5,ball.x#+5,ball.y#+5
`Display the grid lines
FOR x = 1 TO lineTotal STEP lineGap
lineLength = HEIGHT/lineTotal
x1# = WIDTH/2
y1# = lineLength*x
x2# = x1#
y2# = y1# + lineLength
BOX x1#-2,y1#,x2#+2,y2#
NEXT x
`Display the player scores
TEXT 100,0,"P1: "+STR$(players(1).score)
TEXT WIDTH-100,0,"P2: "+STR$(players(2).score)
`Refresh that there screen mkay
SYNC
`Repeat until the user presses escape
ENDWHILE
`Wipe everything
END
`Ball spawning function
FUNCTION spawnBall()
xDir = RND(1)
IF xDir
ball.xSpeed# = .3
ELSE
ball.xSpeed# = -.3
ENDIF
ball.ySpeed# = -.3+(.1*(RND(10)))
IF ball.xSpeed# = 0 THEN ball.xSpeed# = .1
IF ball.ySpeed# = 0 THEN ball.ySpeed# = .1
ENDFUNCTION
I know, theres 100's of pong games out there, ohwell, this one is one of the few that isnt a product of Chris K's "My First Pong Game" tutorial obviously.
It could definitely be more efficient/"green", but whatever, got bored, thar she is.
Oh, also, I made sure to program it so that pretty much everything is customizable, down to the speed/size of the paddles, the acceleration of the ball, etc, so adding things like powerups to change the paddle size, or to slow the enemy down, shouldnt be too hard to plug em' right in.