Delay Fix

Blitz3D Forums/Blitz3D Beginners Area/Delay Fix

Can anyone tell me how to make this NOT delay when trying to use it?

--------------------------------

Graphics 800,600,0,2

SetBuffer BackBuffer()

Type rocket
Field x,y,angle,iangle,speed,turnrate
End Type

Dim rocketimage(500)

TFormFilter 1

Global rocketpic = LoadImage("rocket.bmp")
For a = 0 To 360
rr = CopyImage(rocketpic)
RotateImage(rr,a)
rocketimage(a) = rr
MidHandle rocketimage(a)
Next


While Not KeyDown(1)
Cls
If MouseDown (1)

r.rocket = New rocket

r\x = Rand(1,800)
r\y = Rand(1,600)
r\angle = 0
r\speed = Rand (1,10)
r\turnrate = Rand (1,10)

End If



For h.rocket = Each rocket


h\iangle = ATan2((MouseY()-h\y),((MouseX()-h\x)))

xmov# = Cos(h\angle) * h\speed
ymov# = Sin(h\angle) * h\speed

h\x = h\x + xmov#
h\y = h\y + ymov#


realangle_current = h\angle
realangle_intend = h\iangle

If h\angle < 1
realangle_current = 180+(180 - Abs(h\angle))
End If
If h\iangle < 1
realangle_intend = 180+(180 - Abs(h\iangle))
EndIf



If realangle_intend > realangle_current And h\iangle > 0 Then h\angle = h\angle + h\turnrate
If realangle_intend > realangle_current And h\iangle < 1 Then h\angle = h\angle + h\turnrate
If realangle_intend < realangle_current And h\iangle > 0 Then h\angle = h\angle - h\turnrate
If realangle_intend < realangle_current And h\iangle < 1 Then h\angle = h\angle - h\turnrate

If realangle_current> 360 Then realangle_current = 1
If realangle_current< 1 Then realangle_current = 360


DrawImage rocketimage(realangle_current),h\x,h\y


Next



Flip


Wend

A couple of things:

"Can anyone tell me how to make this NOT delay when trying to use it?"
Make what delay when you use what?

Also take a look at the codebox tags.

when you use that scrip, images go at the mouse. But when you load it up there is about a 10 second delay before you can click your mouse to make the images show up.

The delay would come from using RotateImage. It's pretty slow. So, you can't do much about that i'm afraid :o)

You can maybe rotate the images in a paint program beforehand, then index them with either loading each image in an array or use the frame parameter.

ok then, ill just have to take the rotate image out then cuz i need that speed.

create a couple of images, each one with the same picture rotated at a different angle.

I don't really see how the speed really makes a difference to the game...unless it's taking a really long time to load :o) But saying that, if you make your image rotated in paint, give them sequencial file names, like:

image1.bmp
image2.bmp
image3.bmp
image4.bmp
image5.bmp
...
etc etc

then, in blitz, you can use a loop to load them in :o)

Dim rocketimage(7)
For loop = 1 To 7
    rocketimage(loop) = LoadImage("image"+loop+".bmp")
Next


Hope that helps somewhat :o)

already fixed, i found out i dont need the rotateimage, works alot better without it. thanks.