I'm very proud of myself, I got my ball movement/bouncing code done myself, with no help. There's a couple of bugs left in the 2 player pong I need help with.
On the scoring system, when the sprite hits the sprite it doesn't go over the sprite fast enough for it to hit up 1 more point, so sometimes it adds 2-5 to the score. If someone could tell me how to make it just score once and maybe disable scoring for one second thatd be great
My current code:
Rem Project: VexenPONG
Rem Created: 11/2/2003 8:34:24 PM
Rem ***** Main Source File *****
`Setup:
balspd# = 1
balhit# = 1
set display mode 800,600,16
load image "bat.bmp",1
load image "wall1.bmp",2
load image "inviswall1.bmp",3
load image "ball.bmp",4
sprite 1,6,300,1
sprite 2,774,300,1
sprite 4,0,1,2
sprite 5,0,594,2
sprite 6,5,0,3
sprite 7,795,0,3
gosub vars
gosub bal
do
gosub vars
gosub ball
gosub ply1
gosub ply2
gosub scr1
gosub scr2
gosub balspd
loop
vars:
ply1batx# = sprite x(1)
ply1baty# = sprite y(1)
return
bal:
sprite 3,ply1batx#+5,ply1baty#+50,4
move sprite 3,5
return
ball:
if balhit# = 0
move sprite 3,-balspd#
endif
if balhit# = 1
move sprite 3,-balspd#
endif
if sprite collision (3,1) = 1
balspd# = balspd# + 1
balhit# = 1
balrnd1# = RND (15)
balrnd2# = RND (15)
balrnd3# = RND (15)
balrnd# = balrnd1#-balrnd2#/balrnd3#
rotate sprite 3,-90+balrnd#
endif
if sprite collision (3,2) = 1
balspd# = balspd# + 1
balhit# = 1
balrnd1# = RND (15)
balrnd2# = RND (15)
balrnd3# = RND (15)
balrnd# = balrnd1#-balrnd2#/balrnd3#
rotate sprite 3,90+balrnd#
endif
return
ply1:
if upkey()=1 then move sprite 1,2
if downkey()=1 then move sprite 1,-2
if sprite collision (1,4) = 1 then move sprite 1,-10
if sprite collision (1,5) = 1 then move sprite 1,10
return
ply2:
if scancode()=72 then move sprite 2,2
if scancode()=76 then move sprite 2,-2
if sprite collision (2,4) = 1 then move sprite 2,-10
if sprite collision (2,5) = 1 then move sprite 2,10
return
scr1:
if sprite collision (3,6) = 1 then scr1# = scr1# + 1
text 400,10,"Player 1: " + str$(scr1#)
return
scr2:
if sprite collision (3,7) = 1 then scr2# = scr2# + 1
text 400,25,"Player 2: " + str$(scr2#)
return
balspd:
text 400,40,"Ball Speed: " + str$(balspd#)
return