Rotating the screen 90°... possible?
Marton

I'd like to be able in my game at some point rotate the screen 90°... Is this possible without having to use rotated fonts/objects so they display correctly rotated???

Thanks!!

brigham toskin

instead of drawing directly to the screen when displaying your code, write it to an offscreen bitmap. You can then transfer that to the screen with rotate_sprite() or related function. You'll take a performance hit, but it might not really be noticeable on modern hardware.

TeamTerradactyl

Do you mean simplyp drawing your "completely rendered" BITMAP to your screen, flipped 90-degrees? If so, you can probably very simply employ the rotate() function (see forum thread http://www.allegro.cc/forums/thread/323382 for others trying to do something similar...).

Marton

Will check the thread, thanks!
What I need to do is have a textprintf() call that would write text rotated 90°... Can I do the printf to a bitmap buffer and then rotate it?

brigham toskin

yes

Marton

How am I supposed to do it? It doesn't rotate and the bitmap appears one pixel to the left and one down... I know this may be bad code but hey I'm learning :)

DATAFILE *datafile;
BITMAP *bitmap, *temp;

bitmap = create_bitmap(320,200);
temp = create_bitmap(320,200);
text_mode(-1);
set_color_depth(16);
set_color_conversion(COLORCONV_TOTAL);

datafile = load_datafile("test.dat");
blit(datafile[1].dat, bitmap, 0, 0, 0, 0, 320, 200);
textprintf_centre(bitmap, datafile[0].dat, 160, 165, makecol(255, 0, 0), "Please wait... ");
rect(bitmap, 50, 195, 267, 175, makecol(255, 255, 255));
rect(bitmap, 0, 199, 319, 0, makecol(255, 255, 255));
rotate_sprite(temp, bitmap, 0, 0, 90);
blit(temp, screen, 0, 0, 0, 0, 320, 200);
destroy_bitmap(bitmap);
destroy_bitmap(temp);
unload_datafile(datafile);

kazzmir

A) you have to used 'fix' numbers
B) the angle is really 0-255, not 0-360.

rotate_sprite( temp, bitmap, 0, 0, itofix( 64 ) );

In general to convert 0-360 into 0-255 use this

angle * 256 / 360

Marton

Thanks!!! That was the trick!

Fladimir da Gorf

If you want performance, there's more efficient ways to rotate a bitmap 90 decrees (as it's a special case of rotation). However, you'll need to write your own drawing function for that.

miran

I think roatate_sprite already does multiples of 90 degrees with specialized more efficient code.

Tobias Dammers

Yes it does. At least the C version of the code contains a comment somewhere about the trivial cases (i.e. multiples of 90 degrees).

Arthur Kalliokoski

Does this game use matrices to set screen positions? If so, you could alter a few members of the matrix and it'll get rotated automagically.

Marton

Nope, no matrices. Anyway with rotate_sprite it works like a charm :)

Thanks!!

Thread #587827. Printed from Allegro.cc