Beispiel #1
0
void LoadGame(Heroi *Heroi)
{
	FILE *Load;
	Load = fopen("SaveLoadGame/SaveLoadGame.bin", "r");

	al_clear_to_color(al_map_rgb(0, 0, 0));
	if (!Load)
	{
		al_draw_text(Fonte, al_map_rgb(255, 255, 255), (LARGURA_TELA / 2 - al_get_font_ascent(Fonte)), (ALTURA_TELA / 2 - al_get_font_ascent(Fonte)), ALLEGRO_ALIGN_CENTRE, "Nenhum Save Game Encontrado...");
		al_flip_display();
		al_rest(3.0);
	}
	else
	{
		al_draw_text(Fonte, al_map_rgb(255, 255, 255), (LARGURA_TELA / 2 - al_get_font_ascent(Fonte)), (ALTURA_TELA / 2 - al_get_font_ascent(Fonte)), ALLEGRO_ALIGN_CENTRE, "Carregando Jogo...");
		al_flip_display();
		al_rest(3.0);
	}

	fscanf(Load, "%d", &IDMapa);
	fscanf(Load, "%d", &Heroi->x);
	fscanf(Load, "%d", &Heroi->y);
	fscanf(Load, "%d", &Heroi->LinhaAnimacao);
	fscanf(Load, "%d", &Heroi->ColunaAnimacao);
	fscanf(Load, "%d", &Heroi->Life);
	fscanf(Load, "%d", &Heroi->MaxLife);
	fscanf(Load, "%d", &Heroi->Mana);
	fscanf(Load, "%d", &Heroi->MaxMana);
	fscanf(Load, "%d", &Heroi->QtdVida);
	fscanf(Load, "%d", &Heroi->QtdMana);

	fclose(Load);
}
Beispiel #2
0
void Gra::komunikat(){
	int kto=czyja_wygrana();
	obraz.zmientlo();
	if (kto==0)
		return;

	if (kto==3){
		al_draw_bitmap(obraz.tlo,0,0,0);
		al_draw_text(obraz.font_menu_glowne,al_map_rgb(160,0,0),0.5*800,0.25*600,ALLEGRO_ALIGN_CENTRE,"REMIS");
		
		al_draw_bitmap(obraz.Image2,0.35*800,0.5*600,0);
		al_draw_bitmap(obraz.Image,0.65*800,0.5*600,0);
		al_flip_display();
		al_rest(4);
	}

	if (kto==2){
		al_draw_bitmap(obraz.tlo,0,0,0);
		al_draw_text(obraz.font_menu_glowne,al_map_rgb(63,49,255),0.5*800,0.25*600,ALLEGRO_ALIGN_CENTRE,"WYGRANA!");
		
		al_draw_bitmap(obraz.Image2,0.5*800,0.5*600,0);
		al_flip_display();
		al_rest(4);
	}

	if (kto==1){
		al_draw_bitmap(obraz.tlo,0,0,0);
		al_draw_text(obraz.font_menu_glowne,al_map_rgb(181,230,29),0.5*800,0.25*600,ALLEGRO_ALIGN_CENTRE,"WYGRANA!");
		al_draw_bitmap(obraz.Image,0.5*800,0.5*600,0);
		al_flip_display();
		al_rest(4);
	}

}
int do_gui(const std::vector<Widget *>& widgets, unsigned int selected)
{
   ResourceManager& rm = ResourceManager::getInstance();
   ALLEGRO_BITMAP *bg = (ALLEGRO_BITMAP *)rm.getData(RES_BACKGROUND);
   Input *input = (Input *)rm.getData(RES_INPUT);
   ALLEGRO_BITMAP *logo = (ALLEGRO_BITMAP *)rm.getData(RES_LOGO);
   int lw = al_get_bitmap_width(logo);
   int lh = al_get_bitmap_height(logo);
   ALLEGRO_FONT *myfont = (ALLEGRO_FONT *)rm.getData(RES_SMALLFONT);

   bool redraw = true;

   for (;;) {
      input->poll();
      float ud = input->ud();
      if (ud < 0 && selected) {
         selected--;
         my_play_sample(RES_FIRELARGE);
         al_rest(0.200);
         redraw = true;
      }
      else if (ud > 0 && selected < (widgets.size()-1)) {
         selected++;
         my_play_sample(RES_FIRELARGE);
         al_rest(0.200);
         redraw = true;
      }
      if (input->b1()) {
         if (!widgets[selected]->activate())
            return selected;
      }
      if (input->esc())
         return -1;

      if (!redraw) {
         al_rest(0.010);
         continue;
      }

      /* draw */
      al_draw_scaled_bitmap(bg, 0, 0, 
         al_get_bitmap_width(bg),
         al_get_bitmap_height(bg),
         0, 0, BB_W, BB_H,
         0);
      al_draw_bitmap(logo, (BB_W-lw)/2, (BB_H-lh)/4, 0);

      al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA);
      al_draw_textf(myfont, al_map_rgb(255, 255, 0), BB_W/2, BB_H/2, ALLEGRO_ALIGN_CENTRE, "z/y to start");
      al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA);

      for (unsigned int i = 0; i < widgets.size(); i++) {
         widgets[i]->render(i == selected);
      }
      al_flip_display();
      redraw = false;
   }
}
Beispiel #4
0
static void *wakeup_thread(ALLEGRO_THREAD *thread, void *user)
{
   al_rest(1);
   while (!al_get_thread_should_stop(thread)) {
      /* If the program uses timers, this hack is not required usually. */
      if (_al_get_active_timers_count())
         break;
      if (!al_is_keyboard_installed())
         break;
      wakeup_with_fake_timer_event();
      al_rest(0.01);
   }
   return user;
}
Beispiel #5
0
int main(int argc, char** argv)
{
    if (Init() == false)
    {
        std::cout << "Fatal error! Closing application..." << std::endl;
        al_rest(10.0);
        return EXIT_FAILURE;
    }

    AppBody();
    Shutdown();

    al_rest(0.5);
    return EXIT_SUCCESS;
}
Beispiel #6
0
int main(void) {

   /*Declaracao e Inicializacao da Variavel de Janela*/
   ALLEGRO_DISPLAY *janela = NULL;

   /*Inicializa Allegro5*/
   if(!al_init()) {
      fprintf(stderr, "Falha ao iniciar Allegro5!\n");
      return -1;
   }

   /*Cria Janela de Jogo*/
   janela = al_create_display(LARG, ALT);
   if (!janela)
   {
      fprintf(stderr, "Falha ao criar janela!\n");
      return -1;
   }

   /*Preenche a tela com a cor desejada*/
   al_clear_to_color(al_map_rgb(0, 0, 0));

   /*Atualiza tela*/
   al_flip_display();

   /*Pausa execucao*/
   al_rest(5);

   /*Destroi Variavel de Janela*/
   al_destroy_display(janela);
   
   return 0;
} 
Beispiel #7
0
int main()
{
    //This is the display on which you draw everyting
    ALLEGRO_DISPLAY *display;

    //If Allegro fails to initialize show a message box
    if(!al_init())
    al_show_native_message_box(NULL, NULL, NULL, "Could not initialize Allegro 5", NULL, NULL);

    //Define the display
    display = al_create_display(800, 600);

    //If Allegro fails to create a display show a message box
    if(!display)
    al_show_native_message_box(NULL, NULL, NULL, "Could not create Allegro 5 display", NULL, NULL);

    //Show the application window for 5 seconds
    //(if you don't, the application will shut down immediately after you launch it)
    al_rest(5.0f);

    //Deallocate the memory used for the display creation
    al_destroy_display(display);

    return 0;
}
Beispiel #8
0
/* Note: The system mutex must be locked (exactly once) so when we
 * wait for the condition variable it gets auto-unlocked. For a
 * nested lock that would not be the case.
 */
void _al_display_xglx_await_resize(ALLEGRO_DISPLAY *d, int old_resize_count,
   bool delay_hack)
{
   ALLEGRO_SYSTEM_XGLX *system = (void *)al_get_system_driver();
   ALLEGRO_DISPLAY_XGLX *glx = (ALLEGRO_DISPLAY_XGLX *)d;
   ALLEGRO_TIMEOUT timeout;

   ALLEGRO_DEBUG("Awaiting resize event\n");

   XSync(system->x11display, False);

   /* Wait until we are actually resized.
    * Don't wait forever if an event never comes.
    */
   al_init_timeout(&timeout, 1.0);
   while (old_resize_count == glx->resize_count) {
      if (_al_cond_timedwait(&system->resized, &system->lock, &timeout) == -1) {
         ALLEGRO_ERROR("Timeout while waiting for resize event.\n");
         return;
      }
   }

   /* XXX: This hack helps when toggling between fullscreen windows and not,
    * on various window managers.
    */
   if (delay_hack) {
      al_rest(0.2);
   }

   xdpy_acknowledge_resize(d);
}
Beispiel #9
0
int main3()
{
	if(!al_init())
	{
		al_show_native_message_box(NULL, NULL, "Error", "Could not initialize Allegro 5", NULL, ALLEGRO_MESSAGEBOX_ERROR); 
		return -1;
	}
	
	al_set_new_display_flags(ALLEGRO_FULLSCREEN);
	// al_set_new_display_flags(ALLEGRO_WINDOWED);
	// al_set_new_display_flags(ALLEGRO_RESIZABLE);
	// al_set_new_display_flags(ALLEGRO_WINDOWED | ALLEGRO_RESIZABLE);
	
	ALLEGRO_DISPLAY *display = al_create_display(800, 600); 

	if(!display)
	{
		al_show_native_message_box(NULL, NULL, "Error", "Could not create Allegro 5 display", NULL, ALLEGRO_MESSAGEBOX_ERROR);
		return -1;
	}

	al_set_window_position(display, 200, 100);
	al_set_window_title(display, "CodingMadeEasy");

	// You generally want to do this after you check to see if the display was created. If the display wasn't created then there's
	// no point in calling this function

	al_rest(10.0);
	al_destroy_display(display);

	return 0;
}
Beispiel #10
0
int main(int argc, char **argv)
{
    al_init();
    al_init_image_addon();
    al_init_primitives_addon();
    al_init_font_addon();
    al_init_ttf_addon();
    al_get_display_mode(al_get_num_display_modes()-1, &disp_data);
    //al_set_new_display_flags(ALLEGRO_FULLSCREEN);
    al_set_new_display_flags(ALLEGRO_WINDOWED);
    al_set_new_display_option(ALLEGRO_VSYNC, 1, ALLEGRO_SUGGEST);
    disp_data.width*=0.8;
    disp_data.height*=0.8;
    display=al_create_display(disp_data.width, disp_data.height);
    if(!display)
    {
        return -1;
    }
    al_clear_to_color(al_map_rgb(0, 0, 0));
    al_flip_display();
    al_install_keyboard();
    al_install_mouse();
    al_install_audio();
    al_init_acodec_addon();
    al_reserve_samples(5);
    al_rest(5.0);
    al_destroy_display(display);

    return 0;
}
Beispiel #11
0
int main (void)
{
//cria a variavel para receber a tela
ALLEGRO_DISPLAY *display = NULL;

//inicializa o Allegro
al_init();

//cria a tela com tamanho 400 x 350 (teste: altere os valores)
display = al_create_display(400, 350);

//inicializa o modulo que permite carregar imagens no jogo
al_init_image_addon();

//carrega a imagem louco.jpg e a atribui aa variavel image
ALLEGRO_BITMAP *image = al_load_bitmap("louco.jpg");

//coloca na tela a imagem armazenada na variavel image nas posicoes x=50, y=100
al_draw_bitmap(image, 50, 100, NULL);

//atualiza a tela
al_flip_display();

//pausa a tela por 3.0 segundos
al_rest(3.0);

//destroi a variavel imagem = libera a memoria alocada para ela
al_destroy_bitmap(image);
//destroi a tela criada para o jogo
al_destroy_display(display);

return 0;
}
Beispiel #12
0
   static void *Func_Thread(ALLEGRO_THREAD *thr, void *arg){
 
   DATA *data  = (DATA*) arg;
   float num   = 0.1;
 
   al_lock_mutex(data->mutex);
 
   bool modi_X = data->modi_X;
   data->ready = true;
   al_broadcast_cond(data->cond);
 
   al_unlock_mutex(data->mutex);
 
   while(!al_get_thread_should_stop(thr)){
 
      al_lock_mutex(data->mutex);
      if(modi_X)
         data->posiX += num;
      else
         data->posiY += num;
      al_unlock_mutex(data->mutex);
 
      al_rest(0.01);
 
   }
 
 
   return NULL;
   }
Beispiel #13
0
static void run(void)
{
   ALLEGRO_EVENT event;
   bool quit = false;
   while (!quit) {
      while (al_get_next_event(queue, &event)) {
         if (event.type == ALLEGRO_EVENT_DISPLAY_CLOSE)
            quit = true;
         else if (event.type == ALLEGRO_EVENT_KEY_DOWN) {
            if (event.keyboard.keycode == ALLEGRO_KEY_ESCAPE)
               quit = true;
            else if (event.keyboard.keycode == ALLEGRO_KEY_SPACE) {
               bool opp = !(al_get_display_flags(display) & ALLEGRO_FULLSCREEN_WINDOW);
               al_set_display_flag(display, ALLEGRO_FULLSCREEN_WINDOW, opp);
               redraw();
            }
            else if (event.keyboard.keycode == ALLEGRO_KEY_ENTER) {
               big = !big;
               if (big)
                  al_resize_display(display, 800, 600);
               else
                  al_resize_display(display, 640, 480);
               redraw();
            }
         }
      }
      /* FIXME: Lazy timing */
      al_rest(0.02);
      redraw();
   }
}
Beispiel #14
0
int main() {
    ALLEGRO_DISPLAY *display = NULL;
    if(!al_init() || !al_init_image_addon()) {
        fprintf(stderr, "Não foi possível iniciar o Allegro.\n");
        return -1;
    }
    display = al_create_display(640, 480);
    if(!display) {
        fprintf(stderr, "Não foi possível iniciar o display.\n");
        return -1;
    }
    ALLEGRO_BITMAP *img1 = NULL, *img2 = NULL, *img3 = NULL, *img4 = NULL;
    img1 = al_load_bitmap("A-P.png");
    img2 = al_load_bitmap("A-E.png");
    img3 = al_load_bitmap("A-C.png");
    img4 = al_load_bitmap("A-O.png");
    if(!img1 || !img2 || !img3 || !img4) {
        fprintf(stderr, "Não foi possível criar a imagem.\n");
        return -1;
    }
    al_clear_to_color(al_map_rgb(0, 150, 0));
    al_draw_bitmap(img4, 559, 10, 0);
    al_draw_bitmap(img3, 478, 10, 0);
    al_draw_bitmap(img2, 397, 10, 0);
    al_draw_bitmap(img1, 316, 10, 0);
    al_flip_display();  
    al_rest(10.0);
    al_destroy_display(display);
    return 0;
}
Beispiel #15
0
int main(int argc, const char *argv[])
{
  ALLEGRO_DISPLAY *display = NULL;

  if (!al_init()) {
    fprintf(stderr, "failed to initialize allegro!\n");
    return -1;
  }

  display = al_create_display(640, 480);
  if (!display) {
    fprintf(stderr, "failed to create display!\n");
    return -1;
  }

  al_clear_to_color(al_map_rgb(0,0,0));

  al_flip_display();

  al_rest(10.0);

  al_destroy_display(display);

  return 0;
}
Beispiel #16
0
void drawmonster(int n)
{
    al_init_primitives_addon();
    al_draw_filled_circle(Monstro[n].xlocation, Monstro[n].ylocation, 18, al_map_rgb(0, 0, 255));
    printf("\nmonstro %d foi criado\n", n);
    al_rest(0);
}
Beispiel #17
0
void gdp_splash(){
    int i;
    int ncond = 0,nlogo = 1;

    char *buf;
    ALLEGRO_BITMAP *image = NULL;
    ALLEGRO_THREAD *thread = NULL;

    thread = al_create_thread(gdp_splashclose,(void*) &ncond);
    al_start_thread(thread);

    for(i=0;i<nlogo;i++){
        buf = ".//Images//logo0.png";
        image = al_load_bitmap(buf);

        // se fechar a tela
        if(ncond==1){
            al_destroy_bitmap(image);
            break;
        }
        // se precionar qualquer botao
        if(ncond==2){
            al_destroy_bitmap(image);
            break;
        }

        gdp_fadein(image,1);
        al_rest(0.5);
        gdp_fadeout(image,1);

        al_destroy_bitmap(image);
    }
}
Beispiel #18
0
void event_logic(){
    for(ALLEGRO_EVENT event; al_get_next_event(engine_event_queue,&event);){
//Default event handlers
        switch(event.type){
            case ALLEGRO_EVENT_DISPLAY_CLOSE:
                quit_at_next_frame();
                break;

            case ALLEGRO_EVENT_MOUSE_BUTTON_DOWN:
                if(event.mouse.button==1){
                    for(std::list<renderable*>::iterator iter = ENGINE_SCREEN_MANAGER.buttons.begin();
                        iter != ENGINE_SCREEN_MANAGER.buttons.end(); ++iter){
                        if( (*iter)->active){
                            (*iter)->calc_bounds();
                            if(in_range((*iter)->bounds[0][0],(*iter)->bounds[0][1],mouse_x())
                            && in_range((*iter)->bounds[1][0],(*iter)->bounds[1][1],mouse_y())){
                                ((button*)(*iter))->on_click->exec();
                            }
                        }
                    }
                }
                break;

            case ALLEGRO_EVENT_TIMER:
                if(event.timer.source==timer)
                    draw_now=true;
                break;
        }

        game_event_hooks(event);
    }
    al_rest(0.001);
}
Beispiel #19
0
void Level::dispatchEvent(ALLEGRO_EVENT* event)
{
    if (event->type == ALLEGRO_EVENT_TIMER)
    {
        if (bunny_->atDoor_ >= 0)
        {
            enter(currentRoom_->rooms_.at(bunny_->atDoor_));
        }
        if (bunny_->atPortal_)
        {
            int z = 24;
            while (z > 0)
            {
                bunny_->setPos(375, 225, z);
                draw();
                al_flip_display();
                al_rest(1/60.0);
                z--;
            }
            bunny_->atPortal_ = false;
            nextLevel();
            return;
        }
    }
    else if (event->type == ALLEGRO_EVENT_KEY_DOWN
        || event->type == ALLEGRO_EVENT_KEY_UP)
    {
        bunny_->dispatchEvent(event);
    }
    currentRoom_->dispatchEvent(event);
}
void tela_boot_jogo (Jogo* jogo) {
	ALLEGRO_EVENT_QUEUE *event_queue = NULL;
	ALLEGRO_TIMER *timer = NULL;
	ALLEGRO_EVENT ev;

	int alfa = 0;
	int velocidade = 5;

	ALLEGRO_BITMAP* minerva = al_load_bitmap("resources/minerva.png");
	if (minerva == NULL) {
		puts("Erro ao carregar o arquivo \"resources/minerva.png\"");
		puts("Erro ao carregar o arquivo resources/minerva.png");
		exit(0);
	}

	event_queue = al_create_event_queue();
	timer = al_create_timer(1.0 / 30);

	al_register_event_source(event_queue, al_get_display_event_source(jogo->display));
	al_register_event_source(event_queue, al_get_timer_event_source(timer));

	al_install_keyboard();
	al_register_event_source(event_queue, al_get_keyboard_event_source());

	al_rest(1);

	al_start_timer(timer);

	while (true) {
		alfa += velocidade;

		al_wait_for_event(event_queue, &ev);

		if (ev.type == ALLEGRO_EVENT_TIMER) {

			if (alfa > 0 && alfa < 255) {
				al_clear_to_color(al_map_rgb(0,0,0));
				al_draw_tinted_bitmap(minerva,
									  al_map_rgba(alfa, alfa, alfa, alfa),
									  (jogo->largura - al_get_bitmap_width(minerva))/2,
									  (jogo->altura - al_get_bitmap_height(minerva))/2,
									  0);
				al_flip_display();
			}

			if (alfa > 350)
				velocidade = -velocidade;
			if (alfa < 0)
				break;
		}
		else if (ev.type == ALLEGRO_EVENT_KEY_DOWN) {
			break;
		}
	}

	al_destroy_timer(timer);
	al_destroy_event_queue(event_queue);
	al_destroy_bitmap(minerva);
}
Beispiel #21
0
static mrb_value
rest(mrb_state *mrb, mrb_value self)
{
  mrb_float f;
  mrb_get_args(mrb, "f", &f);
  al_rest(f);
  return mrb_nil_value();
}
Beispiel #22
0
bool Menu()
{
	/* LogoSenac */
	/* -------------------------------------------------------------- */
	DesenhaMenu("Menu/ImagensMenu/FundoBranco.jpg", "Senac", 0, 0);
	FadeInMenu("Menu/ImagensMenu/FundoBranco.jpg", 1);
	TocaEfeitoMenu("Audio/AudioMenu/MenuSenac.wav");
	DesenhaMenu("Menu/ImagensMenu/LogoSenac.jpg", "Senac", 280, 160);
	al_rest(1.0);
	FadeOutMenu(1.0);
	al_destroy_sample(sample);
	/* -------------------------------------------------------------- */

	/* LogoUpGame */
	/* -------------------------------------------------------------- */
	FadeInMenu("Menu/ImagensMenu/FundoBranco.jpg", 1);
	DesenhaMenu("Menu/ImagensMenu/FundoBranco.jpg", "UpGame", 0, 0);
	TocaEfeitoMenu("Audio/AudioMenu/UpGame.wav");
	MovimentaLogo("Menu/ImagensMenu/LogoUpGame.jpg");
	al_rest(0.05);
	FadeOutMenu(1.0);
	al_destroy_sample(Music);
	/* -------------------------------------------------------------- */

	/* Imagem ET */
	/* -------------------------------------------------------------- */
	FadeInMenu("Menu/ImagensMenu/FundoBranco.jpg", 1);
	DesenhaMenu("Menu/ImagensMenu/ET.jpg", "Menu", 0, 0);
	TocaMusicaFundo("Audio/AudioMenu/ET.wav");
	PressioneQualquerTecla("Menu/ImagensMenu/ET.jpg");
	al_destroy_sample(sample);
	/* -------------------------------------------------------------- */

	/* Lopping Principal do Menu */
	FadeInMenu("Menu/ImagensMenu/FundoBranco.jpg", 1);
	DesenhaMenu("Menu/ImagensMenu/ImagemMenuInicio.jpg", "Menu Principal", 0, 0);
	TocaMusicaFundo("Audio/AudioMenu/MusicaMenuPrincipal.wav");

	if(!MenuLopping())
		return false;

	al_destroy_sample(Music);

	return true;
}
Beispiel #23
0
void m_rest(double seconds)
{
	int i = (int)seconds;
	double remainder = seconds-i;

	for (int j = 0; j < i; j++) {
		al_rest(1);
		if (is_close_pressed()) {
			do_close();
			close_pressed = false;
		}
		if (break_main_loop) {
			break;
		}
	}

	al_rest(remainder);
}
Beispiel #24
0
// Update (goto menu!)
void intro::update(){
  // Intro screen
  //fade_in( img_intro, 16);
  al_rest( 1.0);
  //fade_out( 16);

  // Go to menu
  set_next_state( STATE_MENU);
}
Beispiel #25
0
static void *thread_func(ALLEGRO_THREAD *thr, void *arg)
{
   ThreadInfo *info = (ThreadInfo *) arg;
   Viewport viewport;
   unsigned char palette[256][3];
   int y, w, h;

   y = 0;
   w = al_get_bitmap_width(info->bitmap);
   h = al_get_bitmap_height(info->bitmap);

   viewport.centre_x = info->target_x;
   viewport.centre_y = info->target_y;
   viewport.x_extent = 3.0;
   viewport.y_extent = 3.0;
   viewport.zoom = 1.0;
   info->target_x = 0;
   info->target_y = 0;

   while (!al_get_thread_should_stop(thr)) {
      al_lock_mutex(info->mutex);

      while (info->is_paused) {
         al_wait_cond(info->cond, info->mutex);

         /* We might be awoken because the program is terminating. */
         if (al_get_thread_should_stop(thr)) {
            break;
         }
      }

      if (!info->is_paused) {
         if (y == 0) {
            random_palette(palette, &info->random_seed);
         }

         draw_mandel_line(info->bitmap, &viewport, palette, y);

         y++;
         if (y >= h) {
            double z = viewport.zoom;
            y = 0;
            viewport.centre_x += z * viewport.x_extent * info->target_x;
            viewport.centre_y += z * viewport.y_extent * info->target_y;
            info->target_x = 0;
            info->target_y = 0;
            viewport.zoom *= 0.99;
         }
      }

      al_unlock_mutex(info->mutex);
      al_rest(0);
   }

   return NULL;
}
Beispiel #26
0
static void * threadedSegment(ALLEGRO_THREAD *read_thread, void *arg)
{
    while(!al_get_thread_should_stop(read_thread)) {
        map_segment.lockRead();
        read_segment(arg);
        map_segment.unlockRead();
        al_rest(ssConfig.automatic_reload_time/1000.0);
    }
    return 0;
}
Beispiel #27
0
void
_display_loop (void)
{
  context_switch_allegro ();

  ALLEGRO_BITMAP *bmp;
  bmp = al_create_bitmap (640, 480);

  int blah;
  for (blah=0; blah < 64; ++blah)
    {
      struct fbstate_data fbd;

      context_switch_cogl ();
      fbd = fbstate_get_data ();

      context_switch_allegro ();
      ALLEGRO_LOCKED_REGION *rgn;
      rgn = al_lock_bitmap (bmp, ALLEGRO_PIXEL_FORMAT_BGR_888, ALLEGRO_LOCK_READWRITE);
      int cnt;
      char *data;
      for (cnt=0,data=rgn->data; cnt < 480; ++cnt,data+=rgn->pitch)
        {
          memcpy (data, &fbd.data[cnt*640*3], 640*3);
        }
      al_unlock_bitmap (bmp);

      context_switch_cogl ();
      CoglColor clear_color;
      cogl_color_set_from_4ub (&clear_color, '0', '0', '0', 255);
      cogl_clear (&clear_color, COGL_BUFFER_BIT_COLOR);
      _example_draw_at (blah, blah);

      context_switch_allegro ();
      al_set_target_backbuffer (fbd.display);
      al_draw_bitmap (bmp, 0, 0, 0);
      al_flip_display ();

      al_rest (0.1f);
    }

  al_rest (2.0f);
}
Beispiel #28
0
LEVEL *
level_next(LEVEL *level)
{
  LEVEL *old = level;
  level = level_create(old->number + 1, old->score);
  level_free(old);
  al_rest(2.0);

  return level;
}
Beispiel #29
0
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;
}
Beispiel #30
0
void gameLoop()
{
	sprite_Handles.push_back(SpriteManager.Add("ground.png"));
	sprite_Handles.push_back(SpriteManager.Add("player.png"));

	GraphicsManager.DrawSprite("ground.png",0,0,0, SpriteManager);

	al_flip_display();
	al_rest(2.0);
	cleanUp();
}