コード例 #1
0
void ApagaLocalidade(DIST *distrito)
{
	LOCAL *aux, *ante = NULL;
	int dist, conta = 0;
	char nomelocal[SSIZE];
	printf("Insira a localidade a apagar:");
	fgets(nomelocal,SSIZE,stdin);
	nomelocal[strlen(nomelocal)-1] = '\0';
	for(dist = 0;dist < NDIST;dist++)
	{
		aux = distrito[dist].local;
		ante = distrito[dist].local;
		while(aux != NULL)
		{
			if(strcmp(aux->localidade,nomelocal) == 0)
			{
				allegro_init();
				allegro_message("Localidade %s apagada do distrito %s.",aux->localidade,distrito[dist].nomedist);
				allegro_exit();
				distrito[dist].local = ApagaProx(distrito[dist].local,ante,aux);
				conta++;
			}
			ante = aux;
			aux = aux->prox;
		}
	}
	if(conta == 0)
	{
		allegro_init();
		allegro_message("Não foram encontradas localidades com o nome \"%s\".",nomelocal);
		allegro_exit();
	}
}
コード例 #2
0
ファイル: main.cpp プロジェクト: lastab/BagChal
int check_game_over()
{
    int fixed_tiger=0;
    int game,m1,m2;
    for(int j=0; j<5;j++)
    {
     for (int k=0; k<5;k++)
     {
         m1=check_possible_movement(j,k);
         m2=check_possible_jump_movement(j,k);
      if (location[j][k]==1 && m1==0 && m2==0)     
         fixed_tiger++;
     }
    }

    if(fixed_tiger==4)
    {
               game=1;
               allegro_message("tigers that are fixed=%d GOAT WINS",fixed_tiger);
    }           
    else if (count_dead_goat > 5)
    {
         game=2;
         allegro_message("goats dead= %d TIGER WINS",count_dead_goat);
    }
    else
         game=0;
}
コード例 #3
0
ファイル: circ12.c プロジェクト: makhtardiouf/C_Cpp
int main ()
{
    // initialize Allegro
    if (allegro_init () < 0)
    {
        allegro_message ("Error: Could not initialize Allegro");
        return -1;
    }
    // initialize gfx mode
    if (set_gfx_mode (GFX_AUTODETECT, 320, 200, 0, 0) < 0)
    {
        allegro_message ("Error: Could not set graphics mode");
        return -1;
    }
    // initialize keyboard
    install_keyboard ();
    clear_keybuf ();

    // call the example function
    test_mode_7 ();

    // exit Allegro
    allegro_exit ();

    return 0;

} END_OF_MAIN ();
コード例 #4
0
void MostraLocals(DIST *distrito)
{
	LOCAL *aux;
	int dist;
	char nomedist[SSIZE];
	printf("Insira o distrito:");
	fgets(nomedist,SSIZE,stdin);
	nomedist[strlen(nomedist)-1] = '\0';
	for(dist = 0;dist < NDIST;dist++)			/*Corre os distritos*/
		if(strcmp(distrito[dist].nomedist,nomedist) == 0)	/*Pára no distrito com o nome igual ao inserido.("dist" guarda o numero do distrito)*/
			break;
	if(strcmp(distrito[dist].nomedist,nomedist) != 0)       /*se sair do ciclo anterior sem encontrar o distrito*/
	{
		allegro_init();
		allegro_message("Não foram encontradas distrito com o nome \"%s\".",nomedist);
		allegro_exit();
		return;
	}
	if(distrito[dist].local == NULL)
	{
		allegro_init();
		allegro_message("Distrito vazio.");
		allegro_exit();
		return;
	}
	aux = distrito[dist].local;
	while(aux != NULL)			/*corre todas as localidades do distrito*/
	{
		MostraInfo(aux->localidade,aux->latitude,aux->longitude);
		aux = aux->prox;
	}
	printf("Enter para continuar...");
	while(getchar() != '\n');
}
コード例 #5
0
ファイル: example.c プロジェクト: Berneer/editor-on-fire
int main(int argc, char *argv[]) { 
  allegro_init();

  if (argc < 2) {
    allegro_message("Usage: %s files ...\n", argv[0]);
    return 1;
  }

  install_timer();
  install_keyboard();

  if (set_gfx_mode(GFX_SAFE, 640, 480, 0, 0) < 0) {
    allegro_message("Error setting video mode.\n");
    return 1;
  }
  clear_to_color(screen, makecol(255, 255, 255));

  /* to achieve the max possible volume */
  set_volume_per_voice(0);

  if (install_sound(DIGI_AUTODETECT, MIDI_NONE, 0) < 0) {
    set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
    allegro_message("Error installing sound.\n");
    return 1;
  }

  do_example(argc-1, argv+1);

  allegro_exit();

  return 0;
}
コード例 #6
0
ファイル: main.cpp プロジェクト: riseven/JrvLabyrinth
int main(int argc, char *argv[])
{
	allegro_init();
	install_allegro_gl();
	install_keyboard();
	install_mouse();
    
    try
    {
        Juego::Inicializar() ;
        
        Juego *juego = new Juego();
        juego->BuclePrincipal();
        delete juego ;    
            
        Juego::Cerrar();        
    }
    catch ( Excepcion &ex )
    {
        set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
        allegro_message("%s\n", ex.GetMensajeDeError().c_str());
    }
    catch ( exception &ex )
    {
        set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
        allegro_message("%s\n", ex.what() );
    }    
}
コード例 #7
0
ファイル: main.cpp プロジェクト: olofn/db_public
int main(int argc, char **argv)
{
    try
    {
        Game game;
        game.run();
    }
    catch (Exception e)
    {
        std::string str;
        std::ostringstream os(str);

        os << "A game exception occured: \"" << e.getMessage() << "\" "
           << "in function " << e.getFunction()
           << " at line " << e.getLine()<< ".";

        std::cerr << os.str() << std::endl;

        allegro_message(os.str().c_str());
        return 1;
    }
    catch (gcn::Exception e)
    {
        std::string str;
        std::ostringstream os(str);

        os << "A guichan exception occured: \"" << e.getMessage() << "\" "
           << "in function " << e.getFunction()
           << " at line " << e.getLine()<< ".";

        std::cerr << os.str() << std::endl;

        allegro_message(os.str().c_str());
        return 1;
    }
    catch (std::exception e)
    {
        std::string str;
        std::ostringstream os(str);

        os << "An STD exception occured: \"" << e.what() << "\".";

        std::cerr << os.str() << std::endl;

        allegro_message(os.str().c_str());
        return 1;
    }
    catch (...)
    {
        std::string error = "An unknown exception occured (this is generally very bad).";

        std::cerr << error << std::endl;
        allegro_message(error.c_str());
        return 1;
    }

    return 0;
}
コード例 #8
0
ファイル: mapeditor.c プロジェクト: andreasg/gunsmoke
int main(int argc, char *argv[])
{
    scew_parser *parser = NULL;
    if (init() != 0) {
        return 1;
    }

    if (argc == 2) {
        if (exists(argv[1])) {
            parser = scew_parser_create();
            scew_parser_ignore_whitespaces(parser, 1);
            scew_parser_load_file(parser, argv[1]);
            maptree = scew_parser_tree(parser);
        } else {
            allegro_message("Cannot load file: %s", argv[1]);
            close_program = 1;
        }
    } else if (argc == 4) {
        maptree = new_map(0, MAP_WIN.w / TILE_W, atoi(argv[1]), 1, argv[2]);
        map_offset = atoi(argv[1]) * TILE_H - EDITOR_WIN_H;
    } else {
        /* print usage */
        allegro_message
            ("Usage:\n\"editor.exe <filename>\" to load a file\n \"editor.exe <height_in_tiles> <default_tile_name> <newmapfile>\" to create a new map");

        close_program = 1;
    }

    while (!close_program) {
        /* get input */
        parse_mouse();
        get_grid_item();
        if (keypressed()) {
            parse_keyboard();
        }

        /* blit virtual screen */
        clear_to_color(vscreen, DEAD_COLOR);
        draw_select_lists(vscreen);
        draw_ctrl_box(vscreen);

        update_screen();
    }

    if (argc == 2) {
        write_map(argv[1], maptree);
        scew_parser_free(parser);
    } else if (argc == 4) {
        write_map(argv[3], maptree);
        scew_tree_free(maptree);
    }
    destroy_bitmap(vscreen);
    cleanup();
    return 0;
}
コード例 #9
0
void TileRepository::exportBitmap(const char *filename, int tile_w, int tile_h, int tile_spacing, int tiles_in_row)
{
	list<TileType*> tiles_to_save;
	map<const char*, TileType*, ltstr>::iterator i;
	list<TileType*>::iterator j;
	char tempTilename[256];
	char tempFilename[256];
	replace_extension(tempFilename, get_filename(filename), "", 256);

	if (!(tiles_in_row > 0 && tile_w > 0 && tile_h > 0)) {
		allegro_message("WARNING: tiles_in_row (%d), tile_w (%d) and tile_h (%d) must all be larger than 0.", tiles_in_row, tile_w, tile_h);
		return;
	}

	for (i = tileTypes.begin(); i != tileTypes.end(); i++)
	{
		TileType* tempTileType = (*i).second;
		replace_extension(tempTilename, tempTileType->getName(), "", 256);
		if (ustrcmp(tempFilename, tempTilename) == 0) {
			tiles_to_save.push_back(tempTileType);
		}
	}

	if (tiles_to_save.empty()) {
		allegro_message("WARNING: No tiles to save in %s.", filename);
		return;
	}

	BITMAP *tile_bitmap;
	PALETTE pal;

	tile_bitmap = create_bitmap
	(
		tiles_in_row * tile_w,
		(tiles_to_save.size() / tiles_in_row +
		 tiles_to_save.size() % tiles_in_row) * tile_h
	);
	int x = 0;
	int y = 0;

	for (j = tiles_to_save.begin(); j != tiles_to_save.end(); j++)
	{
		blit((*j)->getBitmap(), tile_bitmap, 0, 0, x * tile_w, y * tile_h, tile_w, tile_h);
		x++;
		if (x == tiles_in_row) {
			y++;
			x = 0;
		}
	}

	get_palette(pal);
	save_bitmap(filename, tile_bitmap, pal);

	destroy_bitmap(tile_bitmap);
}
コード例 #10
0
void MenuMapas(DIST *distrito, CTD *contorno)
{
	char esc, nomelocal[SSIZE];
	float zoom = 1;
	LOCAL *locref = NULL;
	while(1){
		system("clear");
		printf("0 – Regressar ao menu anterior\n");
		printf("1 – Seleccao da localidade de referência\n");
		printf("2 – Seleccao da escala\n");
		printf("3 – Visualizar as localidades em redor da referencia\n");
		printf("4 – Apresentar uma rota\n");
		printf("	Opção: ");
		esc = getchar();			/*le o primeiro caracter inserido*/
		if(getchar() != '\n'){
			while(getchar() != '\n');		/*descarta todos os outros*/
			esc = 'x';
		}
		switch(esc)
		{
			case '0':
				return;
			case '1':
				printf("Insira a localidade:");
				fgets(nomelocal,SSIZE,stdin);
				nomelocal[strlen(nomelocal)-1] = '\0';
				locref = RetLocal(distrito,nomelocal);
				break;	
			case '2':
				printf("Insira a escala (pixeis/km):");
				scanf("%f",&zoom);
				getchar();
				if(zoom < 0){
					zoom = 1;
					allegro_init();
					allegro_message("O zoom deve ser um valor superior a zero.");
					allegro_exit();
				}
				break;
			case '3':
				if(locref == NULL){		/*verifica se esta definida uma localidade de referencia*/
					allegro_init();
					allegro_message("Deve defenir primeiro uma localidade de referencia.");
					allegro_exit();
				}
				else
					VerMapa(distrito,contorno,zoom,locref);
				break;
			case '4':		
				DesenhaRota(distrito,contorno);
				break;
		}
	}
}
コード例 #11
0
ファイル: main.cpp プロジェクト: dacap/defenderofnothing
int main()
{
  std::srand(std::time(NULL));

  allegro_init();
  install_timer();
  install_keyboard();
//   install_mouse();
  install_joystick(JOY_TYPE_AUTODETECT);

  override_config_file(redir("defnot.ini").c_str());

  gfx_widescreen = get_config_int("Game", "Widescreen", gfx_widescreen);
  gfx_fullscreen = get_config_int("Game", "Fullscreen", gfx_fullscreen);

  if (!setup_gfx() != 0) {
    allegro_message("Unable to setup the graphics mode\n");
    return 1;
  }

//   if (gfx_capabilities & GFX_HW_CURSOR) {
//     enable_hardware_cursor();
//     select_mouse_cursor(MOUSE_CURSOR_ARROW);
//     show_mouse(screen);
//   }

  if (!load_media()) {
    allegro_message("Unable to load data files to play the game\n");
    return 1;
  }

  // install the timer to control the game speed
  LOCK_VARIABLE(beats);
  LOCK_FUNCTION(timer_control);

  beats = 0;
  install_int_ex(timer_control, BPS_TO_TIMER(BPS));

  // insert the callback routine for the close-button
  LOCK_VARIABLE(continuing);
  LOCK_FUNCTION(close_button);

  set_close_button_callback(close_button);

  // play the game
  game_loop();

  set_config_int("Game", "Widescreen", gfx_widescreen);
  set_config_int("Game", "Fullscreen", gfx_fullscreen);

  remove_int(timer_control);
  allegro_exit();
  return 0;
}
コード例 #12
0
ファイル: Player.cpp プロジェクト: i7621900/Runners
Play::Play()
{
	//Create Player Array
	BITMAP* temp = create_bitmap(608,32); //Size of Sprite BMP

	temp = load_bitmap("Allegro Game Walking Sprite Sheet.bmp", 0);
	if (!temp) // Error checking
	{
		allegro_message("Error, temp bitmap");
		exit(1);
	}

	//Fill Player Array
	for (int i = 0; i <= 10; i++)
	{
		Player[i] = create_bitmap(32,32);
		blit(temp, Player[i], i * 32, 0, 0, 0, 32, 32);
	}
	destroy_bitmap(temp);

	//Create Background Array
	BITMAP* B_Temp = create_bitmap(3200,600); //Size of Background Sprite

	B_Temp = load_bitmap("Background.bmp",0);
	if(!B_Temp)
	{
		allegro_message("Error, B_Temp bitmap");
		exit(1);
	}

	//Fill Background Array
	for (int i = 0; i <= 3; i++)
	{
		Backgrounds[i] = create_bitmap(800,600);
		blit(B_Temp, Backgrounds[i], i * 800, 0, 0, 0, 800, 600);
	}
	destroy_bitmap(B_Temp);

	PlayerSpeed = 10;
	PlayerX = 0;
	PlayerY = 0;
	animCounter = 0;
	Jumping = 0; 
	Velocity = 1;
	Back_Counter = 0; 
	Score = 0; 
	HighScore = 0; 
	PlayerCamX = 0;

	Floor_Collision = false; 
	Block_Collision = false; 
	Player_Jump = false; 
	//BoxTouch = false; 
}
コード例 #13
0
ファイル: bgui.c プロジェクト: rofl0r/GfxRip
void memverify_str(void *pointer, char *str)
{
 if(!pointer)
 {
  set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
  if(str)
   allegro_message("The program that you are running has run out of memory, and cannot continue. %s ", str);
  else 
   allegro_message("The program that you are running has run out of memory, and cannot continue.");
  exit(EXIT_FAILURE);
 }
}
コード例 #14
0
void CriaLocalidade(DIST *distrito)
{
	char ndist[SSIZE], local[SSIZE];
	float latitude, longitude;
	int dist;
	LOCAL *aux;
	printf("Insira o distrito:");
	fgets(ndist,SSIZE,stdin);
	ndist[strlen(ndist)-1] = '\0';
	for(dist = 0;dist < NDIST;dist++)			/*procura pelo nome do distrito*/
		if(strcmp(distrito[dist].nomedist,ndist) == 0)
			break;
	if(strcmp(distrito[dist].nomedist,ndist) != 0)
	{
		allegro_init();
		allegro_message("Distrito não encontrado");
		allegro_exit();
		return;
	}
	printf("Insira o nome da localidade a criar:");
	fgets(local,SSIZE,stdin);
	local[strlen(local)-1] = '\0';
		for(dist = 0;dist < NDIST;dist++)
	{
		aux = distrito[dist].local;
		while(aux != NULL)
		{
			if(strcmp(aux->localidade,local) == 0)
			{
				allegro_init();
				allegro_message("Localidade ja existente!!");
				allegro_exit();
				return;
			}
			aux = aux->prox;
		}
	}
	printf("Latitude:");
	scanf("%f",&latitude);
	printf("Longitude:");
	scanf("%f",&longitude);
	getchar();
	if(latitude > 90 || latitude < -90 || longitude > 180 || longitude < -180)
	{
		allegro_init();
		allegro_message("Coordenadas invalidas!");
		allegro_exit();
		return;
	}
	distrito[dist].local = InsereLocalidade(distrito[dist].local,local,latitude,longitude);		/*insere no fim da lista distrito[dist].local*/
}
コード例 #15
0
ファイル: mix.c プロジェクト: cincodenada/editor-on-fire
void eof_mix_init(void)
{
	int i;
	char fbuffer[1024] = {0};

	eof_log("eof_mix_init() entered", 1);

	eof_sound_clap = load_wav("eof.dat#clap.wav");
	if(!eof_sound_clap)
	{
		allegro_message("Couldn't load clap sound!");
	}
	eof_sound_metronome = load_wav("eof.dat#metronome.wav");
	if(!eof_sound_metronome)
	{
		allegro_message("Couldn't load metronome sound!");
	}
	eof_sound_grid_snap = load_wav("eof.dat#gridsnap.wav");
	if(!eof_sound_grid_snap)
	{
		allegro_message("Couldn't load seek sound!");
	}
	for(i = 0; i < EOF_MAX_VOCAL_TONES; i++)
	{	//Load piano tones
		(void) snprintf(fbuffer, sizeof(fbuffer) - 1, "eof.dat#piano.esp/NOTE_%02d_OGG", i);
		eof_sound_note[i] = eof_mix_load_ogg_sample(fbuffer);
	}
	eof_sound_cowbell = eof_mix_load_ogg_sample("percussion.dat#cowbell.ogg");
	eof_sound_chosen_percussion = eof_sound_cowbell;	//Until the user specifies otherwise, make cowbell the default percussion
	eof_sound_tambourine1 = eof_mix_load_ogg_sample("percussion.dat#tambourine1.ogg");
	eof_sound_tambourine2 = eof_mix_load_ogg_sample("percussion.dat#tambourine2.ogg");
	eof_sound_tambourine3 = eof_mix_load_ogg_sample("percussion.dat#tambourine3.ogg");
	eof_sound_triangle1 = eof_mix_load_ogg_sample("percussion.dat#triangle1.ogg");
	eof_sound_triangle2 = eof_mix_load_ogg_sample("percussion.dat#triangle2.ogg");
	eof_sound_woodblock1 = eof_mix_load_ogg_sample("percussion.dat#woodblock1.ogg");
	eof_sound_woodblock2 = eof_mix_load_ogg_sample("percussion.dat#woodblock2.ogg");
	eof_sound_woodblock3 = eof_mix_load_ogg_sample("percussion.dat#woodblock3.ogg");
	eof_sound_woodblock4 = eof_mix_load_ogg_sample("percussion.dat#woodblock4.ogg");
	eof_sound_woodblock5 = eof_mix_load_ogg_sample("percussion.dat#woodblock5.ogg");
	eof_sound_woodblock6 = eof_mix_load_ogg_sample("percussion.dat#woodblock6.ogg");
	eof_sound_woodblock7 = eof_mix_load_ogg_sample("percussion.dat#woodblock7.ogg");
	eof_sound_woodblock8 = eof_mix_load_ogg_sample("percussion.dat#woodblock8.ogg");
	eof_sound_woodblock9 = eof_mix_load_ogg_sample("percussion.dat#woodblock9.ogg");
	eof_sound_woodblock10 = eof_mix_load_ogg_sample("percussion.dat#woodblock10.ogg");
	eof_sound_clap1 = eof_mix_load_ogg_sample("percussion.dat#clap1.ogg");
	eof_sound_clap2 = eof_mix_load_ogg_sample("percussion.dat#clap2.ogg");
	eof_sound_clap3 = eof_mix_load_ogg_sample("percussion.dat#clap3.ogg");
	eof_sound_clap4 = eof_mix_load_ogg_sample("percussion.dat#clap4.ogg");
}
コード例 #16
0
ファイル: gfx.c プロジェクト: andreasg/gunsmoke
/* search_gfx_list: looks in the external var gfx_list for *name and returns
 * it's BITMAP pointer, if not found in the list it returns a blank
 * bitmap, with TILE_W and TILE_H as it's size */
BITMAP *search_gfx_list(char *name, GFX_OBJ *gfx_list, size_t sz)
{
    size_t i;
    if (!gfx_list) {
         allegro_message("gfx_list==NULL\nname=%s\nsz=%i", name, sz);
         return NULL;
    }
    for (i = 0; i < sz; i++) {
         if (gfx_list[i].name[0] == name[0] && strcmp(gfx_list[i].name, name) == 0) {
              return gfx_list[i].img;
        }
    }
    allegro_message("search faied.\nname=%s\nsz=%i", name, sz);
    return NULL;
}
コード例 #17
0
ファイル: main.cpp プロジェクト: danwardvs/Old-Games
void setup(){
     
     buffer = create_bitmap( 900, 680);
     if (!(bobby = load_bitmap("bobby.bmp", NULL)))
    {
        allegro_message("Cannot find image Bobby.bmp\nPlease check your files and try again");
        exit(-1);
    }
      if (!(scene1 = load_bitmap("scene1.bmp", NULL)))
    {
        allegro_message("Cannot find image Scene1.bmp\nPlease check your files and try again");
        exit(-1);
    }

}
コード例 #18
0
ファイル: initialization.c プロジェクト: ChrisCooper/SPQR
/*  allegInitializations()

Initializes allegro and its associated packages (algif), as well as installing
hardware settings for mouse, keyboard, sound, timers, and the screen.
Autochecks for errors, and displays message and exits(1) on error.

*/
void allegInitializations()
{
	int error = 0;
	srand(time(0));
   error |= allegro_init ();
	algif_init ();

   	set_color_depth (16);
   	//set_gfx_mode(GFX_AUTODETECT_WINDOWED, 900,600,0,0);
   	set_gfx_mode(GFX_AUTODETECT_FULLSCREEN, 1024,768,0,0);
   	install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, NULL);
   	install_keyboard ();
   	install_mouse();
   	error |= install_timer();
   	error |= install_int_ex(incrementTimer, BPS_TO_TIMER(60));
   	error |= install_int_ex(incrementUpdateCounter, BPS_TO_TIMER(4));
   	error |= install_int_ex(incrementAnimateCounter, BPS_TO_TIMER(8));
   	error |= install_int_ex(incrementEconomyCounter, BPM_TO_TIMER(60));
   	error |= install_int_ex(incrementFireCounter, BPS_TO_TIMER(12));
	if (error)
	{
		set_gfx_mode(GFX_TEXT, 1024,768,0,0);
		allegro_message("Allegro Failed to Initialize!");
		exit(1);
	}

}
コード例 #19
0
ファイル: tools.cpp プロジェクト: ADSgames/MineSweeper
/*
 *  ERROR REPORTING
 */
void abort_on_error(const char *message){
	 if (screen != NULL){
	    set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
	 }
	 allegro_message("%s.\n %s\n", message, allegro_error);
	 exit(-1);
}
コード例 #20
0
ファイル: load.c プロジェクト: mtmiron/lich
void
prompt_to_load_file()
{
	char msg[] = "Please select the map file you wish to load";
	char path[FILENAME_MAX * 6] = { "\0" };
	int result;

	mouse_callback = NULL;
	result = file_select_ex(msg, path, "txt", sizeof(path), 0, 0);
	if (!result)
	{
		if (nodelist != NULL && vector_len((vector_t*)nodelist) > 0)
			return;
		allegro_message("You did not select a file to load: there's nothing for the program to do.  Exiting.");
		exit(0);
	}

	if (debugging)
		fprintf(stderr, "%s\n", path);
	nodelist = load_file(path);

	render_image(screen);
	render_image(backbuffer);
	render_info(screen);
	render_info(backbuffer);
	strncpy(last_file, path, sizeof(last_file));
	mouse_callback = mouse_cb;
}
コード例 #21
0
int sauvegarde_niveau(int valeurs[15][19], char mot[50])
{
    int nb,i=0,j=0;
    FILE* noms_sauvegardes;
    FILE* sauvegarde;
    noms_sauvegardes= fopen("noms_sauvegardes.txt", "r+t");
    fscanf(noms_sauvegardes, "%d", &nb);
    if (strlen(mot)<44)
    {
    strcat(mot, ".txt");
    }
    else
    {
        allegro_message("le nom est trop long!");
        return 1;
    }
    sauvegarde = fopen(mot, "w+");

    fseek(noms_sauvegardes, 0, SEEK_SET);
    fprintf(noms_sauvegardes, "%d ", ++nb);
    fseek(noms_sauvegardes, 0, SEEK_END);
    fprintf(noms_sauvegardes, " %s", mot);
    i=0;
    j=0;
    for (i=0; i<15; i++)
    {
        for(j=0; j<19; j++)
                {
                    fprintf(sauvegarde, "%d ", valeurs[i][j]);
                }
    }
    fclose(sauvegarde);
    fclose(noms_sauvegardes);
    return 0;
}
コード例 #22
0
ファイル: xkeymap.c プロジェクト: sesc4mt/mvcdecoder
int main(void)
{
   int i;

   allegro_init();
   install_keyboard();
   install_mouse();
   install_timer();

   if (set_gfx_mode(GFX_SAFE, 640, 480, 0, 0) != 0) {
      set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
      allegro_message("Unable to set any graphic mode\n%s\n", allegro_error);
      exit(EXIT_FAILURE);
   }
   set_palette(desktop_palette);
   gui_fg_color = palette_color[255];
   gui_bg_color = palette_color[16];

   black = makecol(0, 0, 0);
   white = makecol(255, 255, 255);
   red = makecol(255, 0, 0);
   yellow = makecol(255, 255, 0);

   /* Clear key mappings.  */
   for (i = 0; i < 256; i++)
      keycode_to_scancode[i] = -1;

   /* Hook the X keyboard callback.  */
   _xwin_keyboard_callback = get_raw_keycode;

   show_main_dialog();

   return 0;
}
コード例 #23
0
//fungsi untuk menggerakkan snake
int move_snake(SNAKE *snake, int moveX, int moveY, int map[SIZE_Y][SIZE_X])
{
    map[snake->y][snake->x] = PATH;
    while(true)
    {
        if(snake->next == NULL)
        {
            snake->x += moveX;
            if(snake->x >= SIZE_X) snake->x = 0;
            else if(snake->x < 0) snake->x = SIZE_X - 1;

            snake->y += moveY;
            if(snake->y >= SIZE_Y) snake->y = 0;
            else if(snake->y < 0) snake->y = SIZE_Y - 1;

            if(map[snake->y][snake->x] < 0) {
                allegro_message("nabrak...");
                return 0;
            }
            map[snake->y][snake->x] = HEAD;
            return 1;
        }
        snake->x = snake->next->x;
        snake->y = snake->next->y;
        map[snake->y][snake->x] = BODY;
        snake = snake->next;
    }
}
コード例 #24
0
ファイル: exspline.c プロジェクト: AntonLanghoff/whitecatlib
/* main program */
int main(void)
{
   int c;

   if (allegro_init() != 0)
      return 1;
   install_keyboard();
   install_mouse();
   install_timer();

   if (set_gfx_mode(GFX_AUTODETECT, 640, 480, 0, 0) != 0) {
      if (set_gfx_mode(GFX_SAFE, 640, 480, 0, 0) != 0) {
	 set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
	 allegro_message("Unable to set any graphic mode\n%s\n",
			 allegro_error);
	 return 1;
      }
   }

   set_palette(desktop_palette);

   input_nodes();
   calc_tangents();

   curviness = ftofix(0.25);
   show_tangents = FALSE;
   show_control_points = FALSE;

   draw_splines();

   for (;;) {
      if (keypressed()) {
	 c = readkey() >> 8;
	 if (c == KEY_ESC)
	    break;
	 else if (c == KEY_UP) {
	    curviness += ftofix(0.05);
	    draw_splines();
	 }
	 else if (c == KEY_DOWN) {
	    curviness -= ftofix(0.05);
	    draw_splines();
	 }
	 else if (c == KEY_SPACE) {
	    walk();
	    draw_splines();
	 }
	 else if (c == KEY_T) {
	    show_tangents = !show_tangents;
	    draw_splines();
	 }
	 else if (c == KEY_C) {
	    show_control_points = !show_control_points;
	    draw_splines();
	 }
      }
   }

   return 0;
}
コード例 #25
0
int main(int argc, char **argv)
{
	if (allegro_init() != 0)
		return 1;

	install_keyboard();

	if (set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 200, 0, 0) != 0) {
		if (set_gfx_mode(GFX_SAFE, 320, 200, 0, 0) != 0) {
			set_gfx_mode(GFX_TEXT, 0, 0, 0, 0);
			allegro_message("Unable to set any graphics mode:\n"
					"%s\n", allegro_error);
			return 1;
		}
	}

	black = makecol(0,0,0);
	white = makecol(255,255,255);

	clear_to_color(screen, black);
	test_unicode();
	readkey();

	set_uformat(U_ASCII);

	clear_to_color(screen, black);
	test_cp437();
	readkey();

	clear_to_color(screen, black);
	test_ascii();
	readkey();

	return 0;
}
コード例 #26
0
void VerMapa(DIST *distrito, CTD *contorno,float zoom,LOCAL *localref)
{
	int ret,cod;
	COORD *aux, *coordenadas;
	double oldlatitude, oldlongitude;
	double latitude, longitude;
	allegro_init();
	ret = set_gfx_mode(GFX_AUTODETECT_WINDOWED, LARGURA_JANELA, ALTURA_JANELA, 0, 0);
	if (ret != 0)
	{
		allegro_message("Graphic error- Exiting");
		return;
	}
	floodfill(screen,1,1,BGCOL);							/*Pinta a tela (cor do fundo) com a cor defenida em BGCOL*/
	textprintf_ex(screen, font,3,3,TCOL, -1,"Centrado em: \"%s\" Zoom = %.2f px/km",localref->localidade,zoom);
	for(cod = 0 ; cod < NFRON; cod++)		/*Corre todas as listas de contornos*/
	{	
		coordenadas = contorno[cod].coord;
		aux = coordenadas;
		while(aux->prox != NULL)		/*Le a lista do contorno ate ao fim*/
		{
			oldlatitude = transf_lat(aux->latitude,zoom,localref->latitude,SCREEN_H);
			oldlongitude = transf_lon(aux->latitude,aux->longitude,zoom,localref->longitude,SCREEN_W);
			aux = aux->prox;
			latitude = transf_lat(aux->latitude,zoom,localref->latitude,SCREEN_H);
			longitude = transf_lon(aux->latitude,aux->longitude,zoom,localref->longitude, SCREEN_W);
			line(screen,oldlongitude,oldlatitude,longitude,latitude,contorno[cod].cor);
		}
	}
	DesenhaTodasLocal(distrito,localref->latitude,localref->longitude,zoom);
	install_keyboard();	
	readkey();              /*Espera que uma tecla seja clicada*/
	allegro_exit();
}
コード例 #27
0
ファイル: EX_bsp2.c プロジェクト: omer4d/SuperOldCode
void init()
{
    allegro_init();
    set_color_depth(32);

    if(set_gfx_mode(GFX_AUTODETECT_WINDOWED, 320, 240, 0, 0))
    {
        allegro_message("%s.", allegro_error);
        exit(1);
    }

    init_engine(SCREEN_W, SCREEN_H);
    point_at_color_buffer(&buffer);
    setup_projection(90.0, -1.333, 1.333, -1.0, 1.0, 0.0, 200.0);
    set_znear(1.0);
    set_clipping_rect(10, 10, buffer->w - 11, buffer->h - 11);
    init_clipper();
    set_rasterizer_function(flat_zbuff_sides);
    set_world_clip_func(2, wclip_to_rend_int, 0, 0, 0, 0);
    set_scr_clip_func(4, rend_int_to_tri, 0, 0, 0, 0);

    install_keyboard();
    install_mouse();
    srand(time(NULL));
}
コード例 #28
0
ファイル: level_editor.c プロジェクト: zeldrone/finn_ice_info
int sauvegarde_niveau(int valeurs[15][19], char mot[50])
{
    int nb,i = 0,j = 0;
    FILE* noms_sauvegardes;
    FILE* sauvegarde;
    noms_sauvegardes= fopen("noms_sauvegardes.txt", "r+t");//ouvre le fichier pour stocker les noms des saves
    fscanf(noms_sauvegardes, "%d", &nb);//nbre de niveaux pre enregistres
    if (strlen(mot)<44)
    {
    strcat(mot, ".txt");//save dun fichier texte pour gerer le niveau creer 
    }
    else
    {
        allegro_message("Le nom est trop long!");
        return 1;
    }
    sauvegarde = fopen(mot, "w+");

    fseek(noms_sauvegardes, 0, SEEK_SET);// on change le nbre de niveau deja pre enregistre uniquement par le lvl editor
    fprintf(noms_sauvegardes, "%d ", ++nb);
    fseek(noms_sauvegardes, 0, SEEK_END);
    fprintf(noms_sauvegardes, " %s", mot);
    i=0;
    j=0;
    for (i=0; i<15; i++)
    {
        for(j=0; j<19; j++)
                {
                    fprintf(sauvegarde, "%d ", valeurs[i][j]);// on creer le fichier correspondant au niveau qui vient detre creer 
                }
    }
    fclose(sauvegarde);
    fclose(noms_sauvegardes);
    return 0;
}
コード例 #29
0
void init()
{
 allegro_init();

 set_color_depth(32);
 if(set_gfx_mode(GFX_AUTODETECT_WINDOWED, GFX_W, GFX_H, 0, 0))
  {
   allegro_message("Error: %s.", allegro_error);
   exit(1);
  }

 install_keyboard();
 install_mouse();

 buffer = create_bitmap(SCREEN_W, SCREEN_H);
 zbuffer = create_bitmap_ex(32, SCREEN_W, SCREEN_H);
 texture = load_bitmap("data/wall.bmp", NULL);
 skin = load_bitmap("data/babe_skin.bmp", NULL);
 texture2 = load_bitmap("data/color.bmp", NULL);

 setup_projection(90.0, -1.333, 1.333, -1.0, 1.0, -1.0, 200.0);
 init_renderer(GFX_H);
 bind_color_buffer(buffer);
 bind_zbuffer(zbuffer);
 bind_texture(texture);
}
コード例 #30
0
ファイル: perso.c プロジェクト: dridri19/Projet
t_perso * ajouterPerso(t_listePerso *lp,int x,int y)
{
    int i;
    t_perso *perso;
    int couleur;

    // Liste pleine, on alloue rien et on retourne NULL...
    if (lp->nbperso >= MAXI)
        return NULL;

    // Allouer un acteur initialisé
    couleur=obtention_couleurblindee(lp);

    perso=creerPerso(x,y,couleur);

    // Chercher un emplacement libre
    i=0;
    while (lp->perso[i]!=NULL && i<MAXI)
        i++;

    // Si on a trouvé ...
    // (normalement oui car on a vérifié n<max)
    if (i<MAXI)
    {
        // Accrocher le acteur à l'emplacement trouvé
        lp->perso[i]=perso;
        lp->nbperso++;
    }
    // Sinon c'est qu'il y a un problème de cohérence
    else
        allegro_message("Anomalie gestion ajouterActeur : liste corrompue");

    return perso;
}