コード例 #1
0
// odtwarzanie glosu postaci
void glos (Pion_s *pion, int c, stan_tury stan)
{
	
	int x = rand()% 3;
	int y = rand()% 3 + 3;
	al_stop_samples();
	switch (stan)
	{
	case pods_bicie:
		al_play_sample(pion[c].dzwiek[x], 1.0,0.0,1.0,ALLEGRO_PLAYMODE_ONCE,NULL);
		break;
	case pods_ruch:
		al_play_sample(pion[c].dzwiek[x], 1.0,0.0,1.0,ALLEGRO_PLAYMODE_ONCE,NULL);
		break;
	case czyn_bicie:
		al_play_sample(pion[c].dzwiek[y], 1.0,0.0,1.0,ALLEGRO_PLAYMODE_ONCE,NULL);
		break;
	case czyn_ruch:
		al_play_sample(pion[c].dzwiek[y], 1.0,0.0,1.0,ALLEGRO_PLAYMODE_ONCE,NULL);
		break;
	default:
		break;
	}
	x=0;
	y=0;
}
コード例 #2
0
ファイル: Sound.cpp プロジェクト: chiforimpola/GeneralApps
void Sound :: play(double vol, float speed, bool loop)
{
  if(!loop)
    al_play_sample(audio, vol, 0.0, speed, ALLEGRO_PLAYMODE_ONCE, NULL);
  else
    al_play_sample(audio, vol, 0.0, speed, ALLEGRO_PLAYMODE_LOOP, NULL);
}
コード例 #3
0
ファイル: post_game.c プロジェクト: kad4/snake
char * input(void)
{
    int count=0;
    int i=0;
    char name[15]="";
    al_set_target_bitmap(background);
    al_clear_to_color(al_map_rgb(0,0,0));
    al_draw_text(font,al_map_rgb(100,100,100), 640/2+2, 480/4+2,ALLEGRO_ALIGN_CENTRE, "You Got Highscore Enter your name:");
    al_draw_text(font,al_map_rgb(255,255,255), 640/2, 480/4,ALLEGRO_ALIGN_CENTRE, "You Got Highscore Enter your name:");

    al_register_event_source(event_queue, al_get_keyboard_event_source());
    al_set_target_bitmap(al_get_backbuffer(display));

    while(1)
    {
        ALLEGRO_EVENT ev;
        al_wait_for_event(event_queue,&ev);
        al_clear_to_color(al_map_rgb(0,0,0));
        al_draw_bitmap(background,0,0,0);
        al_draw_text(font,al_map_rgb(255,255,255), 640/2, 480,ALLEGRO_ALIGN_CENTRE, name);;
        al_flip_display();

        if(ev.type==ALLEGRO_EVENT_KEY_DOWN)
        {

            if(ev.keyboard.keycode==ALLEGRO_KEY_ENTER)
            {
                al_play_sample(enter, 1.0, -1.0,1.0,ALLEGRO_PLAYMODE_ONCE,NULL);
                break;
            }

            if(ev.keyboard.keycode==ALLEGRO_KEY_BACKSPACE && i>0)
            {
                al_play_sample(_type, 1.0, -1.0,1.0,ALLEGRO_PLAYMODE_ONCE,NULL);
                i--;
                name[i]=' ';
                name[i+1]='\0';
            }

            if(ev.keyboard.keycode>=ALLEGRO_KEY_A && ev.keyboard.keycode<=ALLEGRO_KEY_Z)
            {
                al_play_sample(_type, 1.0, -1.0,1.0,ALLEGRO_PLAYMODE_ONCE,NULL);
                for(count=0; count<26; count++)
                {
                    if(ev.keyboard.keycode==ALLEGRO_KEY_A+count)
                    {
                        name[i]='A'+count;
                        name[i+1]='\0';
                        i++;
                    }
                }
            }
        }// End of key detection
    } // End of while loop

    level_running=false;
    game_running=false;

    return(name);
}
コード例 #4
0
ファイル: FuncoesUteis.c プロジェクト: AleMenezes/Trabalho-PI
void TocaEfeito(ALLEGRO_SAMPLE *Sample, bool Life)
{
	/* Toca os Efeitos Musicas */
	if (!Life)
		al_play_sample(Sample, 1.0, 0.0, 1.0, ALLEGRO_PLAYMODE_ONCE, NULL );
	else
		al_play_sample(Sample, 2.0, 0.0, 1.0, ALLEGRO_PLAYMODE_ONCE, NULL );
}
コード例 #5
0
void powerup_logic(void)
{
	int i;
	
	for(i = 0; i < GAME_MAX_POWERUPS; i++)
	{
		if(powerup[i].active)
		{
			switch(powerup[i].type)
			{
				case POWERUP_TYPE_SPIRIT:
				{
					powerup[i].var--;
					powerup[i].x += powerup[i].vx;
					powerup[i].y += powerup[i].vy;
					if(powerup[i].var <= 0)
					{
						powerup[i].active = false;
					}
					else
					{
						t3f_move_collision_object_xy(powerup[i].object, powerup[i].x, powerup[i].y);
						if(player.active && t3f_check_object_collision(powerup[i].object, player.object))
						{
							al_play_sample(sample[SAMPLE_POWERUP], 1.0, 0.5, 1.0, ALLEGRO_PLAYMODE_ONCE, NULL);
							score += 10 * multiplier;
							multiplier_tick++;
							if(multiplier_tick >= 10)
							{
								al_play_sample(sample[SAMPLE_MULTIPLIER], 1.0, 0.5, 1.0, ALLEGRO_PLAYMODE_ONCE, NULL);
								multiplier++;
								if(multiplier == 10)
								{
									al_play_sample(sample[SAMPLE_MAX_MULTIPLIER], 1.0, 0.5, 1.0, ALLEGRO_PLAYMODE_ONCE, NULL);
								}
								if(multiplier > 10)
								{
									multiplier = 10;
								}
								multiplier_tick = 0;
							}
							powerup[i].active = 0;
						}
					}
					powerup[i].tick++;
					break;
				}
				case POWERUP_TYPE_UPGRADE:
				{
					break;
				}
			}
		}
	}
}
コード例 #6
0
ファイル: Utils.cpp プロジェクト: Langelihle23/DEMO
/*
* Plays a sound file.
*/
void Tetris::Utils::SoundManager::playSound(Tetris::Utils::SoundManager::SoundTrack sound, ALLEGRO_PLAYMODE mode, float volume) {
	if (sound == GAME_MUSIC) {
		al_play_sample(gameMusic, volume, 0.0, 1.0, mode, &gameMusicId);
	}
	else if (sound == MISSION_IMPOSSIBLE) {
		al_play_sample(missionImpossible, volume, 0.0, 1.0, mode, &missionImpossibleId);
	}
	else if (sound == CRASH) {
		al_play_sample(crash, volume, 0.0, 1.0, mode, &crashId);
	}
}
コード例 #7
0
ファイル: Player.cpp プロジェクト: Cheeseness/FLAT
void Player::takeDamage(float dmg) {
	health -= dmg;
	passingOut = health <= 0;
    int i = rand() % 3;
    if (health >= 0 && loseTimer >= 0) {
        Print("Ouch!");
        al_play_sample(painSounds[i], 1.0f, 0.0f, 1.0f, ALLEGRO_PLAYMODE_ONCE, NULL);
    } else if (!gameOver) {
        al_play_sample(deathSound, 1.0f, 0.0f, 1.0f, ALLEGRO_PLAYMODE_ONCE, NULL);
    }

}
コード例 #8
0
ファイル: sound.c プロジェクト: spaceflounder/sr389
void playSound(const unsigned int index)
{

    /* play sound by index number from library, standard volume */
    al_play_sample(sndLib[index].data, 1.0, 0.0, 1.0, ALLEGRO_PLAYMODE_ONCE, NULL);

}
コード例 #9
0
ファイル: a4_aux.c プロジェクト: sesc4mt/mvcdecoder
/* emulate play_sample() */
void play_sample(ALLEGRO_SAMPLE *spl, int vol, int pan, int freq, int loop)
{
   int playmode = loop ? ALLEGRO_PLAYMODE_LOOP : ALLEGRO_PLAYMODE_ONCE;

   al_play_sample(spl, vol/255.0, (pan - 128)/128.0, freq/1000.0,
		  playmode, NULL);
}
コード例 #10
0
ファイル: audio.cpp プロジェクト: pmprog/0Wave
void Audio::PlaySoundEffect( std::string Filename )
{
	// Only play if Music is set
	if( FRAMEWORK->Settings->GetQuickBooleanValue( "Audio.Sound", true ) )
	{
		al_play_sample( SoundEffectsCache::LoadSFX( Filename ), 1.0f, 0.0f, 1.0f, ALLEGRO_PLAYMODE_ONCE, nullptr );
	}
}
コード例 #11
0
ファイル: ColorSelector.cpp プロジェクト: karjonas/one_color
void ColorSelector::select_color_left()
{
    al_play_sample(sample, 1.0, 0.0,1.0,ALLEGRO_PLAYMODE_ONCE,NULL);
    if (selected_color == 0)
        selected_color = num_colors - 1;
    else
        selected_color--;

}
コード例 #12
0
 void PlayOnce()
 {
     al_play_sample(
         mSound->mInnerSelf,
         1,
         0,
         1,
         ALLEGRO_PLAYMODE_ONCE,
         &mChannel
     );
 }
コード例 #13
0
 void PlayLoop()
 {
     al_play_sample(
         mSound->mInnerSelf,
         1,
         0,
         1,
         ALLEGRO_PLAYMODE_LOOP,
         &mChannel
     );
 }
コード例 #14
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);
        }
    }
}
コード例 #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);
}
コード例 #16
0
ファイル: explosion.c プロジェクト: benlemasurier/asteroids
ANIMATION *
explosion_create(VECTOR *position)
{
  ANIMATION *explosion = animation_new(sprites, 15);

  explosion->slowdown = 2;
  explosion->position->x = position->x - (explosion->width  / 2);
  explosion->position->y = position->y - (explosion->height / 2);

  al_play_sample(sample, VOLUME, 0, 1.0, ALLEGRO_PLAYMODE_ONCE, NULL);

  return explosion;
}
コード例 #17
0
ファイル: AudioManager.cpp プロジェクト: Cheeseness/FLAT
void AudioManager::setAudioCue(ALLEGRO_SAMPLE* newCue)
{
	static bool first = true;
	if (!first)
	{
		al_stop_sample(currentSample);
	}
	else
	{
		first = false;
	}
	al_play_sample(newCue, 0.7f, 0.0f, 1.0f, ALLEGRO_PLAYMODE_LOOP, currentSample);
}
コード例 #18
0
ファイル: musica.c プロジェクト: nahuelaguilar93/TELEFONO
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
}
コード例 #19
0
void Pellet::eat(Snake *snake)
{
  assert(m_exists);
  if (m_eat_sound) al_play_sample(m_eat_sound, 1.3*m_volume, 0.0, snake->get_eat_sound_speed(), ALLEGRO_PLAYMODE_ONCE, NULL);
  snake->grow(m_value);
  if (m_scoreboard)
  {
    m_scoreboard->increment_score_by_one(snake);
    m_scoreboard->draw();
  }
  m_exists = false;
  m_collision_table->remove(m_rectangle->get_x(), m_rectangle->get_y());
  m_spawn_countdown = rand() % m_spawn_countdown_max;
}
コード例 #20
0
ファイル: audio.c プロジェクト: davidgomes/gnumaku
static SCM
play_sample (SCM sample_smob, SCM s_gain, SCM s_pan, SCM s_speed)
{
    Sample *sample = check_sample (sample_smob);
    float gain = scm_to_double (s_gain);
    float pan = scm_to_double (s_pan);
    float speed = scm_to_double (s_speed);

    if (sample->sample) {
        al_play_sample (sample->sample, gain, pan, speed, ALLEGRO_PLAYMODE_ONCE, NULL);
    }

    return SCM_UNSPECIFIED;
}
コード例 #21
0
ファイル: DanmakuX.cpp プロジェクト: chong900208/OSGCC6
void init(int width, int height) {
	danmakux.width = width;
	danmakux.height = height;

	if (!al_init()) al_show_native_message_box(display, "Error", "Error", "Failed to initialize Allegro!", NULL, ALLEGRO_MESSAGEBOX_ERROR);
	
	if (!al_install_keyboard()) al_show_native_message_box(display, "Error", "Error", "Failed to install keyboard!", NULL, ALLEGRO_MESSAGEBOX_ERROR);

	if (!al_install_audio()) al_show_native_message_box(display, "Error", "Error", "Failed to install audio!", NULL, ALLEGRO_MESSAGEBOX_ERROR);
	
	if (!al_reserve_samples(10)) al_show_native_message_box(display, "Error", "Error", "Failed to reserve samples!", NULL, ALLEGRO_MESSAGEBOX_ERROR);

	timer = al_create_timer(1.0 / FPS);
	if (!timer) al_show_native_message_box(display, "Error", "Error", "Failed to create timer!", NULL, ALLEGRO_MESSAGEBOX_ERROR);
	
	al_set_new_display_flags(ALLEGRO_WINDOWED);
	al_set_new_window_position(700, 200);
	display = al_create_display(danmakux.width, danmakux.height);
	if (!display) al_show_native_message_box(display, "Error", "Error", "Failed to create display!", NULL, ALLEGRO_MESSAGEBOX_ERROR);

	event_queue = al_create_event_queue();
	if (!event_queue) al_show_native_message_box(display, "Error", "Error", "Failed to create event queue!", NULL, ALLEGRO_MESSAGEBOX_ERROR);

	al_register_event_source(event_queue, al_get_keyboard_event_source());
	al_register_event_source(event_queue, al_get_timer_event_source(timer));
	al_register_event_source(event_queue, al_get_display_event_source(display));

	redraw = false;
	danmakux.fireBomb = false;
	danmakux.lives = 2;
	danmakux.bombsRemain = 2;
	danmakux.weaponLevel = 1;
	danmakux.done = false;
	danmakux.state_menu = true;
	danmakux.state_paused = false;
	danmakux.state_playing = false;
	danmakux.state_dialog = false;
	danmakux.menuChoice = 0;
	danmakux.currentLevel = 1;
	danmakux.player = &playerset;
	UI = danmakux.resources.get_image("ui.png");

	al_start_timer(timer);
	loadMenu("mainmenu");
	/*danmakux.state_menu = false;
							danmakux.state_playing = true;
							danmakux.state_paused = false;
							loadLevel("level1");*/
	al_play_sample(danmakux.bgm, 1.0, 0.0, 1.0, ALLEGRO_PLAYMODE_LOOP, NULL);
}
コード例 #22
0
ファイル: misc.c プロジェクト: mescam/sokoban
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);
}
コード例 #23
0
void InvestigationScene::onCancel(ModalDialog *sender) {
    
    al_play_sample(clickSound, 1.0, 0.5, 1.0, ALLEGRO_PLAYMODE_ONCE, NULL);
    
    sender->removeFromScene(this);
    inputLocked = false;
    
    if (sender->tag == 4) {
        
        if (crimeWeapon == activePOI->contents) {
            crimeWeapon = NULL;
            crimeWeaponLabel->setText("No weapon");
        }
    }
}
コード例 #24
0
ファイル: sound.c プロジェクト: hjqqq/cvne
struct Sound* loadplay_sound(char* filename, int loop)
{
	struct Sound* sound = malloc(sizeof(struct Sound));
	if(!(sound->data = al_load_sample(filename)))
	{
		free(sound);
		return NULL;
	}
	if(!al_play_sample(sound->data, 1.0, 0.0, 1.0, 
		loop ? ALLEGRO_PLAYMODE_LOOP : ALLEGRO_PLAYMODE_ONCE, &(sound->id)))
	{
		al_destroy_sample(sound->data);
		free(sound);
		return NULL;
	}
	return sound;
}
コード例 #25
0
ファイル: HUD.cpp プロジェクト: LanceJZ/vectorasteroids
void HUD::SetPlayerScore(int AddToScore)
{
	int nextShipStep = 1000 * m_WaveNumber;

	m_PlayerScore += AddToScore;

	if (m_PlayerScore > m_PlayerHighScore)
		m_PlayerHighScore = m_PlayerScore;

	if (m_PlayerScore > m_NextNewShipScore)
	{
		m_PlayerHitsLeft ++;
		m_NextNewShipScore += nextShipStep + m_NextNewShipScore;

		if (m_BonusSound)
			al_play_sample(m_BonusSound, 0.7, 0, 1, ALLEGRO_PLAYMODE_ONCE, NULL);
	}
}
コード例 #26
0
ファイル: Ak47.cpp プロジェクト: hudovisk/Allegro
void Ak47::reload()
{
	if(bullets == magazineSize)
		return;
	if(totalBulletes - (magazineSize - bullets) < 0)
		return;

	if(al_get_time() - lastReload < reloadTime)
		return;

	//tocar som de reload
	al_play_sample(aReloadSound, 0.7, 0, 1,  ALLEGRO_PLAYMODE_ONCE, 0);

	totalBulletes -= magazineSize - bullets;
	bullets = magazineSize;

	lastReload = al_get_time();
}
コード例 #27
0
ファイル: DanmakuX.cpp プロジェクト: chong900208/OSGCC6
void loadLevel(std::string lvl) {
	clearMenu();
	clearPause();
	buildPause();
	danmakux.framesPast = 0;
	if (danmakux.menu.running) closeScript(&danmakux.menu);
	if (danmakux.level.running) closeScript(&danmakux.level);
	std::string filename = "lvl_" + lvl + ".lua";
	loadScript(&danmakux.level, filename);
	regFunction(&danmakux.level, "setBGM", setBGM);
	regFunction(&danmakux.level, "setBG", setBG);
	regFunction(&danmakux.level, "addEnemy", addEnemy);
	regFunction(&danmakux.level, "elapsedTime", timePassed);
	regFunction(&danmakux.level, "win", winLevel);
	runFunction(&danmakux.level, "start");
	al_stop_samples();
	al_play_sample(danmakux.bgm, 1.0, 0.0, 1.0, ALLEGRO_PLAYMODE_LOOP, NULL);
}
コード例 #28
0
ファイル: Player.cpp プロジェクト: Cheeseness/FLAT
void Player::pickup() {
	if(weaponPickup == -1) {
		currentWeaponIndex = -1;
		nextWeaponIndex = -1;
	}

	displayHealthTimer = 3.0f;

	weaponPickup++;
	healthpacks += 3;

    al_play_sample(pickupSound, 0.8f, 0.0f, 1.0f, ALLEGRO_PLAYMODE_ONCE, NULL);


	if(weaponPickup <= 2) {
		switchWeapon(weaponPickup);
	}
}
コード例 #29
0
void phColideShotBall(avatar *shooter, avatar *target, ALLEGRO_SAMPLE *sound)
{
    float distance;
    int i;

    for(i = 0; i<TOTAL_SHOTS; i++)
    {
        distance = sqrt(pow((shooter->shots[i].coordX - target->coordX),2)+(pow((shooter->shots[i].coordY - target->coordY),2)));

        if((distance<=target->radius)&&(shooter->shots[i].enable == 1))
        {
            shooter->shots[i].enable = 0;
            target->life-=10;
            al_play_sample(sound, 1.0, 0.0,1.0,ALLEGRO_PLAYMODE_ONCE,NULL);
            setTimer(&target->timeExplosion.time, 25);
            if(target->life <= 0)
            	shooter->score+=10;
        }
    }
}
コード例 #30
0
ファイル: personagens.hpp プロジェクト: khellwan/naodeu
    void BalaColidida (Projetil bala, Inimigo inim, int &dificuldade, ALLEGRO_SAMPLE *morte_inimigo, int &pontos)
    {
        if (bala.ativo)
        {
            if (inim.ativo)
            {
                if (bala.x > inim.x &&
                            bala.x < (inim.x + inim.borda_x) &&
                            bala.y > (inim.y-10) &&
                            bala.y < (inim.y + inim.borda_y))
                {
                            bala.ativo = false;
                            // mas como inimigo desaparece???
                            inim.ativo = false;
                            al_play_sample(morte_inimigo, 1.0, 0.0, 1.0, ALLEGRO_PLAYMODE_ONCE, NULL);

                            pontos++;
                            dificuldade++;
                }
            }
        }
    }