Turning of 2D Graphics

Blitz3D Forums/Blitz3D Beginners Area/Turning of 2D Graphics

BlitzAdict(Posted 2005) [#1]
Hello, everybody, i am writing a space shooter and want my ship to behave like in Asteroids. Im working on that and found lots of help... but if my ship turns the game slows drastically. The only command i know is rotateImage() which is too slow, and if i put all 360 degrees of the turning into an array before starting the game it takes a long time to start (especially since i have 16 different ships and stations which must turn). The search-function of this site is offline and i do not have the time to read every post in here... can anyone tell me how i can make my ships turn in realtime or how to make a loading-screen?
Thanks a lot in advance :)


Regular K(Posted 2005) [#2]
Try only 36 frames.

Or, since this is 3D, you could 3D accelerate it.


BlitzAdict(Posted 2005) [#3]
Thanks for the reply.
The rotating must be smooth... even with 72 frames the rotating looks ugly... and there is nothing better to destroy the playability of a game.
I dont think i could go lower then 180 frames, but that doesent lolve the problem of the command "RotateImage()" being way too slow.
And it is not 3D, it is 2D... can i accelerate that too? (if yes, how?)


Regular K(Posted 2005) [#4]
You could fake 2D using 3D.

But you cant really accelerate 2D.


BlitzAdict(Posted 2005) [#5]
Again, thanks for the reply.
But i have not yet advanced to 3D-Programming, so i have no idea how i could do what you suggest. But honestly thats not important, because i found a solution... My Loading-Screen now works fine and i use 180 steps. The Game will take some time to load, but now it tells the User that it takes time and how far it has advanced loading. In-Game it works perfectly and fast (and easy to programm... :))
The remaining question is, is there another way to make a 2D-Bitmat rotate except RotateImage()?


RiverRatt(Posted 2005) [#6]
RotateImage() is very slow in real time.
The best way to rotate an image is to use a precalculated array. In other words before your main loop, you make an array of 360 (because there is 360 degrees in a circle). Then you iterate through it with a For, Next statment. In each iteration you copy your image and rotate it. There is now 360 frames of the image rotated 1 degree in your array. And last you use drawimage(your frame rotation image here),400,300.

Easier done than said...



RiverRatt(Posted 2005) [#7]
Err looks like you already figured it out and I was to slow.


GfK(Posted 2005) [#8]
Why don't you write some code to rotate and export the animation frames to an animstrip? Then all you have to do is use LoadAnimImage to reload it, instead of making the player wait while your program generates it each time.


BlitzAdict(Posted 2005) [#9]
GfK, thanks for pointing me to the most logical solution... my nose is big and it hid that solution in front of my face ;))
And I wont have to recode much, either...


BlitzAdict(Posted 2005) [#10]
I wrote a piece of code to rotate an Image and export it to an animstrip. Now i would like to share it with u all, but... can u tell me how to make such a nice black window?


big10p(Posted 2005) [#11]
Forum codes


BlitzAdict(Posted 2005) [#12]
As you will see, i commented the code. It is tested to animate squared pictures.
A short summary of what it does:
1. it loads the picture you want it to animate
2. it generates a bigger picture and copies the original into the bigger one (otherwise the edges would get cut off)
3. it rotates the picture
4. it saves the rotated picture into an animstrip (which is nothing more then a really big picture)

Hint: be careful with big pictures... blitz seems to have a maximal number of pixels a picture can have that it sees it completely. (at least with LoadAnimImage())

The Code:


It surely is not perfect, but it runs perfect. And since this creates animstrips you then use in your programs, speed is not of the essence here ;)

Feel free to use the code to your liking.

/edit: corrected a bad grammatical error :)