AppTitle "Pong by Eikon" Graphics 640, 480, 16, 2 SetBuffer BackBuffer() SeedRnd MilliSecs() ClsColor 0, 128, 0 Global PX = 30, PY = 10, PS = 0, P2X = 595, P2Y = 10, P2S = 0 Global BXVel, BYVel, BX = 310, BY = 230 Global PB = 0, PD = -1 If Rand(0, 1) = 0 Then BXVel = -5 Else BXVel = 5 If Rand(0, 1) = 0 Then BYVel = -5 Else BYVel = 5 Font = LoadFont("FixedSys", 12, 0, 0) SetFont Font While Not KeyDown(1) ; Arena Color 255, 255, 255: Rect 1, 1, 318, 478, 0 Rect 320, 1, 318, 478, 0 Color 25, 25, 25: Rect (PX + 20) - (PB/2), (PY + 20) - (PB/2), 15 + PB, 80 + PB, 1 Oval BX + 17, BY + 17, 20, 20, 1 Rect P2X + 20, P2Y + 20, 15, 80, 1 ; Ball Color 255, 255 - (PB * 20), 255 - (PB * 20): Oval BX, BY, 20, 20, 1 ; Player 1 Color 255, 255, 255: Rect PX - (PB/2), PY - (PB/2), 15 + PB, 80 + PB, 1 ; CPU Color 255, 255, 255: Rect P2X, P2Y, 15, 80, 1 ; Stats If Len(Str(PS)) = 2 Then tmp = -6 Else tmp = 0 Color 255, 255, 255: Text 300 + tmp, 10, PS Text 330, 10, P2S If BY <= 3 Then BYVel = Abs(BYVel) If BY >= 457 Then BYVel = -Abs(BYVel) If RectsOverlap(PX, PY, 15, 80, BX, BY, 20, 20) Then BXVel = Abs(BXVel) If PD <> -1 Then BXVel = BXVel + 1 ; Boost ElseIf RectsOverlap(P2X, P2Y, 15, 80, BX, BY, 20, 20) Then BXVel = -Abs(BXVel) If PD <> -1 Then BXVel = BXVel - 1 ; Boost EndIf BX = BX + BXVel BY = BY + BYVel If PD = 1 Then PB = PB + 1 If PD = 0 Then PB = PB - 1 If PB >= 10 Then PD = 0 If PB <= 0 And PD = 0 Then PD = -1 If KeyDown(208) And PY < 390 Then PY = PY + 5 If KeyDown(200) And PY > 10 Then PY = PY - 5 If KeyHit(157) And PD = -1 And PB = 0 Then PD = 1 EndIf If BX > 640 Then PS = PS + 1 If BX < -20 Then P2S = P2S + 1 If BX > 640 Or BX < -20 Then BX = 310: BY = 230 If Rand(0, 1) = 0 Then BXVel = -5 Else BXVel = 5 If Rand(0, 1) = 0 Then BYVel = -5 Else BYVel = 5 EndIf If BX > 310 Then If BY > P2Y + 40 And P2Y < 390 Then P2Y = P2Y + 5 If BY < P2Y + 40 And P2Y > 10 Then P2Y = P2Y - 5 EndIf Flip 1: Cls Wend: End