Hey
I am reasonably new to Darkbasic Pro and I have decided to try and make a pong game!
I have written all the code and it says that there is a syntax error but I can't figure it out.
Here is the code.
Rem Project: Pong
Rem Started: 28/06/2015 20:38
Rem Executable name: Pong.exe
Rem Version: 1.0
Rem Author: Billy Harding
Rem Description: This is based on the original Pong game.
Rem ------------------------------------------------------
Rem ***Declare Global Variables***
GLOBAL PlayerOnePoints AS INTEGER = 0
GLOBAL PlayerTwoPoints AS INTEGER = 0
GLOBAL BallX AS INTEGER = 320
GLOBAL BallY AS INTEGER = 240
GLOBAL SpeedX AS INTEGER = 3
GLOBAL SpeedY AS INTEGER = 1
GLOBAL PaddleX1 AS INTEGER = 5
GLOBAL PaddleY1 AS INTEGER= 200
GLOBAL PaddleX2 AS INTEGER = 625
GLOBAL PaddleY2 AS INTEGER = 200
Rem ***Background***
INK RGB(255, 255, 0),0
Rem ***Logic***
SYNC ON
SYNC RATE 60
DO
CLS
ProcessPlayerMoves()
UpdateBallPosition()
ManageVerticalCollisions()
ProcessPlayerMisses()
DrawBallAndPaddles()
ProcessPlayerHits() `Line with syntax error.
UpdateScore()
IF (PlayerOnePoints = 10) OR (PlayerTwoPoints = 10) THEN EndOfGame()
SYNC
LOOP
Rem ***Functions***
FUNCTION ProcessPlayerMoves()
IF SHIFTKEY()
DEC PaddleY1, 3
IF PaddleY1 < 0 THEN PaddleY1 = 0
ENDIF
IF CONTROLKEY()
INC PaddleY1, 3
IF PaddleY1 > 405 THEN PaddleY1 = 405
ENDIF
IF UPKEY()
DEC PaddleY2, 3
IF PaddleY2 <0 THEN PaddleY1 =0
ENDIF
IF DOWNKEY()
INC PaddleY2,3
IF PaddleY2 > 405 THEN PaddleY2 = 405
ENDIF
ENDFUNCTION
FUNCTION UpdateBallPosition()
INC BallX, SpeedX
INC BallY, SpeedY
ENDFUNCTION
FUNCTION ManageVerticalCollisions()
IF BallY < 5 OR BallY > 475
SpeedY = SpeedY * -1
ENDIF
ENDFUNCTION
FUNCTION ProcessPlayerMisses()
IF BallX < 9
INC PlayerTwoPoints, 1
ResetBallAndPaddles()
SpeedX = 3
SLEEP 2000
ENDIF
IF BallX > 631
INC PlayerOnePoints,1
ResetBallAndPaddles()
SpeedX = -3
SLEEP 2000
ENDIF
ENDFUNCTION
FUNCTION DisplaySplashScreen()
SET TEXT SIZE 48
CENTER TEXT 320, 170, "Welcome to DB Pong."
SET TEXT SIZE 38
CENTER TEXT 320, 230, "Player 1 uses Shift to move up and Ctrl to move down."
CENTER TEXT 320, 275, "Player 2 uses the Up and Down arrow Keys to move."
SET TEXT SIZE 28
CENTER TEXT 320, 225, "Press any key to continue."
WAIT KEY
CLS
ENDFUNCTION
FUNCTION DrawBallAndPaddles()
CIRCLE BallX, BallY, 8
BOX PaddleX1, PaddleY1, PaddleX1 + 10, PaddleY1+75
BOX PaddleX2, PaddleY2, PaddleX2 + 10, PaddleY2+75
ENDFUCTION
FUNCTION ProcessPlayerHits()
IF POINT(BallX,BallY)>0
SpeedX = SpeedX* -1
ENDIF
ENDFUNCTION
FUNCTION ResetBallAndPaddles()
BallX = 320
BallY= 240
PaddleX1 = 5
PaddleY1 = 200
PaddleX2 = 625
PaddleY2 = 200
ENDFUNCTION
FUNCTION UpdateScore()
TEXT 50,10,"PLAYER 1: " + STR$(PlayerOnePoints) + " Points"
TEXT 440,10, "PLAYER 2: " + STR$(PlayerTwoPoints) + " Points"
ENDFUNCTION
FUNCTION EndOfGame()
SYNC OFF
CLS
SET TEXT SIZE 48
CENTER TEXT 320, 120, "Game Over!"
SET TEXT SIZE 24
CENTER TEXT 320,210, "Player 1: " + STR$(PlayerOnePoints)
CENTER TEXT 320,240, "Player 2: " + STR$(PlayerTwoPoints)
SET TEXT SIZE 16
CENTER TEXT 320,300, "Press any key to start a new game"
WAIT KEY
PlayerOnePoints = 0
PlayerTwoPoints = 0
CLS
SYNC ON
END FUNCTION
Any help would be appreciated, cheers.
If women ran the world we wouldn't have wars, just intense negotiations every 28 days.
Robin Williams