;PEENG PAWNG writen and developed by Eric Kline
;Thanks to my Dad for lettin me use his comp and thanks to Maneesh Sethi for writin the book that helped me develop this game
;Here we almost go
;copyright E.K. comics 2008- actually like i have legal rihgts to this!
;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!Game!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Graphics 400, 300
;This will make random numbers
SeedRnd (MilliSecs())
;This will make the buffer backbuffer so it looks good and smooth
SetBuffer BackBuffer()
AutoMidHandle True
;Types
Type Paddle
Field x,y
End Type
Type Ball
Field x, y
Field xv, yv
End Type
;Constants
Const PADDLESTRING$ = "|"
Const BALLSTRING$ = "o"
Const UPKEY = 17
Const DOWNKEY = 31
Const PAUSEKEY = 25
Const ENTERKEY = 28
Const WARPKEY = 19
Const MENUKEY = 50
Const ESCKEY = 1
Global ballheight = FontHeight()
Global ballwidth = Len(ballstring$) * FontWidth()
Global playerheight = FontHeight()
Global playerwidth = Len(playerstring$) * FontWidth()
Global player1score = 0
Global player2score = 0
Global difficulty1 = Input ("How quick can you move?")
Global difficulty2 = Input ("How Quick can the computer move?")
Global ballX = 190
Global ballY = 140
Global ballspeedX = Rnd(-1,1)
Global ballspeedY = Rnd(-1,1)
Global youX = 20
Global youY = 140
Global compX = 370
Global compY = 140
Global ball.Ball = New Ball
Global you.Paddle = New Paddle
Global comp.Paddle = New Paddle
Function DrawHUD()
Cls
Text 0, 0, player1score
Text 380, 0, player2score
Text 0, 270, "p1 speed " + difficulty1
Text 0, 280, "p2 speed " + difficulty2
End Function
Function TestInput()
If KeyDown(DOWNKEY)
youY = youY + difficulty1
EndIf
If KeyDown(UPKEY)
youY = youY - difficulty1
EndIf
If KeyHit(PAUSEKEY)
Cls
While Not KeyHit(PAUSEKEY)
Text 0, 0, ("P1 score: " + player1score)
Text 0, 20, ("P2 score: " + player2score)
Text 0, 40, ("P1 speed: " + difficulty1)
Text 0, 60, ("P2 speed: " + difficulty2)
Text 10, 100, ("PEENG PAWNG, developed by Eric Kline, is paused!")
Text 100, 120, ("Press P to unpause...")
Wend
EndIf
If KeyDown(WARPKEY)
youY = ballY
EndIf
End Function
Function DrawPaddles()
If ballspeedX = 0
ballspeedX = -1
ElseIf ballspeedY = 0
ballspeedY = 1
EndIf
Text youX, youY, paddlestring$
Text compX, compY, paddlestring$
Text ballX, ballY, ballstring$
End Function
Function TestAI()
ballX = ballX + ballspeedX
ballY = ballY + ballspeedY
If ballY > compY
compY = compY + difficulty2
ElseIf ballY < compY
compY = compY - difficulty2
EndIf
End Function
Function Walls()
;lets see if i can get this workin stupid bouncing balls
If ballY <0>= 300
ballspeedY = -ballspeedY + Rand (-1,1)
ballspeedX = ballspeedX + Rand (-1,1)
EndIf
If ballX <0>= 400
player1score = player1score + 1
ballX = 190
ballY = 140
youX = 20
youY = 140
compX = 370
compY = 140
EndIf
If ballY >= youY And ballY <youY>= youX And ballX + ballwidth <= youX + playerwidth
ballspeedX = -ballspeedX + 1
EndIf
If ballY <compY>= compY + playerheight And ballX + ballwidth <compX>= compX + playerwidth
ballspeedX = -ballspeedX - 1
EndIf
End Function
;Mainloop this makes the game run
While Not KeyDown(ESCKEY)
;Functions here's where the stuff happens
DrawHUD()
TestInput()
DrawPaddles()
TestAI()
Walls()
Flip
Wend