Rotating bitmap in local and global axis ?
Thinkal VB

My 2D top-down shooter game wants some syntactic sugar to rotate the bitmap and the whole bitmap around another bitmap or point (which is the player). Please help me out
Thanks in advance

Edgar Reynaldo

Do yourself a favor and draw out what you want to do on paper and look at the math. Then it should be clear how to proceed programming your app.

Dizzy Egg
rotate_bitmap_around_another_bitmap();

Cookies please.

Edgar Reynaldo

Hey Dizzy, looks like your shell is still intact. Glad to hear it. ;D

Drop some sick beats

Thinkal VB

Edgar Reynaldo and Dizzy Egg - than you for the replay.
I will try to sort out a way to do that using trigonometry or simple geometric mathematics.

Edgar Reynaldo

It's the sum of two angles and a point rotated around the circle.

Neil Roy

Take the rotation of the world, add in the rotation of the object in the world with it, then draw it on your rotated world.

Thinkal VB

Edgar Reynaldo and Neil Roy- thank you for replying
I fixed it using the transform

al_identity_transform(&transform);
al_translate_transform(&transform, -playerX, -playerY);
al_rotate_transform(&transform, cameraRotation * 3.14 / 180);
al_translate_transform(&transform, playerX, playerY);
al_use_transform(&transform);

when drawing the player i used rotation (360 - cameraRotation), so that the player won't rotate, rather the world will rotate around the player.

Edgar Reynaldo

Thinkal_VB, glad you solved it. See, you could do it!

Thinkal VB

Thank you Edgar Reynaldo, for your compliments and help.

Elias

You should probably use a few more decimal places with your 3.14 constant there or after you spin the camera a few times it will start being off...

Eric Johnson
Elias said:

You should probably use a few more decimal places with your 3.14 constant there or after you spin the camera a few times it will start being off...

He should use ALLEGRO_PI.

Thinkal VB

Thank you Elias and Eric Johnson,
I used #define PI 3.14159f in my actual code.
That code was purely representational(in the post). However, thank you for letting me know about the ALLEGRO_PI. I will change my code to use ALLEGRO_PI as it is more precise.

Thread #617439. Printed from Allegro.cc