Hey guys, I'm trying to create a pong clone on DBC as my 2nd program I've made and came to somewhere I need some help. First I want to see if the way I'm going about this program is right, if it isn't then could someone show me how I should rewrite some parts? Second could someone show me a better AI I could use, insted of this unbeatable one. Thanks.
Rem declare and give arrays variables
DIM PaddlePos1y(1)
DIM PaddlePos2Y(1)
DIM BallPosX#(1)
DIM BallPosY#(1)
DIM BallPosY#(1)
DIM BallSpeedX#(1)
DIM BallSpeedY#(1)
PaddlePos1y(1) = 250
PaddlePos2Y(1) = 250
BallPosX#(1) = 320
BallPosY#(1) = 420
BallSpeedX#(1) = 3
BallSpeedY#(1) = 3
Rem Set game up
CreateStage()
CreateBall()
Createpaddles()
HIDE MOUSE
SYNC ON
Rem Main Loop
DO
SPRITE 1,BallPosX#(1),BallPosY#(1),2
SPRITE 2,0,PaddlePos1Y(1),1
SPRITE 3,633,PaddlePos2Y(1),1
MoveBall()
ControlPaddle1()
CompPaddle2()
SYNC
LOOP
WAIT KEY
END
FUNCTION CreateBall()
CREATE BITMAP 2 ,21,21
SET CURRENT BITMAP 2
CIRCLE 10,10,10
GET IMAGE 2,0,0,21,21
ENDFUNCTION
FUNCTION Createpaddles()
CREATE BITMAP 1,6,41
SET CURRENT BITMAP 1
BOX 0,0,5,40
GET IMAGE 1,0,0,6,41
ENDFUNCTION
FUNCTION CreateStage()
SET DISPLAY MODE 640, 480, 16
INK RGB(255,255,255),RGB(0,0,0)
SET CURRENT BITMAP 0
LINE 0,0,640,0
LINE 0,479,640,479
LINE 320,479,320,0
ENDFUNCTION
FUNCTION MoveBall()
BallPosX#(1) = BallPosX#(1) + BallSpeedX#(1)
BallPosY#(1) = BallPosY#(1) + BallSpeedY#(1)
IF BallPosY#(1) > 460
BallSpeedY#(1) = BallSpeedY#(1) * -1
ENDIF
IF BallPosY#(1) < 0
BallSpeedY#(1) = BallSpeedY#(1) * -1
ENDIF
IF SPRITE HIT(3, 1) = 1
BallSpeedX#(1) = BallSpeedX#(1) * -1 -.2
ENDIF
IF SPRITE HIT(2, 1) = 1
BallSpeedX#(1) = BallSpeedX#(1) * -1 +.2
ENDIF
ENDFUNCTION
FUNCTION ControlPaddle1()
IF UPKEY() = 1 And PaddlePos1Y(1) > 1
PaddlePos1Y(1) = PaddlePos1Y(1) + -4
ENDIF
IF DOWNKEY() AND PaddlePos1Y(1) < 439
PaddlePos1Y(1) = PaddlePos1Y(1) + 4
ENDIF
ENDFUNCTION
FUNCTION CompPaddle2
PaddlePos2Y(1) = BallPosY#(1)
ENDFUNCTION