I changed your media to DBP generated media so I could run your code. NOW I know what you mean. The problem lies in this part of your code:
do
`Player Control for 1
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
`The paddle sprite
sprite 1,onexpos,oneypos,1
bally = sprite Y(1)+10
`Player 2 Paddle
if inkey$() = "w" then twoypos = twoypos - 7
if inkey$() = "s" then twoypos = twoypos + 7
sprite 2,twoxpos,twoypos,2
if twoypos < 1 then twoypos = twoypos + 7
if twoypos > 432 then twoypos = twoypos - 7
`kogel
if inkey$() = "m" and pf = 0
pf=1
endif
if pf=1
gosub shoot
else
sleep 1
endif
sync
loop
More specifically, it's right here:
`The paddle sprite
sprite 1,onexpos,oneypos,1
bally = sprite Y(1)+10
You tell "bally" to always equal sprite 1's Y Position plus 10 because it's in the loop. It's getting run over and over again, so bally is being set equal to Sprite 1's Y Position over and over again. You only want this to happen once: when the player shoots the ball. All you really need to do is put this:
with your "if inkey$() = "m" and pf = 0" statement. So, that part should end up looking like this:
`kogel
if inkey$() = "m" and pf = 0
pf=1
bally = sprite Y(1)+10
endif
And your entire code should be like this:
sync on
sync rate 30
hide mouse
`Load the images
load image "paddle1.jpg",1
load image "paddle2.jpg",2
load image "kogel.jpg",3
` Start the main game loop
` Setup some variables first
oneypos = 1
onexpos = 1
twoypos = 1
twoxpos = 610
ballx = 30
pf = 0
move = 1
color backdrop rgb(0, 0, 0)
do
`Player Control for 1
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
`The paddle sprite
sprite 1,onexpos,oneypos,1
`Player 2 Paddle
if inkey$() = "w" then twoypos = twoypos - 7
if inkey$() = "s" then twoypos = twoypos + 7
sprite 2,twoxpos,twoypos,2
if twoypos < 1 then twoypos = twoypos + 7
if twoypos > 432 then twoypos = twoypos - 7
`kogel
if inkey$() = "m" and pf = 0
pf=1
bally = sprite Y(1)+10
endif
if pf=1
gosub shoot
else
`sleep 1
endif
sync
loop
shoot:
sprite 3,ballx,bally,3
ballx=ballx+15
if sprite exist(3)=1 and ballx>=680
ballx=30
pf=0
endif
return
Good luck
EDIT: I noticed that the ball stays at the right side of the screen when it's done moving, even though you set "ballx" equal to 30. This is because "pf" gets set to 0 so the sprite isn't updated until "pf" is equal to 1 again. To fix this you would need to do one of two things:
1) Draw the sprite again right after you set pf equal to 0.
OR
2) Cut and paste your SPRITE command to be after that IF statement.
If you wanted the ball to stay there then ignore this comment