k i updated the code somewhat it runs smooth enough, only not in the beginning dunno why but i got still got 2 probs, maybe someone can take a look at it and help me sort them out
first the code:
`breakout clone dmv sprites :p
rem blokskes
box 1,1,50,10
get image 1, 1,1,50,10
cls
rem balleke
circle 5,5,5
get image 2,0,0,15,15
cls
rem paddle
ink rgb(100,100,100),rgb(200,100,200)
box 1,1,100,20
get image 3,1,1,100,20
cls
rem images for border
ink rgb(250,250,250),0
box 1,20,637,22
get image 4,1,20,637,22
box 637,20,639,477
get image 5,637,20,639,477
box 1,477,639,479
get image 6,1,477,639,479
box 1,20,3,477
get image 7,1,20,3,477
cls
load sound "explode.wav",1
hide mouse
rem player vars
playerx=300
playery=440
rem ball vars
ballx=320
bally=240
balla=180
balls=4
rem extra vars
aantal=8
levens=3
wachten=0
links=0
rechts=0
rem array for blocks
dim blokken(8)
for t=1 to 8
blokken(t)=1
next t
SET TEXT OPAQUE
TEXT 310,1, "Lives"
sync rate 60
do
rem controls
if leftkey() =1
playerx= playerx-10
endif
if rightkey()=1
playerx=playerx+10
endif
rem paddle niet van het screen af
if playerx <5 then playerx=5
if playerx>535 then playerx=539
rem nieuwe cords voor bal
ballx=newxvalue(ballx,balla,balls)
bally=newzvalue(bally,balla,balls)
rem sprite-int all the images
for t=1 to 8
if blokken(t)=1
sprite t,30+t*55,30,1
endif
next t
sync
sprite 9,ballx,bally,2
sprite 10,playerx,playery,3
sprite 11,1,20,4
sprite 12,637,20,5
sprite 13,1,477,6
sprite 14,1,20,7
rem collision with border
if sprite hit(9,11)
balla=0+(180-balla)
endif
if sprite hit(9,12)
balla=360-balla
endif
rem bottom
if sprite hit(9,13)
levens=levens-1
playerx=300
playery=440
ballx=320
bally=240
balla=180
wachten=1
endif
if sprite hit(9,14)
balla=360-balla
endif
rem collision with paddle
IF SPRITE HIT(9,10) = 1
if (playerx-ballx)<0 and playerx-ballx>-25
balla=360-balla
balla=(180-balla)+(rnd(10)+10)
`balla=195
else
if playerx-ballx<-75
balla=180-balla-(rnd(10)+10)
else
balla=180-balla
endif
endif
endif
rem collision with blocks
for d=1 to 8
if blokken(d)=1 and sprite hit(d,9)=1
balla=0+(180-balla)
delete sprite d
blokken(d)=0
aantal=aantal-1
play sound 1
endif
next d
fps=screen fps()
TEXT 310,1, "Lives "+str$(levens)+" "+str$(fps)+" "+str$(balla)+" "+str$(playerx-ballx)
rem when live is lost
if wachten=1
delete sprite 9
text 320,240,"3"
wait 1000
text 320,240,"2"
wait 1000
text 320,240,"1"
wait 1000
cls
for t=1 to 8
if (blokken(t)=1)
sprite t,30+t*55,30,1
endif
next t
sync
sprite 9,ballx,bally,2
sprite 10,playerx,playery,3
wachten=0
endif
loop
So my two problems are:
1)Sometimes when the ball hits the left, top or right sprite it gets stuck, it just keeps changing the angle but it keeps stuck in that sprite, for example when i hit the left border it just keeps on hitting it and going out and hitting it and so on. It just trembles against that sprite. (it ll be a lot clearer when you play it :p)
2)I think i did something wrong with my angles caus when the ball hits the paddles it sometimes does unpredictable things (it makes a wrong angle with it)
So if anyone know how to improve this/fix it i would be very happy
tia