allegro rotation?

This is a discussion on allegro rotation? within the Game Programming forums, part of the General Programming Boards category; Hey all, I'm lookin' to start up a non-grid strategy game, and I've hit a problem with rotating the bmp's ...

  1. #1
    GA ichijoji's Avatar
    Join Date
    Nov 2002
    Posts
    179

    allegro rotation?

    Hey all, I'm lookin' to start up a non-grid strategy game, and I've hit a problem with rotating the bmp's for units so that they face the right way. Here's the code that I have, but it doesn't work:
    Code:
    PALETTE pal;
    get_palette(pal);
    BITMAP * bmp = load_bmp(filename.c_str(),pal);
    fix_image_pal(bmp,pal);
    fixed angle = 0, scale = fixed((SCREEN_W/4)/(bmp->w/2));
    while (!key[KEY_ESC]) {
      clear_bitmap(buffer);
      rotate_sprite(buffer,bmp,SCREEN_W/2-(bmp->w/2),SCREEN_H/2-(bmp->h/2),angle);
      if (++angle >= 256) angle = 0;
      textprintf_centre(buffer,font,SCREEN_W/2,SCREEN_H/4,15,"angle = %d",angle);
      blit(buffer,screen,0,0,0,0,SCREEN_W,SCREEN_H);
    }
    When I run this the picture just sits in the middle, not rotating. I also attached a zip with all of everything you'd need to see this in action (except alleg40.dll). I was wondering if anybody knows why this isn't working or how I could fix it, thx.
    Attached Files Attached Files
    Illusion and reality become impartiality and confidence.

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    380
    try using fixtoi(angle) in rotate_sprite.
    Don't you dare hit me on the head, you know I'm not normal.
    A Stooge Site
    Green Frog Software

  3. #3
    GA ichijoji's Avatar
    Join Date
    Nov 2002
    Posts
    179
    I found the solution to this in an old techwins post (search first? well I never!), I needed to make angle a float then pass it to rotate_sprite() like ftofix(angle).
    Illusion and reality become impartiality and confidence.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. camera rotation matrix
    By Vick jr in forum Game Programming
    Replies: 5
    Last Post: 05-26-2009, 09:16 AM
  2. Image rotation - doesn't always work
    By ulillillia in forum C Programming
    Replies: 12
    Last Post: 05-03-2007, 01:46 PM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 04:00 PM
  4. sprite rotation in allegro
    By thedumbmutt in forum Game Programming
    Replies: 4
    Last Post: 01-14-2003, 08:43 AM
  5. Special Allegro Information
    By TechWins in forum Game Programming
    Replies: 12
    Last Post: 08-21-2002, 12:35 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21