Exemplo n.º 1
0
twoDPrimitive::twoDPrimitive(){
	if(!ALLEGRO_PRIMITIVE_ADDON_INIT){
		al_init_primitives_addon();
		ALLEGRO_PRIMITIVE_ADDON_INIT = true;
	}

	this->numVertices = 0;
	this->type = TWOD_PRIMITIVE_LINE_LOOP;
	this->texture = NULL;
	this->color = new twoDColor("white");
}
Exemplo n.º 2
0
void game_init()
{
	if( ! al_init() )
		EXIT_ON_FAILURE();
	if( ! al_install_keyboard() )
		EXIT_ON_FAILURE();
	if( ! al_init_image_addon() )
		EXIT_ON_FAILURE();
	if( ! al_init_primitives_addon() )
		EXIT_ON_FAILURE();
}
Exemplo n.º 3
0
Arquivo: main.c Projeto: wjwwood/agame
int main(void) {
  if(!al_init()) {
    al_show_native_message_box(NULL, NULL, NULL,
                               "failed to initialize allegro!", NULL, 0);
    return -1;
  }

  display = al_create_display(640, 640);

  if(!display) {
    al_show_native_message_box(NULL, NULL, NULL,
                               "failed to initialize display!", NULL, 0);
    return -1;
  }

  al_init_font_addon();
  al_init_ttf_addon();
  al_init_primitives_addon();

  ALLEGRO_FONT * font24 = safe_load_font("bin/arial.ttf", 24, 0);
  if (!font24) {return -1;}
  ALLEGRO_FONT * font36 = safe_load_font("bin/arial.ttf", 36, 0);
  if (!font36) {return -1;}
  ALLEGRO_FONT * font18 = safe_load_font("bin/arial.ttf", 18, 0);
  if (!font18) {return -1;}

  al_clear_to_color(al_map_rgb(255, 255, 255));

  agame_msg("This is a message for the player of agame, but it is really "
            "long and needs to be wrapped.", font24);

  // al_draw_text(font24, al_map_rgb(255, 0, 255), 50, 50, 0,
  //              "Hello World, this is 24 point");
  // al_draw_text(font36, al_map_rgb(255, 127, 127), 640 / 2, 480 / 2,
  //              ALLEGRO_ALIGN_CENTRE, "This is Centered and 36 point");
  // al_draw_text(font18, al_map_rgb(15, 240, 18), 620, 350, ALLEGRO_ALIGN_RIGHT,
  //              "This is right aligned and 18 point");

  // al_draw_textf(font18, al_map_rgb(255, 255, 255), screen_w/2, 400,
  //               ALLEGRO_ALIGN_CENTRE,
  //               "TEXT with variable output (textf): Screen width and height "
  //               "= %i / %i" , screen_w, screen_h);

  al_flip_display();

  al_rest(4.0);

  al_destroy_font(font18);
  al_destroy_font(font24);
  al_destroy_font(font36);
  al_destroy_display(display);

  return 0;
}
Exemplo n.º 4
0
void initGameEngine()
{
	if (!al_init()) {
		FatalErrorDialog("Allegro 5 core library initialization failed.");
	}
	if (!al_init_image_addon()){
		FatalErrorDialog("Allegro image add-on initialization failed.");
	}
	if (!al_init_primitives_addon()){
		FatalErrorDialog("Allegro primitives add-on initialization failed.");
	}
}
Exemplo n.º 5
0
View::View(int rectSize) : rectSize_(rectSize){
	al_init();                 //inicjalizacja 
	al_init_primitives_addon();//inicjalizacja primitywow  
	display = al_create_display(640, 640);
	bgColor=al_map_rgb(100,100,130);
	offset=10;
	al_clear_to_color(bgColor);//al_map_rgb(0,33,0)); //kolor tla
	//al_draw_filled_rectangle(50,50,100,100,al_map_rgb(30,50,200));
	al_flip_display();
	//al_rest(10.0);//TODO: okno ma nie znikac
	// if(!display) 
}
Exemplo n.º 6
0
void Utility::InitAllegro()
{
	if (!al_init())										//initialize Allegro
		m_GameOver = 1;

	al_init_primitives_addon();
	al_install_mouse();
	al_install_keyboard();
	al_init_font_addon();
	al_init_ttf_addon();
	al_init_image_addon();
}
Exemplo n.º 7
0
bool printDefaultLifeBar(
    long int          lifeactual,
    long int          lifemax,
    long int          bar_x,
    long int          bar_y,
    long int          WIDTH,
    long int          HEIGHT,
    ALLEGRO_COLOR     col,
    int               thickness)
{
    volatile long     x = bar_x,
                      y = bar_y,
                      cont_bars = 0;
    float
    /*Porcentagem referente à [lifeactual] e [lifemax]*/
    percent   = (lifeactual*100) / lifemax;
    unsigned long
    /*Espacamento entre as barras menores*/
    spacement = thickness,

    /*Total de barras que preenche completamente o retangulo*/
    max_bars  = (WIDTH / (spacement + thickness)),

    /*Numero de barras que preenche o retangulo ate [percent]*/
    actual_max_bars = (percent * max_bars) / 100;

    if(lifeactual < 0 || WIDTH <= 0 || HEIGHT <= 0 ||
            lifeactual > lifemax || thickness <= 0)
        return (false);

    if(!USING_PRIMITIVES_ADDON)
    {
        al_init_primitives_addon();
        USING_PRIMITIVES_ADDON = true;
    }

    al_draw_rectangle(
        bar_x, bar_y,
        bar_x + WIDTH, bar_y + HEIGHT,
        col, thickness);

    for(cont_bars = 0; cont_bars < actual_max_bars; cont_bars++)
    {
        al_draw_line(
            x, y,
            x, y + HEIGHT,
            col, thickness);
        x += thickness + spacement;
    }

    return (true);
}
Exemplo n.º 8
0
int main(int argc, const char *argv[])
{
   ALLEGRO_THREAD *thread[MAX_THREADS];
   Background background[MAX_BACKGROUNDS] = {
      { 1.0, 0.5, 0.5 },
      { 0.5, 1.0, 0.5 },
      { 0.5, 0.5, 1.0 },
      { 1.0, 1.0, 0.5 },
      { 0.5, 1.0, 1.0 },
      { 1.0, 0.7, 0.5 },
      { 0.5, 1.0, 0.7 },
      { 0.7, 0.5, 1.0 },
      { 1.0, 0.7, 0.5 },
      { 0.5, 0.7, 1.0 }
   };
   int num_threads;
   int i;

   if (argc > 1) {
      num_threads = strtol(argv[1], NULL, 10);
      if (num_threads > MAX_THREADS)
         num_threads = MAX_THREADS;
      else if (num_threads < 1)
         num_threads = 1;
   }
   else {
      num_threads = 3;
   }

   if (!al_init()) {
      abort_example("Could not init Allegro.\n");
      return 1;
   }
   
   al_init_primitives_addon();
   al_install_keyboard();
   al_install_mouse();

   for (i = 0; i < num_threads; i++) {
      thread[i] = al_create_thread(thread_func,
         &background[i % MAX_BACKGROUNDS]);
   }
   for (i = 0; i < num_threads; i++) {
      al_start_thread(thread[i]);
   }
   for (i = 0; i < num_threads; i++) {
      al_join_thread(thread[i], NULL);
      al_destroy_thread(thread[i]);
   }

   return 0;
}
Exemplo n.º 9
0
 bool Init_Allegro()
 {
     if(!al_init())
     {
         error_message("al_init()");
     }
     if(!al_init_native_dialog_addon())
     {
         error_message("al_init_native_dialog_addon()");
     }
     if(!al_init_primitives_addon())
     {
         error_message("al_init_primitives_addon()");
         return false;
     }
     if(!al_install_keyboard())
     {
         error_message("al_install_keyboard()");
         return false;
     }
     if(!al_install_mouse())
     {
         error_message("al_install_mouse()");
         return false;
     }
     if(!al_init_image_addon())
     {
         error_message("al_init_image_addon()");
         return false;
     }
     if(!al_install_audio())
     {
         error_message("al_install_audio()");
         return false;
     }
     if(!al_init_acodec_addon())
     {
         error_message("al_init_acodec_addon()");
         return false;
     }
     al_init_font_addon(); // returns void
     if(!al_init_ttf_addon())
     {
         error_message("al_init_ttf_addon()");
         return false;
     }
     if(!al_init_video_addon())
     {
         error_message("al_init_video_addon()");
         return false;
     }
 }
Exemplo n.º 10
0
// Sets up game
void setup(){
  // Init allegro 5
  al_init();

  // Input
  al_install_keyboard();
  al_install_mouse();
  al_install_joystick();

  // Fonts
  al_init_font_addon();
  al_init_ttf_addon();

  // Graphics
  al_init_image_addon();
  al_init_primitives_addon();

  // Audio
  al_install_audio();
  al_init_acodec_addon();
  al_reserve_samples( 20);

  // Initializing
  timer = al_create_timer(1.0 / MAX_FPS);
  display = al_create_display( SCREEN_W, SCREEN_H);

  // Events
  event_queue = al_create_event_queue();
  al_register_event_source( event_queue, al_get_display_event_source(display));
  al_register_event_source( event_queue, al_get_timer_event_source(timer));
  al_register_event_source( event_queue, al_get_keyboard_event_source());
  al_register_event_source( event_queue, al_get_joystick_event_source());

  al_clear_to_color( al_map_rgb(0,0,0));
  al_flip_display();
  al_start_timer(timer);

  // Creates a random number generator (based on time)
  srand( time(nullptr));

  // Game state
  stateID = STATE_NULL;
  nextState = STATE_NULL;

  // Clear settings
  for( int i = 0; i < 11; i++)
    settings[i] = false;

  // Clear frams array
  for( int i = 0; i < 100; i++)
    frames_array[i] = 0;
}
Exemplo n.º 11
0
static void initialize(void)
{
   if (!al_init()) {
      abort_example("Could not init Allegro.\n");
   }

   open_log();

   al_init_primitives_addon();
   al_init_image_addon();
   al_init_font_addon();
   if (!al_install_keyboard()) {
      abort_example("Could not init keyboard!\n");
   }
   if (!al_install_mouse()) {
      abort_example("Could not init mouse!\n");
   }
   
   al_init_acodec_addon();

   if (!al_install_audio()) {
      abort_example("Could not init sound!\n");
   }
   if (!al_reserve_samples(16)) {
      abort_example("Could not set up voice and mixer.\n");
   }

   init_platform_specific();

   display = al_create_display(640, 228);
   if (!display) {
      abort_example("Could not create display!\n");
   }
   
   basic_font = al_load_font("data/font.tga", 0, 0);
   if (!basic_font) {
      abort_example("Could not load font!\n");
   }
   timer = al_create_timer(1.000 / 30);
   if (!timer) {
      abort_example("Could not init timer!\n");
   }
   queue = al_create_event_queue();
   if (!queue) {
      abort_example("Could not create event queue!\n");
   }
   al_register_event_source(queue, al_get_keyboard_event_source());
   al_register_event_source(queue, al_get_mouse_event_source());
   al_register_event_source(queue, al_get_display_event_source(display));
   al_register_event_source(queue, al_get_timer_event_source(timer));
}
Exemplo n.º 12
0
int main()
{
    ALLEGRO_DISPLAY *display = NULL;
    ALLEGRO_FONT* century_gothic24;

    if(!al_init())
    {
        printf("al_init Failed!\n");
        return -1;
    }
    if(!al_init_primitives_addon())
    {
        printf("al_init_primitives_addon Failed!\n");
        return -1;
    }
    display = al_create_display(640, 480);
    if(!display)
    {
        printf("al_create_display Failed!\n");
        return -1;
    }
    al_init_font_addon();
    al_init_ttf_addon();
    century_gothic24  = al_load_ttf_font("C:\\Windows\\Fonts\\GOTHIC.TTF" , 24, ALLEGRO_ALIGN_CENTRE);
    // Paint a hidden screen (a buffer), that we'll apply later.
    al_clear_to_color(al_map_rgb(0,0,0));
    // Draw an ugly red triangle to the buffer.
    al_draw_filled_triangle(10, 10, 200, 200, 350, 230, al_map_rgb(255,0,0));
    // Draw text to the buffer
    al_draw_text(century_gothic24, al_map_rgb(255,255,255), 550, 440, ALLEGRO_ALIGN_CENTRE, "Hello World!");
    // Draw a line to the buffer
    al_draw_line(400,400,500,34,al_map_rgb(255,255,255), 5);
    // Draw a circle
    al_draw_circle(300,300, 50, al_map_rgb(255,255,0), 5);
    // Draw Eclipse
    al_draw_filled_ellipse(500, 300, 40, 56, al_map_rgb(255,0,255));
    // Draw a rectangle
    al_draw_rectangle(100,200,200,300,al_map_rgb(0,255,0), 6);s
    // Draw a polygon
    al_draw_filled_rectangle(0,480,50,400,al_map_rgb(25,185,35));
    al_draw_filled_rectangle(0,480,200,450,al_map_rgb(25,185,35));
    // Apply the buffer to the front.
    al_flip_display();
    // Wait for 3 secs.
    al_rest(10.0);
    // Destroying the display we created, to avoid memory leaking.
    al_destroy_display(display);

    return 0;
}
Exemplo n.º 13
0
int main() {
    load_configuration_file();

    // ŁADOWANIE BIBLIOTEK
    al_init();
    al_init_image_addon();
    al_init_primitives_addon();
    al_install_keyboard();
    al_init_font_addon();
    al_init_ttf_addon();
    al_install_audio();
    al_init_acodec_addon();
    al_reserve_samples(100);

    // WYŚWTIETLANIE EKRANU
    display.view = NULL;
//	al_get_display_mode(al_get_num_display_modes() -3, &disp_data);
//	al_set_new_display_flags(ALLEGRO_FULLSCREEN);
    display.view = al_create_display(display.width, display.height);

    // TIMER
    main_timer = NULL;
    main_timer = al_create_timer(1.0 / display.FPS);

    GAME_MODE = MENU;
    Exit_game = false;

    al_start_timer(main_timer);
    while (!Exit_game) {
        switch (GAME_MODE) {
            case MENU:
                menu();
                break;
            case GAMEPLAY:
                gameplay();
                break;
            case AFTER_GAMEPLAY:
                menu();
                break;
            default:
                break;
        }
    }

    al_destroy_display(display.view);
    al_destroy_timer(main_timer);


    return 111;
}
Exemplo n.º 14
0
void gui_init()
{
    /* Inicializa a biblioteca allegro */
    al_init();
    al_init_primitives_addon();
    al_init_image_addon();

    /* Cria fila de eventos */
    event_queue = NULL;
    event_queue = al_create_event_queue();

    if(!gui_keyboard_init())
        fprintf(stderr, "Falha ao inicializar o teclado.\n");
}
Exemplo n.º 15
0
int main(int argc, char **argv)
{
   ALLEGRO_DISPLAY *display;
   ALLEGRO_BITMAP *cursor;
   ALLEGRO_MOUSE_STATE msestate;
   ALLEGRO_KEYBOARD_STATE kbdstate;
   int i;

   (void)argc;
   (void)argv;

   if (!al_init()) {
      abort_example("Could not init Allegro.\n");
   }

   al_init_primitives_addon();
   al_install_mouse();
   al_install_keyboard();
   al_init_image_addon();
   init_platform_specific();

   display = al_create_display(640, 480);
   if (!display) {
      abort_example("Error creating display\n");
   }

   al_hide_mouse_cursor(display);

   cursor = al_load_bitmap("data/cursor.tga");
   if (!cursor) {
      abort_example("Error loading cursor.tga\n");
   }

   do {
      al_get_mouse_state(&msestate);
      al_get_keyboard_state(&kbdstate);

      al_clear_to_color(al_map_rgb(0xff, 0xff, 0xc0));
      for (i = 1; i <= NUM_BUTTONS; i++) {
         draw_mouse_button(i, al_mouse_button_down(&msestate, i));
      }
      al_draw_bitmap(cursor, msestate.x, msestate.y, 0);
      al_flip_display();

      al_rest(0.005);
   } while (!al_key_down(&kbdstate, ALLEGRO_KEY_ESCAPE));

   return 0;
}
Exemplo n.º 16
0
int main(int argc, char *argv[]) {
  ALLEGRO_DISPLAY *display;
  unsigned int ticks = 0;

  if (!al_init()) {
    std::cerr << "[ERROR] Error initializing Allegro" << std::endl;
  }

  display = al_create_display(SCREEN_WIDTH, SCREEN_HEIGHT);

  if (!display) {
    std::cerr << "[ERROR] Error creating Allegro display" << std::endl;
  }

  al_install_audio();
  al_install_keyboard();

  al_init_primitives_addon();
  al_init_acodec_addon();
  al_init_font_addon();
  al_init_ttf_addon();
  al_init_image_addon();

  al_reserve_samples(10);

  srand(time(NULL));

  ALLEGRO_TIMER *timer = al_create_timer(1.0 / FPS);
  ALLEGRO_EVENT_QUEUE *timerQueue = al_create_event_queue();
  al_register_event_source(timerQueue, al_get_timer_event_source(timer));

  al_start_timer(timer);

  Tetris *game = new Tetris(SCREEN_WIDTH, SCREEN_HEIGHT, timerQueue);

  while (game->update(ticks)) {
    game->render();

    ++ticks;
  }

  delete game;

  al_destroy_display(display);
  al_destroy_timer(timer);
  al_destroy_event_queue(timerQueue);

  return 0;
}
Exemplo n.º 17
0
int main(int argc, const char *argv[])
{
   enum Mode mode = ALL;
   int i;

   if (argc > 1) {
      i = strtol(argv[1], NULL, 10);
      switch (i) {
         case 0:
            mode = PLAIN_BLIT;
            break;
         case 1:
            mode = SCALED_BLIT;
            break;
         case 2:
            mode = ROTATE_BLIT;
            break;
      }
   }

   if (!al_init()) {
      abort_example("Could not init Allegro\n");
   }

   open_log();

   al_init_image_addon();
   al_init_primitives_addon();

   display = al_create_display(640, 480);
   if (!display) {
      abort_example("Error creating display\n");
   }
   
   if (mode == ALL) {
      for (mode = PLAIN_BLIT; mode <= ROTATE_BLIT; mode++) {
         do_test(mode);
      }
   }
   else {
      do_test(mode);
   }

   al_destroy_display(display);

   close_log(true);

   return 0;
}
Exemplo n.º 18
0
Terminal::Terminal(std::string const& fontPath, int charWidth, int charHeight, int width, int height)
{
    this->width = width;
    this->height = height;
    this->charWidth = charWidth;
    this->charHeight = charHeight;
    
    // init addons
    if (!al_init_image_addon())
        THROW() << "Failed to init image addon";
    if (!al_init_primitives_addon())
        THROW() << "Failed to init primitives addon";
    
    // load the font
    glyphSheet = al_load_bitmap(fontPath.c_str());
    if (!glyphSheet)
        THROW() << "Failed to load font: " << fontPath;
    
    // create the glyphs
    for (int y = 0; y < GLYPH_ROWS; ++y) {
        for (int x = 0; x < GLYPH_COLUMNS; ++x) {
            ALLEGRO_BITMAP* glyph = al_create_sub_bitmap(glyphSheet, x * charWidth, y * charHeight, charWidth, charHeight);
            if (!glyph)
                THROW() << "Failed to create glyphs";
            al_convert_mask_to_alpha(glyph, al_map_rgb(0, 0, 0));
            glyphs.push_back(glyph);
        }
    }
    
    // create the window
    al_set_new_display_flags(ALLEGRO_WINDOWED);
    al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 1, ALLEGRO_SUGGEST);
    al_set_new_display_option(ALLEGRO_SAMPLES, 8, ALLEGRO_SUGGEST);
    display = al_create_display(width * charWidth, height * charHeight);
    if (!display)
        THROW() << "Failed to create display";
    al_clear_to_color(al_map_rgb(0, 0, 0));
    
    // create the character arrays
    for (int i = 0; i < width * height; i++) {
        chars.push_back(CharData(' ', white, black));
        oldChars.push_back(CharData('?', white, black));
        // we make oldChars different to force a refresh
    }
    
    foregroundColor = white;
    backgroundColor = black;
    cursorX = cursorY = 0;
}
Exemplo n.º 19
0
void AllegroShell::init(int disp_h, int disp_w, int step_flag){
	fps = 30;
	display_h = disp_h; // 480
	display_w = disp_w; // 480
	run_flag = true;
	draw_flag = false;
	this->step_flag = step_flag; // false
	step_once_flag = false;

	int x = 8;
	x -= al_init();
	x -= al_init_image_addon();
	al_init_font_addon();
	x -= al_init_ttf_addon();
	x -= al_install_mouse();
	x -= al_install_keyboard();
	x -= al_install_audio();
	x -= al_init_acodec_addon();
	x -= al_init_primitives_addon();
	//x -= al_reserve_samples(10);
	printf("%d errors during loading.\n",x);

	// initializing the allegro objects
	display = al_create_display(display_w,display_h);
	queue = al_create_event_queue();
	timer = al_create_timer(1.0/fps);

	// al_toggle_display_flag(display,ALLEGRO_FULLSCREEN_WINDOW,false);
	// al_toggle_display_flag(display,ALLEGRO_NOFRAME,false);

	// registering the even sourcees
	al_register_event_source(queue,al_get_timer_event_source(timer));
	al_register_event_source(queue,al_get_display_event_source(display));
	al_register_event_source(queue,al_get_mouse_event_source());
	al_register_event_source(queue,al_get_keyboard_event_source());
	al_clear_to_color(al_map_rgb(0,0,0));
	al_flip_display();

	// instantiate my objects
	mouse  = new _Mouse();

	model = new Model();
	al_set_timer_speed(timer,1.0/model->speed);

	view = new View(this,model);
	al_register_event_source(queue,view->get_event_source());
	view->emit_event();
}
Exemplo n.º 20
0
int main(void)
{
  int a = returnas5();
  int b = returnas6();
  
  al_init();
  al_init_primitives_addon();
  
  ALLEGRO_DISPLAY *display = al_create_display(SCREEN_W, SCREEN_H);

  draw_main(&display);

  al_destroy_display(display);
  
  return 0;
}
Exemplo n.º 21
0
void init()
{
	al_init();
	al_install_mouse();
	al_install_keyboard();
	al_install_audio();
	al_init_image_addon();
	al_init_font_addon();
	al_init_ttf_addon();
	al_init_acodec_addon();
	al_init_primitives_addon();
	CharFont::loadFont();
	sysConfig::init();
	Parse::init();
	wcout.imbue(locale(".936"));
}
Exemplo n.º 22
0
void BaseGame::initModules()
{
	al_init_font_addon();
	if(!(al_init_ttf_addon() &&
		al_init_primitives_addon() &&
		al_init_image_addon() &&
		al_init_acodec_addon() &&
		al_install_keyboard() &&
		al_install_mouse() &&
		al_install_audio() &&
		al_install_joystick()))
	{
		al_show_native_message_box(display, "Error!", "ERROR 42 (0x2a)",
			"Error while loading allegro modules. Please contact distributor and inform them of this error.", NULL, 0);
		exit(42);
	}
}
InitializationStatus AllegroFlasher::AllegroInit()
{
	//const int FPS = 60;

	// initialise Allegro itself
	if(!al_init()) return ALLEGRO_INITIALISATION_ERROR;

	// initialise primitives addon (for drawing shapes)
	if(!al_init_primitives_addon()) return PRIMITIVES_ADDON_ERROR;

	// install the keyboard
	if(!al_install_keyboard()) return KEYBOARD_ERROR;

	//install the mouse
	if(!al_install_mouse()) return MOUSE_ERROR;

	// initialise font and ttf addon (for drawing text)
	al_init_font_addon();

	if (!al_init_ttf_addon()) return TTF_ADDON_ERROR;

	//initialise audio
	if(!al_install_audio()) return AUDIO_ERROR;

	//initialise audio codecs
	if(!al_init_acodec_addon()) return CODEC_ERROR;

	//reserve samples
	if (!al_reserve_samples(5)) return RESERVE_SAMPLES_ERROR;

	//event_queue = al_create_event_queue();
    
    //display = al_create_display(width, height);
    //if(!display)
    //    return DISPLAY_ERROR;

	//timer = al_create_timer(1.0 / FPS);	    // Set the period of the time

	// Register keyboard input, mouse input, display input, and timer as event source on event_queue
	//al_register_event_source(event_queue, al_get_keyboard_event_source());
	//al_register_event_source(event_queue, al_get_mouse_event_source());
    
	//al_register_event_source(event_queue, al_get_timer_event_source(timer));
	
    return OKAY;
}
int main(int argc, char *argv[])
{
   ALLEGRO_DISPLAY *display;
   ALLEGRO_FONT *font;

   (void)argc;
   (void)argv;

   if (!al_init()) {
      abort_example("Could not init Allegro.\n");
      return 1;
   }

   al_init_primitives_addon();
   al_init_image_addon();
   al_init_font_addon();

   al_install_keyboard();
   al_install_mouse();

   al_set_new_display_flags(ALLEGRO_GENERATE_EXPOSE_EVENTS);
   display = al_create_display(640, 480);
   if (!display) {
      abort_example("Error creating display\n");
      return 1;
   }

   //printf("Display format = %d\n", al_get_display_format());

   font = al_load_font("data/fixed_font.tga", 0, 0);
   if (!font) {
      abort_example("Failed to load data/fixed_font.tga\n");
      return 1;
   }

   /* Don't remove these braces. */
   {
      Theme theme(font);
      Prog prog(theme, display);
      prog.run();
   }

   al_destroy_font(font);

   return 0;
}
Exemplo n.º 25
0
int main(int argc, char **argv)
{
   ALLEGRO_DISPLAY *display;
   ALLEGRO_BITMAP *picture;

   if (!al_init()) {
      abort_example("Could not init Allegro.\n");
      return 1;
   }
   al_init_primitives_addon();
   al_install_keyboard();
   al_init_image_addon();

   open_log_monospace();

   if (argc == 2) {
   	al_set_new_display_adapter(atoi(argv[1]));
   }

   al_set_new_display_flags(ALLEGRO_FULLSCREEN |
       ALLEGRO_GENERATE_EXPOSE_EVENTS);
   display = al_create_display(res[cur_res].w, res[cur_res].h);
   if (!display) {
      abort_example("Error creating display\n");
      return 1;
   }
   
   picture = al_load_bitmap("data/mysha.pcx");
   if (!picture) {
      abort_example("mysha.pcx not found\n");
      return 1;
   }

   main_loop(display, picture);

   al_destroy_bitmap(picture);

   /* Destroying the fullscreen display restores the original screen
    * resolution.  Shutting down Allegro would automatically destroy the
    * display, too.
    */
   al_destroy_display(display);

   return 0;
}
Exemplo n.º 26
0
void StartAllegro5() {
	cout << "Starting Allegro 5..." << endl;
	if (!al_init())
		al_show_native_message_box(NULL, NULL, "Could not initialize Allegro 5",
				NULL, NULL, 0);

	cout << "Initializing add ons..." << endl;
	al_init_image_addon();
	al_init_primitives_addon();
	al_init_font_addon();
	al_init_ttf_addon();
	al_init_acodec_addon();

	cout << "Installing devices..." << endl;
	al_install_mouse();
	al_install_keyboard();
	al_install_audio();
}
Exemplo n.º 27
0
void gdp_init(){
    // aloca limites de exibicao
    listlifeless = calloc(LIFELESS,sizeof(Lifeless*));
    listchars = calloc(CHARS,sizeof(Char*));

    // configurações iniciais
    ncanaisaudio = 3; // numero de canais de audio
    connecterro  = 0; //nao existe erro
    ntotlifeless = 0; // numero de objetos
    ntotchars    = 4; // numero de personagens
    ntotenemies  = 0; // numero de inimigos
    opmap        = 1; // mapa escolhido
    scale        = 1.5; //escala do mapa
    boss_char_id = gdp_files_quick_getint("Configs//server.txt","boss_char_id"); //id do boss

	// Inicializa a Allegro
	al_init();

	// Inicializa o add-on para utilização de imagens
	al_init_image_addon();

	// Inicializa o add-on para utilização de teclado
	al_install_keyboard();

	// Inicialização do add-on para uso de fontes
	al_init_font_addon();
	al_init_ttf_addon();

	// Inicialização do add-on para uso de sons
	al_install_audio();
	al_init_acodec_addon();
	al_reserve_samples(ncanaisaudio);

    //inicia addons de primitivas
    al_init_primitives_addon();

	// Configura a janela
	 al_set_new_display_flags(ALLEGRO_FULLSCREEN_WINDOW|ALLEGRO_FULLSCREEN);
	SCREEN = al_create_display(wigth, height);
	// define o titulo
	al_set_window_title(SCREEN, title);

    ambient = NULL;
}
Exemplo n.º 28
0
int main(int argc, char **argv)
{
   (void)argc;
   (void)argv;

   if (!al_init()) {
      abort_example("Could not init Allegro.\n");
   }

   al_init_primitives_addon();
   al_install_keyboard();
   al_init_image_addon();
   al_init_font_addon();
   init_platform_specific();

   al_set_new_display_flags(ALLEGRO_FULLSCREEN_WINDOW);
   display = al_create_display(640, 480);
   if (!display) {
      abort_example("Error creating display\n");
   }

   queue = al_create_event_queue();
   al_register_event_source(queue, al_get_keyboard_event_source());
   al_register_event_source(queue, al_get_display_event_source(display));

   picture = al_load_bitmap("data/mysha.pcx");
   if (!picture) {
      abort_example("mysha.pcx not found\n");
   }
   
   font = al_load_font("data/fixed_font.tga", 0, 0);
   if (!font) {
      abort_example("data/fixed_font.tga not found.\n");
   }

   redraw();
   run();

   al_destroy_display(display);

   al_destroy_event_queue(queue);

   return 0;
}
Exemplo n.º 29
0
//Funciones
void inicializar(void){

    //Inicializar los AddOns
    if(!al_init())
    {
        fprintf(stderr, "Error al inicializar Allegro."); // Imprimir errores en stream STDERR
        exit(-1);
    }

    if(!al_init_primitives_addon())
    {
        fprintf(stderr, "Error al inicializar el addon de primitivas."); // Imprimir errores en stream STDERR
        exit(-2);
    }

    dis = al_create_display(VENTANA_X, VENTANA_Y); // Crear el display de tamaño 500x300 píxeles

    al_set_window_title(dis, "Ejemplo Allegro 5 - www.multiaportes.com"); // Establecer el título de la ventana
}
Exemplo n.º 30
0
int main(int argc, char **argv){
 
   ALLEGRO_DISPLAY       *display = NULL;
   ALLEGRO_DISPLAY_MODE   disp_data;
 
   al_init(); // I'm not checking the return value for simplicity.
   al_init_image_addon();
   al_init_primitives_addon();
 
   al_get_display_mode(al_get_num_display_modes() - 1, &disp_data);
 
   al_set_new_display_flags(ALLEGRO_FULLSCREEN);
   display = al_create_display(disp_data.width, disp_data.height);
 
   al_rest(3);
   al_destroy_display(display);
 
   return 0;
}