Thread: This won't compile

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    208

    This won't compile

    this will not compile

    Code:
    #include <allegro.h>
    
    int main() 
    {        
     allegro_init();      
     set_gfx_mode(GFX_AUTODETECT, 640,480,0,0); 
     install_keyboard();
     set_color_depth(16);
    /******************** Main Menu **************************************/
     while (!key[KEY_ESC]){
     BITMAP *main; 
     main = load_bitmap("main.bmp", NULL); 
     
     acquire_screen();
     
     blit(main, screen, 0,0,0,0,640,480); 
     
    
     if (key[KEY_1]||key[KEY_1_PAD])
     {clear_to_color(screen, 0);
       readkey();
     }
     
     if (key[KEY_2]||key[KEY_2_PAD])
     {clear_to_color(screen, 1);
       readkey();
     }
     
     if (key[KEY_3]||key[KEY_3_PAD])
     {clear_to_color(screen, 2);
       readkey();}
     } 
     release_screen();
    
     destroy_bitmap(main);//error here
     allegro_exit();
     return 0;     
    }     
    
    
    END_OF_MAIN();
    this is the error I get


    cannot convert `int (*)()' to `BITMAP*' for argument `1' to `

  2. #2
    Has a Masters in B.S.
    Join Date
    Aug 2001
    Posts
    2,263
    it's name is main!!! the compiler is gonna think you mean the main function, this name is reserved use something else, like 'mainbmp' or something.
    ADVISORY: This users posts are rated CP-MA, for Mature Audiences only.

  3. #3
    Rambling Man
    Join Date
    Jan 2002
    Posts
    1,050
    do it like this instead

    Code:
    #include <allegro.h>
    
    void setup();
    void load();
    
    BITMAP *bmp;
    BITMAP *buffer;
    
    int main() 
    {        
     
     setup();
     load(); 
     
     blit(main, buffer, 0,0,0,0,SCREEN_W,SCREEN_H); 
     blit(buffer, screen, 0,0,0,0,SCREEN_W,SCREEN_H);
    
    while(!key[KEY_ESC])
     { 
    
     if (key[KEY_1]||key[KEY_1_PAD])
     {clear_to_color(buffer, 0);
       clear_keybuf();
     }
     
     if (key[KEY_2]||key[KEY_2_PAD])
     {clear_to_color(buffer, 1);
       clear_keybuf();
     }
     
     if (key[KEY_3]||key[KEY_3_PAD])
     {clear_to_color(buffer, 2);
       clear_keybuf();
     }
    
     acquire_screen();
     blit(buffer, screen, 0,0,0,0,SCREEN_W,SCREEN_H); 
     release_screen();
    
     }
    
    allegro_exit();
    return 0;     
    }     
    
    END_OF_MAIN();
    
     
    void setup()
     {
     allegro_init(); 
     install_keyboard(); 
     set_color_depth(32);    
     set_gfx_mode(GFX_AUTODETECT, 640,480,0,0); 
     }
    
    void load()
     {
      bmp = load_bitmap("main.bmp", NULL); 
      buffer = create_bitmap(SCREEN_W, SCREEN_H);
     }
    
    /* I did not compile this code so there might be a few parse errors or something like that, but I don't think there are any.  All in all, though, the basic concept of the code works for sure.
    If you have any further questions, then just ask them. However, I probably won't be able to answer them until later. Btw, allegro.cc is a very good site for allegro users.

  4. #4
    Registered User
    Join Date
    May 2002
    Posts
    208

    Thanx Guys

    Your suggestions worked. But now I have another question. what is the input text function for allegro. I want the user to input their name and I can't seem to find any referances to an input function in allegro.

  5. #5
    "The Oldest Member Here" Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,039
    Code:
    char name[15];
    cin >> name; //include iostream.h
    or if you want spaces
    Code:
    char name[15];
    cin.getline(name, 15);
    i didn't answer your question did i

  6. #6
    Registered User
    Join Date
    May 2002
    Posts
    208

    no

    no what I wuz wondering was if there was a input function within allegro. I have seen it done before in games that I would asume were created in allegro but I dunno.
    Jeff Paddon
    Undergraduate Research Assistant
    Physics Department
    St. Francis Xavier University

  7. #7
    Rambling Man
    Join Date
    Jan 2002
    Posts
    1,050
    I'm assuming your not talking about regular game input, rather large strings input. Like typing in your name for a character or something like that, right?

    Well, if so then this link at allegro.cc could be useful:


Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C and C++ compile speed
    By swgh in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 01-02-2007, 02:37 PM
  2. Compile as you type
    By Rocketmagnet in forum A Brief History of Cprogramming.com
    Replies: 33
    Last Post: 12-07-2006, 01:36 PM
  3. How to compile mfc libs from platform sdk
    By tjcbs in forum Windows Programming
    Replies: 6
    Last Post: 11-19-2006, 08:20 AM
  4. Compile crashes certain windows
    By Loduwijk in forum C++ Programming
    Replies: 5
    Last Post: 03-26-2006, 09:05 PM
  5. How can I compile C or C++ with Visual Studio .NET?
    By Dakkon in forum C Programming
    Replies: 8
    Last Post: 02-11-2003, 02:58 PM