hi, i'm a real noob and i've picked breakout as my first 2d project
i cant get my ball to move when the mouse button is clicked
here is my code:
sync on
sync rate 70
hide mouse
`paddle coords
pX=300
pY=440
`ball coords
bX = pX
bY = pY-3
bsK = 5
bsL = 5
load bitmap "spritesheet1.bmp",1
get image 1,8,8,92,28
get image 2,100,14,108,20
get image 3,8,38,82,70
`Paddle Sprite
set current bitmap 0
sprite 1,pX,pY,1
offset sprite 1,40,-2
set sprite 1,1,1
`Ball Sprite
sprite 2,bX,bY,2
set sprite 2,1,1
`Block Sprites
sprite 3,60,40,3
sprite 4,130,40,3
sprite 5,200,40,3
`Print Score
set text font "arial black"
set text size 18
text 0,0,"Score: " + str$(score)
`Print Lives
lives = 3
set text font "arial black"
set text size 18
text 550,0,"Lives: " + str$(lives)
do
if mouseclick()=1
bX=bX+bsK:bY=by+bsl:sprite 2,mousex(),440,2:set sprite 2,1,1
endif
if bX>620:bsK=-5:endif
if bX<10:bsK=5:endif
if bY<10:bsL=5:endif
if bY>500 : wait key : lives = lives - 1 : bX=0:bY=0 : gosub ResetGame : endif
if mousex()=mousex()
pX = mousex()
endif
if px > 550
px = 550
endif
if sprite hit(2,1)
bsL = -5
endif
if sprite hit(2,3)
delete sprite 3
bsL = -5
score = score + 10
gosub score
endif
if sprite hit(2,4)
delete sprite 4
bsL = -5
score = score + 10
gosub score
endif
if sprite hit(2,5)
delete sprite 5
bsL = -5
score = score + 10
gosub score
endif
if sprite exist(3)=0
if sprite exist(4)=0
if sprite exist(5)=0
center text 320,240,"WELL DONE!"
endif
endif
endif
sprite 1,pX,pY,1
sprite 2,mousex(),440,2
sync
loop
score:
cls
score# = 0
set text font "arial black"
set text size 18
text 0,0,"Score: " + str$(score)
return
lives:
cls
lives# = 3
set text font "arial black"
set text size 18
text 550,0,"Lives: " + str$(lives)
return
ResetGame:
bX = screen width() / 2
bY = screen height() / 2 + 100
bsK = 2
bsL = 2
return
i had the ball moving once but when i stuck it to the paddle at the start of the game and used mouseclick() the ball just moves with the paddle.
can someone help???
Thanx