Advertisement

code help

Started by December 11, 2002 06:56 PM
3 comments, last by craphead 21 years, 11 months ago
why wont this work
  
#include <allegro.h>



const int scrx = 640;
const int scry = 480;

int main(int argc, char* argv[]) {
  if (allegro_init()) {
    allegro_message("Cannot initalize Allegro.\n");
    return 1;
  }

  
  set_window_title("Hello World");

  if (install_keyboard()) {
    allegro_message("Cannot initalize keyboard input.\n");
    return 1;
  }

  
  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;
        }
      }
    }
  }

  
  text_mode(makecol(0, 0, 255));

  
  textout_centre(screen, font, "Hello World!!!", scrx/2,
                 scry/2, makecol(255, 255, 0));

  
  while (!keypressed()) {}

  return 0;
 
}
END_OF_MAIN()




  
shuv-it
50/50 Robotics and Software
Need more data to compute.

What is not working?
Does the program not compile? Does the program compile and not run?
Does it run and produce one of those error messages, like allegro not initialized?
-------------------------GBGames' Blog: An Indie Game Developer's Somewhat Interesting ThoughtsStaff Reviewer for Game Tunnel
Advertisement
You probably didn''t add -lalleg to the linker options.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.
I am not an expert but here are some strange things I noticed.

if (allegro_init()) { allegro_message("Cannot initalize Allegro.\n"); return 1; }

This says "if allegro initiats post an error message and return" maybe I missid something but I think you should have:

if(!allegro_init){...

The same goes for the other if statement. You want to check if it DOESN''T work so you make it do that by using the "!" wich says it returned false.
quote:
Currently this function always returns zero. If no system driver can be used, the program will abort.


I assume that means a non zero result would mean failure if they ever decided to allow it to fail.

I think most functions return 0 if everything it okay, with the exception of install_mouse() which returns the number of mouse buttons, and -1 if there is an error.
Chess is played by three people. Two people play the game; the third provides moral support for the pawns. The object of the game is to kill your opponent by flinging captured pieces at his head. Since the only piece that can be killed is a pawn, the two armies agree to meet in a pawn-infested area (or even a pawn shop) and kill as many pawns as possible in the crossfire. If the game goes on for an hour, one player may legally attempt to gouge out the other player's eyes with his King.

This topic is closed to new replies.

Advertisement