Hey guys i just made my first pong game and here it is, but i need help with the AI if i could for some reason i make it to hard or to easy but here is the code for it.
sync on
sync rate 40
hide mouse
load image "paddle1.bmp",1
load image "paddle2.bmp",2
load image "ball.bmp",3
load image "background.bmp",4
load music "Futures.mp3",1
play music 1
oneypos=1
onexpos=1
twoypos=1
twoxpos=620
ballx=150
bally=150
movey=rnd(1)
movex=rnd(1)
onegoal=0
twogoal=0
movepx=rnd(1)
movepy=rnd(1)
backgroundx=1
backgroundy=1
do
paste image 4,1,1
set text opaque
text 1,1, "Points:"+str$(onegoal)
text 558,1, "Points:"+str$(twogoal)
if upkey() = 1 then oneypos = oneypos - 7
if downkey() = 1 then oneypos = oneypos + 7
if oneypos < 1 then oneypos = oneypos + 7
if oneypos > 432 then oneypos = oneypos - 7
sprite 1,onexpos,oneypos,1
if upkey()=1 then if movey = 1 then twoypos = twoypos - 5
if downkey()=1 then if movex = 1 then twoypos = twoypos + 6
sprite 2,twoxpos,twoypos,2
if twoypos < 1 then twoypos = twoypos + 7
if twoypos > 432 then twoypos = twoypos - 7
if movey = 1 then bally = bally + 5
if movey = 0 then bally = bally - 5
if movex = 1 then ballx = ballx + 5
if movex = 0 then ballx = ballx - 5
sprite 3,ballx,bally,3
if sprite hit(1,3) = 1 then movex = 1
if sprite hit(2,3) = 1 then movex = 0
if ballx < 1 then movex = 1:twogoal = twogoal + 1
if ballx > 620 then movex = 0:onegoal = onegoal + 1
if bally < 1 then movey = 1
if bally > 432 then movey = 0
if onegoal = 10
text 100,150,"Player 1 Has Won!"
wait 300
end
endif
if twogoal = 10
text 100,150,"Player 2 Has Won!"
wait 300
end
endif
sync
loop
People think DarkBASIC is for noobs and isnt professional, but i think its the future of game programming. Do you agree with me? Just reply to this thread saying you do.
DarkBASIC for ever!