Rotation

BlitzPlus Forums/BlitzPlus Beginners Area/Rotation

SuperSonic7(Posted 2009) [#1]
Still doing the same thing (see forum posting before this one). I want the ship to always be facing the cursor, but I know that's a problem since the RotateImage command does not run in real-time. Is there any solution here?


Sauer(Posted 2009) [#2]
You need to rotate all of your images ahead of time and store them in an array. Then you just index the array with the angle you want it to be at.

I made some code for a similar topic, here:
http://www.blitzbasic.com/Community/posts.php?topic=82064#925355


Matty(Posted 2009) [#3]
Or rotate the images outside of your game and store them in in animated image (see the loadanimimage command for instance). That way you simply use the frame argument when drawing your image.


CloseToPerfect(Posted 2009) [#4]
I just did this and the way I did it was an array. There may be a better way but here is what I did.

tankbase=LoadImage("tankbase.bmp")
Dim tankGFX(360)
For x=0 To 359
	tankGFX(x)=CopyImage(tankbase) 
	MaskImage tankGFX(x),255,0,255 ; set transparrency color
	MidHandle tankGFX(x) ; set center of image
	RotateImage tankGFX(x), x
Next


Now once I know what angle I want it to face I use that for the number of the array, for example if I want it turned to angle 57,

DrawImage tankGFX(57),x,y


CTP


SuperSonic7(Posted 2009) [#5]
Okay, I'll try these options and see what works out. Thanks! :)