Thread: Rotating sprites in allegro.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User ~Kyo~'s Avatar
    Join Date
    Jun 2004
    Posts
    320

    Rotating sprites in allegro.

    This code works great, but only allows a 90 degree rotation of the sprite. I assume this is because of allegro and I think every other graphics lib assuming top left is 0,0 and going from there so I am only playing in one quad... I am wondering how to make it rotate all 360 degrees do I just make a correction factor based on the screen size or what?

    Code:
    int main()
    {
        ini();
    
        player = load_bitmap("Player.bmp",NULL);
        BUFFER = create_bitmap(scrx,scry);
    
        while(!key[KEY_ESC])
        {
    
            int angle = fixatan2(mouse_y, mouse_x);
            rotate_sprite(BUFFER,player,(scrx/2),(scry/2),angle);
            show_mouse(BUFFER);
            blit(BUFFER,screen,0,0,0,0,scrx,scry);
        }
    	return 0;
    }
    END_OF_MAIN()
    Answered my own question. Subtracting half of the screen size from each var allows for 360 degree rotation. center the sprite by subbing half the size in x and y... Now to get a grappling hook working for movement...
    Last edited by ~Kyo~; 02-17-2011 at 10:54 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem with Allegro sprites
    By godly 20 in forum C++ Programming
    Replies: 16
    Last Post: 01-18-2011, 04:24 PM
  2. Game Programming FAQ
    By TechWins in forum Game Programming
    Replies: 5
    Last Post: 09-29-2004, 02:00 AM
  3. Special Allegro Information
    By TechWins in forum Game Programming
    Replies: 12
    Last Post: 08-20-2002, 11:35 PM
  4. Sprites n Allegro
    By Paninaro in forum Game Programming
    Replies: 1
    Last Post: 07-07-2002, 09:28 AM
  5. + Sprites n allegro
    By Paninaro in forum Game Programming
    Replies: 3
    Last Post: 07-07-2002, 03:15 AM

Tags for this Thread