Esempio n. 1
0
bool GameLogic::LoadAssets() {

    Bitmap.Logo = al_load_bitmap("assets/images/daklutz.png");
    Bitmap.Title = al_load_bitmap("assets/images/Bitmap.Title.png");
    if(!Bitmap.Title || !Bitmap.Logo) {
        fprintf(stderr, "Failed to load image files!\n");
        return false;
    }
	if(Debug) { fprintf(stderr, "Bitmaps loaded.\n"); }

	// actually load the font, I loaded the same font at different sizes.
    Font.Small = al_load_font("assets/fonts/Geo-Regular.ttf", 24, 0);
    Font.Medium = al_load_font("assets/fonts/Geo-Regular.ttf", 38, 0);
    Font.Big = al_load_font("assets/fonts/Geo-Regular.ttf", 70, 0);
	if(!Font.Small || !Font.Medium || !Font.Big) {
		fprintf(stderr, "Failed to load fonts!\n");
        return false;
    }

	if (!al_reserve_samples(2)) {
        fprintf(stderr, "Could not reserve samples!\n");
        return false;
    }
    if(Debug) { fprintf(stderr, "Samples reserved.\n"); }

	Sound.HitWall = al_load_sample("assets/sounds/wall_collision.ogg");
    Sound.HitPaddle = al_load_sample("assets/sounds/paddle_collision.ogg");
    Sound.BackgroundMusic = al_load_audio_stream("assets/sounds/Sound.BackgroundMusic-tech.ogg", 4, 2048);
    if (!Sound.HitWall || !Sound.HitPaddle || !Sound.BackgroundMusic) {
        fprintf(stderr, "Failed to load sound files!\n");
        return false;
    }
	if(Debug) { fprintf(stderr, "Sound files loaded.\n"); }

	if(!al_attach_audio_stream_to_mixer(Sound.BackgroundMusic, Mixer) ) {
        fprintf(stderr, "Failed to attach stream to default Mixer!\n");
        return 1;
    }
    if(Debug) { fprintf(stderr, "Stream attached to Mixer.\n"); }

    if(!al_set_mixer_playing(Mixer, true)) {
        fprintf(stderr, "Failed to play Mixer!\n");
    }
    if(Debug) { fprintf(stderr, "Mixer playing.\n"); }

    if(!al_set_audio_stream_playmode(Sound.BackgroundMusic, ALLEGRO_PLAYMODE_LOOP)) {
        fprintf(stderr, "Failed to loop stream!\n");
    }
    if(Debug) { fprintf(stderr, "Stream is set to loop.\n"); }

    if(!al_set_audio_stream_playing(Sound.BackgroundMusic, true)) {
        fprintf(stderr, "Failed to play stream!\n");
    }
    if(Debug) { fprintf(stderr, "Stream playing.\n"); }


	return true;
}
Esempio n. 2
0
AudioManager::AudioManager()
{
    gameState = GAME_STATE_NONE;

    currentSample = new ALLEGRO_SAMPLE_ID();

    normalMusic = al_load_sample("music/normal.ogg");
    combatMusic = al_load_sample("music/combat.ogg");
    dragonMusic = al_load_sample("music/dragon.ogg");

    //ctor
}
Esempio n. 3
0
MainLoop::MainLoop() :
    color_selector(2,400, 80)
{
    state = SPLASH_SCREEN;
    font = al_load_ttf_font("PressStart2P.ttf",72,0 );
    font_splash_big = al_load_ttf_font("PressStart2P.ttf",48,0 );
    font_splash_small = al_load_ttf_font("PressStart2P.ttf",24,0 );
    alpha = 255;
    selected_color = 0;
    done_selecting = false;
    win = al_load_sample( "level_win.wav" );
    alert = al_load_sample( "alert.wav" );
};
Esempio n. 4
0
File: audio.c Progetto: bercik/space
void LoadSamples(Audio* const audio)
{
    al_reserve_samples(10);

    audio->song_sample = al_load_sample("song.ogg");
    audio->song_sample_instance = al_create_sample_instance(audio->song_sample);
    al_set_sample_instance_playmode(audio->song_sample_instance, ALLEGRO_PLAYMODE_LOOP);
    al_attach_sample_instance_to_mixer(audio->song_sample_instance, al_get_default_mixer());

    audio->samples[AT_EXPLOSION] = al_load_sample("explosion.wav");
    audio->samples[AT_RESTART] = al_load_sample("restart.wav");
    audio->samples[AT_TRANSPORT] = al_load_sample("transport.wav");
    audio->samples[AT_WHIZ] = al_load_sample("whiz.wav");
}
Esempio n. 5
0
void SoundManager::LoadSounds(int levelNum)
{
	DestroyAllSounds();
	std::vector<int> soundNums = FileManager::GetInstance().LoadSoundNums(levelNum);
	std::vector<int>::iterator iter;

	for(iter = soundNums.begin(); iter!= soundNums.end(); iter++)
	{
		try
		{
			switch(*iter)
			{
			case -2:
				SoundManager::snd_click = al_load_sample("snd/click.wav");
				if(!snd_click)
					throw "snd_click";
				break;
			case 0:
				SoundManager::snd_shoot = al_load_sample("snd/player/shoot.wav");
				if(!snd_shoot)
					throw "snd_shoot";
				break;
			case 1:
				SoundManager::snd_jump1 = al_load_sample("snd/player/jump1.wav");
				if(!snd_jump1)
					throw "snd_jump1";
				break;
			case 2:
				SoundManager::snd_jump2 = al_load_sample("snd/player/jump2.wav");
				if(!snd_jump2)
					throw "snd_jump2";
				break;
			case 3:
				SoundManager::snd_splat = al_load_sample("snd/player/splat.wav");
				if(!snd_splat)
					throw "snd_splat";
				break;
			}
		}
		catch(char const* error)
		{
			std::stringstream ss;
			ss << "Coudn't open " << error;
			al_show_native_message_box(DisplayManager::GetInstance().GetDisplay(),
				"Error!", "SoundManager", ss.str().c_str(),"Ok", ALLEGRO_MESSAGEBOX_ERROR);
			Exit::ExitProgram(-11);
		}
	}
}
Esempio n. 6
0
ALLEGRO_SAMPLE *ResourceCache::get_sound(std::string file) {
	ALLEGRO_SAMPLE *snd;
	std::string filepath = "sounds/" + file;
	snd = al_load_sample(filepath.c_str());
	if (!snd) return NULL;
	else return snd;
}
Esempio n. 7
0
Music *SoundManager::loadMusic(const char *path)
{
	Music *music = new Music;
	music->sound = new Sound;

	music->vol = 0.0;
	music->instance = NULL;
	music->sound->sample = NULL;

	music->sound->sample = al_load_sample(path);

	if (music->sound->sample)
	{
		music->instance = NULL;
		music->instance = al_create_sample_instance(music->sound->sample);
		music->sound->path = path;
		
		if (music->instance)
		{
			music->sound->id = cur_id;
			cur_id++;
			al_attach_sample_instance_to_mixer(music->instance, al_get_default_mixer());
			streams[music->sound->id] = music;
			return music;
		}
		else printf("Unable to create instance of path: %s\n", path);
	}
	else printf("Unable to load sample at path: %s\n", path);

	delete music->sound;
	delete music;
	return NULL;
}
Esempio n. 8
0
c_monster_character::c_monster_character(t_monster_type type, int square_x, int square_y, long *global_time)
  {
	this->is_dead = false;
	this->path_length = 0;
	this->type = type;
	this->direction = DIRECTION_SOUTH;
	this->current_path_instruction = 0;
	this->waiting = false;
	this->global_time = global_time;
	this->footsteps_gain = 0.2;
	this->playing_animation = ANIMATION_NONE;
	this->playing_sound = false;
	this->sound_skate = NULL;
	this->skate_gain = 0.3;
	this->shadow = al_load_bitmap("resources/shadow.png");

	this->position_x = c_character::square_to_position(square_x,true);
	this->position_y = c_character::square_to_position(square_y,false);

	switch (type)
	  {
	    case MONSTER_GHOST:
		  this->sprite_north = al_load_bitmap("resources/character_ghost_north.png");
		  this->sprite_north_running_1 = this->sprite_north;
		  this->sprite_north_running_2 = this->sprite_north;
		  this->sprite_east = al_load_bitmap("resources/character_ghost_east.png");
		  this->sprite_east_running_1 = this->sprite_east;
		  this->sprite_east_running_2 = this->sprite_east;
		  this->sprite_south = al_load_bitmap("resources/character_ghost_south.png");
		  this->sprite_south_running_1 = this->sprite_south;
		  this->sprite_south_running_2 = this->sprite_south;
		  this->sprite_west = al_load_bitmap("resources/character_ghost_west.png");
		  this->sprite_west_running_1 = this->sprite_west;
		  this->sprite_west_running_2 = this->sprite_west;
		  this->sound_footsteps = NULL;
		  break;

		case MONSTER_TROLL:
		  this->sound_footsteps = al_load_sample("resources/footsteps2.wav");
		  this->sprite_north = al_load_bitmap("resources/character_troll_north.png");
		  this->sprite_north_running_1 = al_load_bitmap("resources/character_troll_north_running_1.png");
		  this->sprite_north_running_2 = al_load_bitmap("resources/character_troll_north_running_2.png");
		  this->sprite_east = al_load_bitmap("resources/character_troll_east.png");
		  this->sprite_east_running_1 = al_load_bitmap("resources/character_troll_east_running_1.png");
		  this->sprite_east_running_2 = al_load_bitmap("resources/character_troll_east_running_2.png");
		  this->sprite_south = al_load_bitmap("resources/character_troll_south.png");
		  this->sprite_south_running_1 = al_load_bitmap("resources/character_troll_south_running_1.png");
		  this->sprite_south_running_2 = al_load_bitmap("resources/character_troll_south_running_2.png");
		  this->sprite_west = al_load_bitmap("resources/character_troll_west.png");
		  this->sprite_west_running_1 = al_load_bitmap("resources/character_troll_west_running_1.png");
		  this->sprite_west_running_2 = al_load_bitmap("resources/character_troll_west_running_2.png");
		  break;
	  }
	
	this->succesfully_loaded = (!this->shadow || !this->sprite_north || !this->sprite_north_running_1 || 
	  !this->sprite_north_running_2 || !this->sprite_east || !this->sprite_east_running_1 || 
	  !this->sprite_east_running_2 || !this->sprite_south || !this->sprite_south_running_1 || 
	  !this->sprite_south_running_2 || !this->sprite_west || !this->sprite_west_running_1 ||
	  !this->sprite_west_running_2 || (this->type != MONSTER_GHOST && !this->sound_footsteps)); 
  }
Esempio n. 9
0
ALLEGRO_SAMPLE* SoundManager::GetSoundFX(std::string Filename)
{
	SoundCache* fc;

	if( !SfxCached.empty() )
	{
		for( std::list<SoundCache*>::iterator i = SfxCached.begin(); i != SfxCached.end(); i++ )
		{
			fc = (*i);
			if( fc->Path->compare( Filename ) == 0 )
			{
				fc->LastAccess = al_get_time();
				return (ALLEGRO_SAMPLE*)fc->Reference;
			}
		}
	}

	fc = (SoundCache*)malloc( sizeof(SoundCache) );
	fc->Path = new std::string(Filename);
	fc->Reference = al_load_sample( Filename.c_str() );
	fc->LastAccess = al_get_time();
	SfxCached.push_front( fc );

	return (ALLEGRO_SAMPLE*)fc->Reference;
}
void mw2_Resources::LoadSound(std::string name, std::string fileName)
{
	mw2_Sound* sound = new mw2_Sound();
	std::string path = mDirectoryPath + fileName;
	sound->mInnerSelf = al_load_sample( path.c_str() );
	mSounds[name] = sound;
}
Esempio n. 11
0
AudioSource* AllegroEngine::createSource(const std::wstring& filename)
{
	std::string tmp;
	tmp.assign(filename.begin(), filename.end());
	ALLEGRO_SAMPLE* sample = al_load_sample(tmp.c_str());
	return new AllegroSource(this, sample);
}
Esempio n. 12
0
ALLEGRO_SAMPLE *Animal::getVoice() {
    if (!voiceSamples[voice]) {
        std::stringstream voiceFilename;
        voiceFilename << "voice" << voice << ".wav";
        voiceSamples[voice] = al_load_sample(voiceFilename.str().c_str());
    }
    return voiceSamples[voice];
}
Esempio n. 13
0
void* Gamestate_Load(struct Game *game, void (*progress)(struct Game*)) {
	struct GamestateResources *data = malloc(sizeof(struct GamestateResources));
	data->timeline = TM_Init(game, "main");
	data->bitmap = al_create_bitmap(game->viewport.width, game->viewport.height);
	data->checkerboard = al_create_bitmap(game->viewport.width, game->viewport.height);
	data->pixelator = al_create_bitmap(game->viewport.width, game->viewport.height);

	al_set_target_bitmap(data->checkerboard);
	al_lock_bitmap(data->checkerboard, ALLEGRO_PIXEL_FORMAT_ANY, ALLEGRO_LOCK_WRITEONLY);
	int x, y;
	for (x = 0; x < al_get_bitmap_width(data->checkerboard); x=x+2) {
		for (y = 0; y < al_get_bitmap_height(data->checkerboard); y=y+2) {
			al_put_pixel(x, y, al_map_rgba(0,0,0,64));
			al_put_pixel(x+1, y, al_map_rgba(0,0,0,0));
			al_put_pixel(x, y+1, al_map_rgba(0,0,0,0));
			al_put_pixel(x+1, y+1, al_map_rgba(0,0,0,0));
		}
	}
	al_unlock_bitmap(data->checkerboard);
	al_set_target_backbuffer(game->display);
	(*progress)(game);

	data->font = al_load_ttf_font(GetDataFilePath(game, "fonts/DejaVuSansMono.ttf"),
	                              (int)(game->viewport.height*0.1666 / 8) * 8 ,0 );
	(*progress)(game);
	data->sample = al_load_sample( GetDataFilePath(game, "dosowisko.flac") );
	data->sound = al_create_sample_instance(data->sample);
	al_attach_sample_instance_to_mixer(data->sound, game->audio.music);
	al_set_sample_instance_playmode(data->sound, ALLEGRO_PLAYMODE_ONCE);
	(*progress)(game);

	data->kbd_sample = al_load_sample( GetDataFilePath(game, "kbd.flac") );
	data->kbd = al_create_sample_instance(data->kbd_sample);
	al_attach_sample_instance_to_mixer(data->kbd, game->audio.fx);
	al_set_sample_instance_playmode(data->kbd, ALLEGRO_PLAYMODE_ONCE);
	(*progress)(game);

	data->key_sample = al_load_sample( GetDataFilePath(game, "key.flac") );
	data->key = al_create_sample_instance(data->key_sample);
	al_attach_sample_instance_to_mixer(data->key, game->audio.fx);
	al_set_sample_instance_playmode(data->key, ALLEGRO_PLAYMODE_ONCE);
	(*progress)(game);

	return data;
}
Esempio n. 14
0
void Audio::Init(){ //// RESERVE SOUNDS, SET MUSIC, INSTANCE

	al_reserve_samples(3); //// CAN PLAY 3 SOUNDS AT ONCE

	//// LOAD IN SOUNDS

	bMusic = al_load_sample("Sounds/background.ogg");
	endGame = al_load_sample("Sounds/endGame.ogg");

	caught = al_load_sample("Sounds/caught_01.ogg");
	respawn = al_load_sample("Sounds/respawn_01.ogg");
	collect = al_load_sample("Sounds/collect_01.ogg");

	//// SET UP INSTANCE
	MusicInstance = al_create_sample_instance(bMusic);
	al_set_sample_instance_playmode(MusicInstance, ALLEGRO_PLAYMODE_LOOP);
	al_set_sample_instance_gain(MusicInstance, 1.0f);
	al_attach_sample_instance_to_mixer(MusicInstance, al_get_default_mixer());
};
Esempio n. 15
0
MediumExplosion::MediumExplosion(float x, float y) : Sprite(x, y, AnimationFilmHolder::Get().GetFilm("medium.explosion"), spritetype_t::EXPLOSION)
{
	ALLEGRO_SAMPLE* explosion = al_load_sample("resources/SM_explosion.ogg");
	animation = new FrameRangeAnimation(0, 5, 0, 0, delay, false, 2);
	animator = new FrameRangeAnimator();
	animator->Start(this, animation);
	al_play_sample(explosion, 1, 0, 1, ALLEGRO_PLAYMODE_ONCE, 0);
	animator->SetOnFinish(OnAnimationFinish, this);
	AnimatorHolder::Register(animator);
	AnimatorHolder::MarkAsRunning(animator);
}
Esempio n. 16
0
void PrimitiveEar::renderFeedback(Object *object, Environment *environment) {
    if (object == environment->getPlayer() && nearestObject) {
        if (nearestObject->getVoiceInterval() < 0.0) {
            nearestObject->resetVoiceInterval();
            if (!sound) {
                sound = al_load_sample("blip.wav");
            }
            al_play_sample(sound, 1.0, 0.0, 1.0, ALLEGRO_PLAYMODE_ONCE, NULL);
        }
    }
}
Esempio n. 17
0
ColorSelector::ColorSelector(int num_colors, int width, int height)
:
    num_colors(num_colors),
    width(width),
    height(height)
{
    selected_color = num_colors/2;
    block_size = height < width/num_colors ? height : width/num_colors; 
    sample = al_load_sample( "data/beep.wav" );

};
Esempio n. 18
0
	SamplePtr Load( const std::string & path )
	{
		SampleMap::iterator iter = m_samples.find( path );
		if ( iter != m_samples.end() )
			return iter->second;

		SamplePtr s( new SSample( path, al_load_sample( path.c_str() ) ), *this );
		if ( s )
			m_samples.insert( std::make_pair( path, s ) );

		return s;
	}
MeteorologistCharacter::MeteorologistCharacter(int rowSet, int columnSet, Container info, ALL* allegro) : Character(rowSet, columnSet, info, allegro) {
	if (adventurerImage = al_load_bitmap_resized("Resources/Players/meteorologistImage.png", allegro)) {
		if (image = al_load_bitmap_resized("Resources/Players/Pawns/MeteorologistPawnImage.png", allegro)) {
			seeStormDeckButton = new Button(allegro->screenWidth / 8, allegro->screenHeight / 2 - 50, "Resources/Players/MeteorologistButton/PeepButtonImage.png", "Resources/Players/MeteorologistButton/PeepButtonImage.png", allegro);	//TODO: cambiar las imagenes! XD
		}
		else { cout << "Failed to load Meteorologist Pawn Image" << endl; }
	}
	else { cout << "Failed to load meteorologistImage.png" << endl; }
	//Sounds
	if (gettingCloseSound = al_load_sample("Resources/Sounds/MustBeGettingClose(Boy).wav")) {}
	else { cout << "Failed to load Must be getting close Sound" << endl; }
}
Esempio n. 20
0
void* Gamestate_Load(struct Game *game, void (*progress)(struct Game*)) {

	struct MenuResources *data = malloc(sizeof(struct MenuResources));

	data->options.fullscreen = game->config.fullscreen;
	data->options.fps = game->config.fps;
	data->options.width = game->config.width;
	data->options.height = game->config.height;
	data->options.resolution = game->config.width / 320;
	if (game->config.height / 180 < data->options.resolution) data->options.resolution = game->config.height / 180;
	(*progress)(game);

	data->bg = al_load_bitmap( GetDataFilePath(game, "bg.png") );
	data->monster = al_load_bitmap( GetDataFilePath(game, "monster.png") );
	data->title = al_load_bitmap( GetDataFilePath(game, "title.png") );
	(*progress)(game);

	data->sample = al_load_sample( GetDataFilePath(game, "monster.flac") );
	data->click_sample = al_load_sample( GetDataFilePath(game, "click.flac") );
	(*progress)(game);

	data->music = al_create_sample_instance(data->sample);
	al_attach_sample_instance_to_mixer(data->music, game->audio.music);
	al_set_sample_instance_playmode(data->music, ALLEGRO_PLAYMODE_LOOP);

	data->click = al_create_sample_instance(data->click_sample);
	al_attach_sample_instance_to_mixer(data->click, game->audio.fx);
	al_set_sample_instance_playmode(data->click, ALLEGRO_PLAYMODE_ONCE);

	if (!data->click_sample){
		fprintf(stderr, "Audio clip sample not loaded!\n" );
		exit(-1);
	}
	(*progress)(game);

	data->font = al_load_ttf_font(GetDataFilePath(game, "fonts/MonkeyIsland.ttf"),game->viewport.height*0.05,0 );

	al_set_target_backbuffer(game->display);
	return data;
}
Esempio n. 21
0
void brisa(void){    
    if(soundtrack){
        al_stop_sample(&id);
        al_destroy_sample(soundtrack);
        soundtrack=NULL;
    }
    soundtrack = al_load_sample("brisa.wav"); // pájaros de motoneta
    if (!soundtrack)
    {
        printf( "Audio clip sample not loaded!\n" );
    }
    al_play_sample(soundtrack, 1.0, 0.0,1.0,ALLEGRO_PLAYMODE_ONCE,&id); // le doy play a la canción
}
Esempio n. 22
0
// sound effects
double create(string fname) {
    // load
    ALLEGRO_SAMPLE *s = al_load_sample(fname.c_str());
    if (s == NULL) {
        cout << "audio clip could not be created for: " << fname << endl;
        return -1;
    }
    // increment id and create. returns audio clip id
    double id = idcount;
    idcount += 1;
    samples.insert( pair<double,ALLEGRO_SAMPLE*>(id, s) );
    return id;
}
Esempio n. 23
0
	bool initialize() {
		std::map<std::string, int> fonts = {
			{ "normal", 20 },
			{ "big", 40 },
			{ "huge", 60 }
		};

		std::map<std::string, std::string> samples = {
			{ "beginning", "assets/sounds/beginning.wav" },
			{ "end", "assets/sounds/end.wav" },
			{ "shot", "assets/sounds/fighter.wav" },
			{ "explosion", "assets/sounds/explosion.wav" },
			{ "enemy_death_1", "assets/sounds/enemy1death.wav" },
			{ "enemy_death_2", "assets/sounds/enemy2death.wav" }
		};

		std::map<std::string, std::string> textures = {
			{ "ship", "assets/images/galaga.png" },
			{ "explosion", "assets/images/explosion.png" },
			{ "enemies", "assets/images/enemies.png" },
			{ "bullet", "assets/images/galaga_bullet.png" },
			{ "powerups", "assets/images/powerups.png" }
		};

		for (std::pair<std::string, int> font : fonts) {
			_fonts[font.first] = al_load_font("assets/fonts/arcade.ttf", font.second, NULL);

			if (_fonts[font.first] == NULL) {
				return false;
			}
		}

		for (std::pair<std::string, std::string> sample : samples) {
			_samples[sample.first] = al_load_sample(sample.second.c_str());

			if (_samples[sample.first] == NULL) {
				return false;
			}
		}

		for (std::pair<std::string, std::string> texture : textures) {
			_textures[texture.first] = al_load_bitmap(texture.second.c_str());

			if (_textures[texture.first] == NULL) {
				return false;
			}
		}

		return true;
	}
Esempio n. 24
0
ClimberCharacter::ClimberCharacter(int rowSet, int columnSet, Container info, ALL* allegro) : Character(rowSet, columnSet, info, allegro) {
	if(adventurerImage = al_load_bitmap_resized("Resources/Players/climberImage.png", allegro)){
		if (image = al_load_bitmap_resized("Resources/Players/Pawns/ClimberPawnImage.png", allegro)) {
			if (selectedImage = al_load_bitmap_resized("Resources/Players/ClimberButton/selectedImage.png", allegro)) {
				if(takeWithMeButton = new Button(allegro->screenWidth / 8, allegro->screenHeight / 2, "Resources/Players/ClimberButton/noMouseOverCheckBoxImage.png", "Resources/Players/ClimberButton/mouseOverCheckBoxImage.png", allegro)) {
					takeWithMe = false;
				} else { cerr << "Failed to load takeWithMeButton" << endl;}
			} else { cerr << "Failed to init selectedImage" << endl;}
		} else { cerr << "Failed to load Climber Pawn Image" << endl; }
	} else { cerr << "Failed to load climberImage.png" << endl; }
	//Sounds
	if (gettingCloseSound = al_load_sample("Resources/Sounds/MustBeGettingClose(Boy).wav")) {}
	else { cerr << "Failed to load Must be getting close Sound" << endl; }
}
Esempio n. 25
0
void load_in_msample(int s, const char* file_name)
{

 if (settings.sound_on == 0)
  return;

 msample [s] = al_load_sample(file_name);

 if (!msample [s])
 {
  fprintf(stdout, "\nCould not load sample file (%s). Sound disabled.", file_name);
  settings.sound_on = 0;
 }

}
Esempio n. 26
0
void inquisition(al_defs* al) {
  al_install_audio();
  al_init_acodec_addon();
  al_reserve_samples(1);
  ALLEGRO_SAMPLE *sample = al_load_sample("res/spanish.wav");
  if(!sample) fprintf(stderr, "nie :< \n");
  al_clear_to_color(al_map_rgb(0,0,0));
  ALLEGRO_BITMAP* bmp = al_load_bitmap("res/troll.jpg");
  al_draw_bitmap(bmp, (al->width-500)/2, (al->height-360)/2, 0);
  al_flip_display();
  al_play_sample(sample, 1.0, 0.0, 1.0, ALLEGRO_PLAYMODE_ONCE, NULL);
  wait_for_key_enter(al);
  al_destroy_bitmap(bmp);
  al_destroy_sample(sample);
}
Esempio n. 27
0
bool SampleResource::load(void)
{
    if (!al_is_audio_installed()) {
        debug_message("Skipped loading sample %s\n", filename.c_str());
        return true;
    }

    sample_data = al_load_sample(filename.c_str());
    if (!sample_data) {
        debug_message("Error loading sample %s\n", filename.c_str());
        return false;
    }

    return true;
}
Esempio n. 28
0
Ak47::Ak47()
	: Weapon(10,1.2,30,30,90)
{
	lastReload = 0;
	lastShoot = 0;

	bullet = Projectile("resource/sprites/bullet2.bmp", 350,18,10);

	sprite = al_load_bitmap("resource/weapons/ak47.bmp");
	if(!sprite)
	{
		std::cout<<"Erro no sprite da Ak47"<<std::endl;
		return;
	}

	width = al_get_bitmap_width(sprite);
	height = al_get_bitmap_height(sprite);

	al_convert_mask_to_alpha(sprite,al_map_rgb(255,0,255));

	aShootSound = al_load_sample("resource/sounds/ak47.wav");
	if(!aShootSound)
	{
		std::cout<<"Erro no audio de shoot"<<std::endl;
		return;
	}

	aReloadSound = al_load_sample("resource/sounds/reload.wav");
	if(!aReloadSound)
	{
		std::cout<<"Erro no audio reload"<<std::endl;
		return;
	}


}
Esempio n. 29
0
Music::Music(string name)
{
    sample = NULL;
    instance = NULL;
    sample = al_load_sample(name.c_str());
    if (!sample)
        return;
    instance = al_create_sample_instance(sample);
    if (!instance)
    {
        al_destroy_sample(sample);
    }
    al_attach_sample_instance_to_mixer(instance, al_get_default_mixer());
    al_set_sample_instance_gain(instance, 1.0);
    al_set_sample_instance_playmode(instance, ALLEGRO_PLAYMODE_LOOP);
}
Esempio n. 30
0
void* Gamestate_Load(struct Game *game, void (*progress)(struct Game*)) {
	struct dosowiskoResources *data = malloc(sizeof(struct dosowiskoResources));
	  data->bitmap = al_load_bitmap( GetDataFilePath(game, "bg.png"));

		data->font = al_load_font(GetDataFilePath(game, "fonts/MonkeyIsland.ttf"),100, ALLEGRO_TTF_MONOCHROME );
	(*progress)(game);

		    data->sample = al_load_sample( GetDataFilePath(game, "end.flac") );

		data->sound = al_create_sample_instance(data->sample);
		al_attach_sample_instance_to_mixer(data->sound, game->audio.fx);
		al_set_sample_instance_playmode(data->sound, ALLEGRO_PLAYMODE_ONCE);
		al_set_sample_instance_gain(data->sound, 1.5);

	return data;
}