Beispiel #1
0
//returns a pointer to BITMAP (char *aFilename) and shows
//error message on failure
BITMAP *makeBitmap(char *aFilename)
{
	BITMAP *bitmapPointer;
	if (!(bitmapPointer = load_bitmap(aFilename, NULL)))
	{
      set_gfx_mode(GFX_TEXT, 1024,768,0,0);
		allegro_message("Error! Could not find the file \"%s\"!", aFilename);
		exit(1);
	}
	return(bitmapPointer);
}
Opponent::Opponent(Character character):
	mCharacter(character)
{
	mPositionX = 900;
	mPositionY = 520;

	mBitmap = create_bitmap(32, 32);

	switch (mCharacter)
	{
		case Luigi:
			mSprite = load_bitmap("Data/Luigi.bmp", NULL);
			break;
		case Peach:
			mSprite = load_bitmap("Data/Peach.bmp", NULL);
	}

	floodfill(mBitmap, 0, 0, makecol(0, 0, 0));
	blit(mSprite, mBitmap, 0, 0, 0, 0, 32, 32);
}
Beispiel #3
0
int Validate()
{
  acquire_screen();

  B1 = load_bitmap("images/Validate/Base01.pcx", pal);
  B2 = load_bitmap("images/Validate/Base02.pcx", pal);
  system("mp3blaster sounds/GuacaGuaca.wav&");
  while (!key[KEY_ENTER])
  {
    blit(B1, screen, 0, 0, 0, 0, 1024, 768);
    usleep(400000);
    blit(B2, screen, 0, 0, 0, 0, 1024, 768);
    usleep(400000);
    system("mp3blaster sounds/GuacaGuaca.wav&");
  }

  Register();
  release_screen();  
  return 0;
}
Beispiel #4
0
BITMAP * load_bitmap_check(char *pictureName)
{
	BITMAP *bmp;
	bmp=load_bitmap(pictureName,NULL);
	if (!bmp)
	{
		allegro_message("cant find %s",pictureName);
		exit(EXIT_FAILURE);
	}
	return bmp;
}
Beispiel #5
0
/**
 * Load bitmap (this function is aware of truecolor transparency)
 */
static BITMAP *load_bitmap_alpha(const char *filename, bool keep_alpha)
{
    // Allow any color conversions except when loaded file 
    // contains alpha channel
    int cc = get_color_conversion();
    set_color_conversion((COLORCONV_TOTAL | COLORCONV_KEEP_TRANS) & 
        ~(COLORCONV_32A_TO_8 | COLORCONV_32A_TO_15 | COLORCONV_32A_TO_16 | COLORCONV_32A_TO_24));
    BITMAP *bmp_orig = load_bitmap(filename, NULL);
    set_color_conversion(cc);
    return convert_bitmap_alpha(bmp_orig, keep_alpha);
}
Beispiel #6
0
	bitmap(const std::string& filename) :
		file_name_(filename),
		data_(0),
		length_(0),
		width_(0),
		height_(0),
		row_increment_(0),
		bytes_per_pixel_(0)
	{
		load_bitmap();
	}
int cRingStatusMenu::Load()
{
    FILE *fp;
    char filename[256], s[256];
    int r, g, b, i;

    // free bitmaps, incase already loaded
    FreeAll();

    for(i = 0; i < 2; ++i)
    {
        // player 1
        sprintf(filename, "data/status/%d/info", pstat[i].style);
        fp = fopen(filename, "r+");
        if(fp == NULL) {
            return 1; // error, could not load file
        }

        fscanf(fp, "%s", s);
        fscanf(fp, "%d", &r);
        fscanf(fp, "%d", &g);
        fscanf(fp, "%d", &b);
        fclose(fp);

        pstat[i].color = makecol(r, g, b);

        //
        sprintf(filename, "data/status/%d/health_%d.bmp", pstat[i].style, i);
        pstat[i].hp = load_bitmap(filename, NULL);

        sprintf(filename, "data/status/%d/star.bmp", pstat[i].style);
        pstat[i].star = load_bitmap(filename, NULL);

        pstat[i].name->SetString(pstat[i].fname);

        sprintf(filename, "data/status/%dp.bmp", pstat[i].type);
        pstat[i].player_type = load_bitmap(filename, NULL);
    }

    return 0;
}
Beispiel #8
0
void
load_kid_turn_run (void)
{
  /* bitmaps */
  kid_turn_run_00 = load_bitmap (KID_TURN_RUN_00);
  kid_turn_run_01 = load_bitmap (KID_TURN_RUN_01);
  kid_turn_run_02 = load_bitmap (KID_TURN_RUN_02);
  kid_turn_run_03 = load_bitmap (KID_TURN_RUN_03);
  kid_turn_run_04 = load_bitmap (KID_TURN_RUN_04);
  kid_turn_run_05 = load_bitmap (KID_TURN_RUN_05);
  kid_turn_run_06 = load_bitmap (KID_TURN_RUN_06);
  kid_turn_run_07 = load_bitmap (KID_TURN_RUN_07);
  kid_turn_run_08 = load_bitmap (KID_TURN_RUN_08);

  /* frameset */
  init_kid_turn_run_frameset ();
}
Beispiel #9
0
bool Blotter::load_shapes(const std::string& s)
{
    destroy_all_shapes();

    BITMAP* sheet = load_bitmap(s.c_str(), 0);
    if (!sheet) return false;
    else {
        bool ok = cut_into_list(sheet);
        ::destroy_bitmap(sheet);
        return ok;
    }
}
Beispiel #10
0
int main()
{
	define_exp(exp);
	TRY(exp) {
		do_init();
		launch_resource_process();

		struct bitmap_t * b = load_bitmap("0*XP3:ss_保有背景真アサシン.tlg|FILE:/home/wn/Windows/Fate/image.xp3",
				NULL);
		struct bitmap_array_t * array = split_bitmap(b,
				128, 128, 1);
		if (array->original_bitmap == NULL) {
			free_bitmap(b);
		}
		struct rect_mesh_t * mesh = build_mesh_by_array(array);
		assert(mesh != NULL);

		VERBOSE(SYSTEM, "%dx%d\n", array->nr_w, array->nr_h);
		char name[128];
		for (volatile int j = 0; j < array->nr_h; j++) {
			for (volatile int i = 0; i < array->nr_w; i++) {
				snprintf(name, 128, "/tmp/%dx%d.png", j, i);
				define_exp(exp);
				catch_var(struct io_t *, writer, NULL);
				TRY(exp) {
					set_catched_var(writer, io_open_write("FILE", name));
					bitmap_to_png(&array->tiles[j * array->nr_w + i], writer);
				} FINALLY {
					get_catched_var(writer);
					if (writer != NULL)
						io_close(writer);
				} CATCH(exp) {
					RETHROW(exp);
				}
			}
		}

		print_rect_mesh(mesh);
		destroy_rect_mesh(mesh);

		if (array->original_bitmap != NULL) {
			free_bitmap(array->original_bitmap);
			free_bitmap_array(array);
		}

	} FINALLY {
		shutdown_resource_process();
		do_cleanup();
	} CATCH(exp) {
		
	}
	return 0;
}
Beispiel #11
0
void gameover()
{
    BITMAP *fin = load_bitmap("media/gameover.bmp", NULL);
    if(fin == NULL)
        ERREUR("Echec chargement fin");
    blit(fin, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
    textprintf_centre_ex(screen, font, SCREEN_W/2, SCREEN_H/2, makecol(0, 0, 0), makecol(255, 0, 0), "   Score : %d   ", score);
    while(keypressed())
        readkey();
    rest(2000);
    readkey();
}
Beispiel #12
0
void loadGame()
{
 BITMAP *loadBackground = NULL;
 loadBackground = load_bitmap("Load Background.bmp", NULL); // Load our picture
 BITMAP *loadBuffer = NULL;
 loadBuffer = create_bitmap(1024,768); //Create an empty bitmap.
  
 draw_sprite(loadBuffer, loadBackground, 0, 0);
 blit(loadBuffer, screen, 0,0,0,0,1024,768);//Draw the buffer to the screen
 readkey();
 return;
}
Beispiel #13
0
int advanceCredits(int position, float creditPosition)
{
      
     BITMAP *credits1 = NULL;
     credits1 = load_bitmap("Intro Credits 1.bmp", NULL); // Load our picture
     BITMAP *newBuffer = NULL;
     newBuffer = create_bitmap(1024,768); //Create an empty bitmap.
     BITMAP *newBackground = NULL;
     newBackground = load_bitmap("Intro Background 1.bmp", NULL); // Load our picture
 
     while(!key[KEY_ESC] && creditPosition >= -position)
     {
         draw_sprite(newBuffer, newBackground, 0, 0);
         draw_sprite(newBuffer, credits1, 0, creditPosition);
         blit(newBuffer, screen, 0,0,0,0,1024,768);//Draw the buffer to the screen
         creditPosition -= 0.01*(creditPosition + position + 30);
     }
     readkey();
     clear_keybuf();
     return(creditPosition);
}
bool Bitmap::LoadFromFile(const char *filename)
{
    Destroy();

	BITMAP *al_bmp = load_bitmap(filename, nullptr);
	if (al_bmp)
	{
		_alBitmap = al_bmp;
        _isDataOwner = true;
	}
	return _alBitmap != nullptr;
}
Beispiel #15
0
//	Carregar Imagens.	//
BITMAP *carregaBitmap(BITMAP *bitmap, char endereco[50]) {
	
	if( bitmap = load_bitmap(endereco, NULL) ) {
		return(bitmap);
	}
	else {
		printf("Falha ao tentar acessar \"%s\"\n",endereco);
		allegro_exit();
		exit(-1);
	}
	return;
}
Beispiel #16
0
void gameOptions()
{
 BITMAP *optionsBackground = NULL;
 optionsBackground = load_bitmap("Options Background.bmp", NULL); // Load our picture
 BITMAP *optionsBuffer = NULL;
 optionsBuffer = create_bitmap(1024,768); //Create an empty bitmap.
 
 draw_sprite(optionsBuffer, optionsBackground, 0, 0);
 blit(optionsBuffer, screen, 0,0,0,0,1024,768);//Draw the buffer to the screen
 readkey();
 return;
}
void
init_game(Memory *memory, GameState *game_state, Keys *keys, u64 time_us, u32 argc, char *argv[])
{
    game_state->init = true;

    game_state->single_step = false;
    game_state->sim_ticks_per_s = 5;

    game_state->finish_sim_step_move = false;

    if (argc > 1)
    {
        game_state->filename = argv[1];
    }
    else
    {
        printf("Error: No Maze filename supplied.\n");
        exit(1);
    }

    setup_inputs(keys, &game_state->inputs);

    load_bitmap(&game_state->particles.spark_bitmap, "particles/spark.bmp");
    load_bitmap(&game_state->particles.cross_bitmap, "particles/cross.bmp");
    load_bitmap(&game_state->particles.blob_bitmap,  "particles/blob.bmp");
    load_bitmap(&game_state->particles.smoke_bitmap, "particles/smoke.bmp");
    load_bitmap(&game_state->bitmaps.tile, "tile.bmp");
    load_bitmap(&game_state->bitmaps.font, "font.bmp");

    load_cell_bitmaps(&game_state->cell_bitmaps);

    strcpy(game_state->persistent_str, "Init!");

    init_ui(&game_state->ui);
}
int initialize(){
    allegro_init();
    install_timer();
    install_keyboard();
    set_color_depth(16);
    set_gfx_mode(MODE,WIDTH,HEIGHT,0,0);
    srand(time(NULL));
    buffer=create_bitmap(SCREEN_W,SCREEN_H);
    clear(buffer);
    if(install_sound(DIGI_AUTODETECT,MIDI_AUTODETECT,"")!=0){
        allegro_message("Error initializing sound system");
        return 0;
    }
    welcome=load_bitmap("welcome.bmp",NULL);
     instruction1=load_bitmap("instruction1.bmp",NULL);
     instruction2=load_bitmap("instruction2.bmp",NULL);
      instruction3=load_bitmap("instruction3.bmp",NULL);
       gameoverscreen=load_bitmap("gameover.bmp",NULL);
       if(!welcome || !instruction2 || ! instruction3 || !instruction1 || ! gameoverscreen){
        set_gfx_mode(GFX_TEXT,0,0,0,0);
        allegro_message("WELCOME BMPS MISSING");
        return 0;
       }
    //level1=load_sample("stage1.wav");
    /*if(!level1){
        allegro_message("No sound file");
        return 0;
    }*/
        if(MapLoad("level1.fmp")){
        set_gfx_mode(GFX_TEXT,0,0,0,0);
        allegro_message("Can't find level1.fmp");
        return 0;
    }
    LOCK_FUNCTION(timer1);
    LOCK_VARIABLE(ticks);
    LOCK_VARIABLE(framerate);
    LOCK_VARIABLE(counter);
    install_int(timer1,100);
    return 1;
}
Beispiel #19
0
int main(int argc, char **argv) {
    allegro_init();
    set_color_depth(32);
    set_gfx_mode(GFX_AUTODETECT_WINDOWED, SCRW, SCRH, 0, 0);
    install_keyboard();
    install_mouse();
    install_timer();

    LOCK_VARIABLE(timer);
    LOCK_FUNCTION(timerupdate);
    install_int_ex(timerupdate, BPS_TO_TIMER(TIMER_BPS));

    srand((unsigned)time(NULL));
    set_window_title("Skat");

    LOCK_FUNCTION(close_handler);
    set_close_button_callback(close_handler);

    cards = load_bitmap("images/cards.tga", NULL);
    game.p[0] = &human;
    game.p[1] = &cpu1;
    game.p[2] = &cpu2;
    human.choose_card = human_choose_card;
    cpu1.choose_card = cpu_choose_card;
    cpu2.choose_card = cpu_choose_card;
    human.choose_game = human_choose_game;
    cpu1.choose_game = cpu_choose_game;
    cpu2.choose_game = cpu_choose_game;
    human.reizen = human_reizen;
    cpu1.reizen = cpu_reizen;
    cpu2.reizen = cpu_reizen;
    human.schieben = human_schieben;
    cpu1.schieben = cpu_schieben;
    cpu2.schieben = cpu_schieben;
    human.kontra = human_kontra;
    cpu1.kontra = cpu_kontra;
    cpu2.kontra = cpu_kontra;
    human.name = "Stefan";
    cpu1.name = "Robert";
    cpu2.name = "Thomas";
    human.rtext = cpu1.rtext = cpu2.rtext = NULL;
    human.total_points = 0;
    cpu1.total_points = 0;
    cpu2.total_points = 0;

    enable_hardware_cursor();
    show_mouse(screen);

    buffered_do_dialog(main_dlg, -1);

    destroy_bitmap(cards);
}
Beispiel #20
0
//Constructor
Intro::Intro()
{
	//Load background - exit if it fails
	m_background = load_bitmap("Images/IntroBG.bmp", 0);

	if(!m_background)
	{
		allegro_message("INTRO BACKGROUND BITMAP");
		exit(1);
	}

	m_stateID = STATE_INTRO;
}
Beispiel #21
0
void cAnim::load(int numFrames, string basename, int frameTime) {
	this->curFrame = 0;
	this->tickCounter = 0;
	this->frames = numFrames;
	this->frameTime = frameTime;
	
	ostringstream streamTemp;
	for(int i = 1; i <= numFrames; i++) {
		streamTemp.str("");
		streamTemp << basename << i << ".bmp";
		this->frame[i - 1] = load_bitmap(streamTemp.str().c_str(), NULL);
	}
}
Beispiel #22
0
void Painting::SetParameter(std::string p, std::string v)
{
	if(p == "file")
	{
        file = std::atoi(v.c_str());
        std::string canvasFileName = "saves/game";
        canvasFileName += Itoa(file + 1);
        canvasFileName += ".bmp";
        canvas = load_bitmap(canvasFileName.c_str(), 0);
		return;
	}
	Entity::SetParameter(p, v);
}
Beispiel #23
0
Imagen::Imagen(string fichero)
{
    bitmap = NULL ;
    bitmap = load_bitmap(fichero.c_str(), NULL);
    if ( !bitmap )
    {
        string temp = "Imagen::Imagen(string): No se pudo cargar el fichero: ";
        temp += fichero ;
        throw Excepcion(temp);
    }
    mascara = false ;
    alpha = 255 ;
}
Beispiel #24
0
int main( void )
{
   /* first, set up Allegro and the graphics mode */
   allegro_init(); /* initialize Allegro */
   install_keyboard(); /* install the keyboard for Allegro to use */
   install_sound( DIGI_AUTODETECT, MIDI_AUTODETECT, NULL );
   set_color_depth( 16 ); /* set the color depth to 16-bit */
   set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0 ); /* set graphics mode */
   ball = load_bitmap( "ball.bmp", NULL ); /* load the ball bitmap */
   bar = load_bitmap( "bar.bmp", NULL); /* load the bar bitmap */
   buffer = create_bitmap(SCREEN_W, SCREEN_H);/* create buffer */
   boing = load_sample( "boing.wav" ); /* load the sound file */
   ball_x = SCREEN_W / 2; /* give the ball its initial x-coordinate */
   ball_y = SCREEN_H / 2; /* give the ball its initial y-coordinate */
   barL_y = SCREEN_H / 2; /* give left paddle its initial y-coordinate */
   barR_y = SCREEN_H / 2; /* give right paddle its initial y-coordinate */
   srand( time( NULL ) ); /* seed the random function ... */
   direction = rand() % 4; /* and then make a random initial direction */
   
   while ( !key[KEY_ESC] )/* until the escape key is pressed ... */
   {
      moveBall(); /* move the ball */
      respondToKeyboard(); /* respond to keyboard input */
      /* now, perform double buffering */
      clear_to_color( buffer, makecol( 255, 255, 255 ) );
      blit( ball, buffer, 0, 0, ball_x, ball_y, ball->w, ball->h );
      blit( bar, buffer, 0, 0, 0, barL_y, bar->w, bar->h );
      blit( bar, buffer, 0, 0, 620, barR_y, bar->w, bar->h );
      blit( buffer, screen, 0, 0, 0, 0, buffer->w, buffer->h );    
      clear_bitmap( buffer );
                                            
   } /* end while */
   destroy_bitmap( ball ); /* destroy the ball bitmap */
   destroy_bitmap( bar ); /* destroy the bar bitmap */
   destroy_bitmap( buffer ); /* destroy the buffer bitmap */
   destroy_sample( boing ); /* destroy the boing sound file */
   return 0;
} /* end function main */
Beispiel #25
0
/* append_tile_to_gfx_list: reallocates the list to fit another element
 * the pointer returned may point to another address then the one
 * passed. 
 * NOTE: Bascially, what differs this from append_bmp_to_gfx_list is that this function
 * builds a filename (with path) from the 'name' of a tile. And then simply calls
 * the previoulsy mentioned function. */
GFX_OBJ *append_tile_to_gfx_list(const char *name, GFX_OBJ *gfx_list, size_t *sz)
{
    char filename[LONG_NAME_LN];
    BITMAP *bmp = NULL;
    sprintf(filename, "%s%s%s", WORLD_GFX_DIR, name, GFX_EXT);

    bmp = load_bitmap(filename, NULL);
    if (bmp) {
         gfx_list = append_bmp_to_gfx_list(name, bmp, gfx_list, sz);
         return gfx_list;
    } else {
         return NULL;
    }
}
Beispiel #26
0
int db_image_load_pcx(BITMAP *bmp, const char *filename)
{
	PALETTE palette;


	bmp = load_bitmap(filename, palette);
	if (!bmp) {
		///abort_on_error("image_load_pcx : Could not load pcx from filename");
		return -1;
	}

	return 0;

}	
/*
Nom : bitmap_loader
Entrées : tableau d'images
Sorties :
Date de dernière modification : 14/03
Nature de la dernière modification : création
Version : 1.0
*/
void bitmap_loader(BITMAP* img[BMP_NB])
{
    int i=0;
    char bmp_name[BMP_NB][10];

    for( i = 0;  i < BMP_NB; i++)
    {
        bmp_name[i][0] = '\0';
        sprintf(bmp_name[i], "%d.bmp", i);
        printf("%s\n",bmp_name[i]);
        img[i] = load_bitmap(bmp_name[i],NULL); //les images sont appelés 1,2,3,... pour être facilement initialisée
        if(!img[i]) printf("RIP img\n");
    }
}
Beispiel #28
0
int main( void )
{
    BITMAP *bmp; /* pointer to the bitmap */
    
    allegro_init(); /* initialize Allegro */
    install_keyboard(); /* allow Allegro to recieve keyboard input */
    set_color_depth( 16 ); /* set the color depth to 16-bit */
    set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0 ); /* set graphics mode */
    bmp = load_bitmap( "picture.bmp", NULL ); /* load the bitmap file */
    blit( bmp, screen, 0, 0, 0, 0, bmp->w, bmp->h ); /* draw the bitmap */
    readkey(); /* wait for a keypress */
    destroy_bitmap( bmp ); /* free the memory allocated to bmp */
    return 0;
} /* end function main */
Beispiel #29
0
void show_gripdesign(void)
{
	BITMAP *bmp;
	BITMAP *bmp2;
	int end=0;
	int time=0;
	
	int alpha=255;


	bmp2 = load_bitmap("graphic/menu/logo.pcx",NULL);
	bmp = create_bitmap(480,480);
	
	stretch_sprite(bmp,bmp2,0,0,480,480);
		
	speed_counter = 0;
	

	while(!key[KEY_ESC] && !end)
	{
		
		while(speed_counter>0)
		{
			
			time++;

			if(time<350 && alpha>0)
				alpha-=2;

			if(alpha<0)alpha=0;

			if(time>350)
				alpha+=4;
			
			if(alpha>255)alpha=255;

			if(time>450)end=1;

			speed_counter--;
		}
		
		set_trans_blender(0,0,0,0);
		draw_lit_sprite(virt,bmp,0,0,alpha);
		vsync();
		blit(virt,screen,0,0,80,0,480,480);
	}

	destroy_bitmap(bmp);
	destroy_bitmap(bmp2);
}
Beispiel #30
0
GLuint make_texture(char *path, int flags)
{
 BITMAP *texture = load_bitmap(path, NULL);

 if(!texture)
  {
   allegro_message("Failed loading texture '%s'.", path);
   exit(1);
  }

 int id = allegro_gl_make_texture_ex(flags, texture, GL_RGBA8);
 destroy_bitmap(texture);
 return id;
}