2D Rotation Confusion

Blitz3D Forums/Blitz3D Beginners Area/2D Rotation Confusion

Crazy4Code(Posted 2005) [#1]
I'm confused on how to do rotation in 2D. Since you can't do it real time, how do you pre rotate them. I tried storing them in an array, but it took forever to load then. Could anyone just show me a method to do this?


SoggyP(Posted 2005) [#2]
Hello.

Create an image with as many frames as you want in your rotation, setbuffer to image(frame_no) rotate and draw the image.

Then you can use drawimage image,x,y,frame as required.

Goodbye.


Crazy4Code(Posted 2005) [#3]
What do you mean Setbuffer to Image? You mean like Setbuffer BackBuffer()? And if so, then do I have to setbuffer Backbuffer after? Sorry, i'm a little confused.


Crazy4Code(Posted 2005) [#4]
oh wait, nevermind, I get it. But I don't see how this would make it any faster.


SoggyP(Posted 2005) [#5]
Hello.

No, it won't make it any faster, you're right. However, what you might want to consider is loading one image, doing the rotation into a multi-frame image as part of the game loading process and there you go. It has to take place at some point, when is up to you - there's no way of making it faster, per se.

Goodbye.


Matty(Posted 2005) [#6]
In a paint program create your object, example a little 2d spaceship of size 64x64 (could be any size really). In the paint program rotate the image through 45 degrees 7 times and paste each rotated image one after the other in an imagestrip. This would give you an image strip of 8 frames possibly of size 512x64. Then load it using the loadanimimage command and draw it using the drawimage command as normal.

http://www.blitzbasic.com/b3ddocs/command.php?name=LoadAnimImage&ref=2d_cat


tonyg(Posted 2005) [#7]
You can do this before your mainloop...
For iLoop=0 To iNumRotations-1
       Ship_Player(iLoop)=CopyImage( Image_Temp )
       RotateImage Ship_Player(iLoop),iLoop*360/iNumRotations
   Next



IPete2(Posted 2005) [#8]
Why not make it into a sprite and do it in 3d?? This is the Blitz 3D forum right?

IPete2.


IPete2(Posted 2005) [#9]
.


Ross C(Posted 2005) [#10]
Best to prerotate the image as suggested. But, not in game. Do it, create your image strip and use that. :o) I heard TFormImage was slightly faster.


IPete2(Posted 2005) [#11]
Grantyt3,

I have the solution for you, find the 'Image Packer 1.05b' download (by Jim Brown) here:

http://homepage.ntlworld.com/config/imagepacker/index.htm

Now have a look at the rotation code for his 2d blitz sprites - its wonderfully smooth and easy to implement.

Regards,

IPete2.


tonyg(Posted 2005) [#12]
Doesn't that use 3D though? I realise you've already suggested using 3D but the question was regarding 2D.
btw, I would also use 2D in 3D with either SMPro, NSprite (both free) or NSprite Pro, SpriteCandy (both fee but excellent).
I've mixed SpriteCandy with pure 2D images and don't get too many problems although it's been suggested this can lead to performance issues.


IPete2(Posted 2005) [#13]
Tonyg,

Jeeps you're right dude!

On looking more carefully at the code again, there's a comment which says '; set up 3d display -> gfxmode/camera/sprite pivot'

Doh!

I had just looked at the sprite graphics code below and thought it was 2d.

Oops, Sorry! I'll just go and lie down and be quite somewhere...
IPete2.


Crazy4Code(Posted 2005) [#14]
I just did a smaller array and that worked fine. It probably won't work when I want smaller turns though.