allegro

This is a discussion on allegro within the C++ Programming forums, part of the General Programming Boards category; could someone write me a sample allegro program in C++ just a spuare or a triangle just enough to get ...

  1. #1
    Banned
    Join Date
    Oct 2004
    Posts
    250

    allegro

    could someone write me a sample allegro program in C++
    just a spuare or a triangle just enough to get me going

  2. #2
    Registered User
    Join Date
    Jul 2004
    Posts
    12
    This is a newb question but what is Allegro?
    AIM-PlatinumMjolnir
    Gmail-XenoForce@gmail.com

  3. #3
    Arggggh DeepFyre's Avatar
    Join Date
    Sep 2004
    Posts
    227
    >>This is a newb question but what is Allegro?
    It is kind of like an addition to C++ meant for game programming.
    Keyboard Not Found! Press any key to continue. . .

  4. #4
    Registered User ~Kyo~'s Avatar
    Join Date
    Jun 2004
    Posts
    319
    they have plenty of demos at www.allegro.cc this is more of a game programming question should be moved to the game fourm people in there know allegro a bit more. The easiest way to use graphics in allegro is to use bitmaps and blits IMHO. drawing lines and such isn't what the library is designed for. So sample code for a triangle?

    Code:
    #include <allegro.h>
    const int scrx = 1024;
    const int scry = 768;
    const int BSIZE = 960;
    
    BITMAP *TRI;
    RGB *TRIPAL;
    
    int main(int argc, char *argv[])
    {
      if (allegro_init())
      {
        allegro_message("Cannot initalize Allegro.\n");
        return 1;
      }
    if (install_keyboard()) 
      {
        allegro_message("Cannot initalize keyboard input.\n");
        return 1;
      }
    
      if (!install_mouse()) 
      {
        allegro_message("Cannot initalize mouse input.\n");
        return 1;
      }
      set_mouse_sprite(NULL);
      //set graphics mode, trying all acceptable depths
      set_color_depth(32);
      if (set_gfx_mode(GFX_AUTODETECT, scrx, scry, 0, 0)) {
        set_color_depth(24);
        if (set_gfx_mode(GFX_AUTODETECT, scrx, scry, 0, 0)) {
          set_color_depth(16);
          if (set_gfx_mode(GFX_AUTODETECT, scrx, scry, 0, 0)) {
            set_color_depth(15);
            if (set_gfx_mode(GFX_AUTODETECT, scrx, scry, 0, 0)) {
              allegro_message("Video Error: %s.\n", allegro_error);
              return 1;
            }
          }
        }
      }
      TRI = load_bitmap("triangle.bmp",TRIPAL);//make a bitmap in paint or whatever and save it as triangle
      blit(TRI,screen,0,0,0,0,50,50); // change 50's to max X and max Y of the bitmap
    while(!key[KEY_ESC){}
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Allegro in C for a newb
    By Ideius in forum C Programming
    Replies: 5
    Last Post: 12-29-2005, 03:36 PM
  2. Game Programming FAQ
    By TechWins in forum Game Programming
    Replies: 5
    Last Post: 09-29-2004, 02:00 AM
  3. double buffering for allegro
    By Leeman_s in forum C++ Programming
    Replies: 6
    Last Post: 09-12-2002, 02:45 PM
  4. Special Allegro Information
    By TechWins in forum Game Programming
    Replies: 12
    Last Post: 08-20-2002, 11:35 PM
  5. Allegro programming in a window
    By Person Man in forum Windows Programming
    Replies: 0
    Last Post: 11-16-2001, 02:23 PM

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