• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ play_sample函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中play_sample函数的典型用法代码示例。如果您正苦于以下问题:C++ play_sample函数的具体用法?C++ play_sample怎么用?C++ play_sample使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了play_sample函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: play_sample

//Sounds
void ce_game::playSounds(){

	//Walk sound if not already playing
	if ((key[KEY_A] || key[KEY_D] || key[KEY_LEFT] || key[KEY_RIGHT]) && (player->isWalkingLeft || player->isWalkingRight) && !jumpSound){
		if (!walkSound){
			walkSound = true;
			play_sample(walk,255,128,1000,10000);
		}
	}else{
		walkSound = false;
		stop_sample(walk);
	}

	//Ladder sound if not already playing
	if ((key[KEY_W] || key[KEY_S] || key[KEY_UP] || key[KEY_DOWN]) && player->isClimbing && !jumpSound){
		if (!ladderSound){
			ladderSound = true;
			play_sample(ladder,255,128,1000,10000);
		}
	}else{
		ladderSound = false;
		stop_sample(ladder);
	}

	//Jump sound if not already playing
	if (player->isJumping){
		if (!jumpSound){
			jumpSound = true;
			play_sample(jump,255,128,1000,10000);
		}
	}else{
		jumpSound = false;
		stop_sample(jump);
	}
}
开发者ID:VictorLeach96,项目名称:ChuckieEgg,代码行数:36,代码来源:game.cpp


示例2: Component

PlayerComponent::PlayerComponent() : Component( "PlayerComponent" )
{
  angelCounter = 200;
  xVel = yVel = 0.0;
  gravity = 0.2;
  speed = 2.5;
  angel = false;
  state = "idle";

  startX = 1717.5;
  startY = 732.5;

  windVol = 64.0;
  windPan = 128.0;
  windFreq = 300.0;

  transformCounter = 0;
  flapCounter = 0;
  deathCounter = -1;

  wind2 = load_sample( "data/sfx/wind.wav" );
  wind = load_sample( "data/sfx/wind.wav" );
  die = load_sample( "data/sfx/wind.wav" );
  play_sample( wind, windVol, windPan, windFreq, 1 );
  play_sample( wind2, windVol/1.5, 200, windFreq/2.13, 1 );
}
开发者ID:amarillion,项目名称:TINS-Is-not-speedhack-2010,代码行数:26,代码来源:PlayerComponent.cpp


示例3: sample_random_loose_floor

void
sample_random_loose_floor (int room)
{
  switch (prandom (2)) {
  case 0: play_sample (loose_floor_00_sample, room);
  case 1: play_sample (loose_floor_01_sample, room);
  case 2: play_sample (loose_floor_02_sample, room);
  }
}
开发者ID:jolfzverb,项目名称:mininim,代码行数:9,代码来源:loose-floor.c


示例4: flow

static bool
flow (struct anim *k)
{
  struct coord nc; struct pos np, pm, ptf;

  if (k->oaction != kid_jump)
    k->i = -1, k->misstep = k->hang = false;

  bool hang_front = ((k->f.dir == LEFT) ? k->key.left : k->key.right)
    && ! k->key.up && k->key.shift;

  bool hang_back = ((k->f.dir == LEFT) ? k->key.right : k->key.left)
    && ! k->key.up && k->key.shift;

  int back_dir = (k->f.dir == LEFT) ? RIGHT : LEFT;

  /* hang front */
  survey (_m, pos, &k->f, &nc, &pm, &np);
  survey (_tf, pos, &k->f, &nc, &ptf, &np);
  if (k->i >= 8 && k->i <= 10 && hang_front
      && (is_hangable_pos (&pm, k->f.dir)
          || is_hangable_pos (&ptf, k->f.dir))) {
    if (is_hangable_pos (&pm, k->f.dir)) k->hang_pos = pm;
    else if (is_hangable_pos (&ptf, k->f.dir)) k->hang_pos = ptf;
    pos2room (&k->hang_pos, k->f.c.room, &k->hang_pos);
    k->hang = true;
    play_sample (hang_on_fall_sample, k->f.c.room);
    kid_hang (k);
    return false;
  }

  /* hang back */
  survey (_tf, pos, &k->f, &nc, &ptf, &np);
  if (k->i >= 8 && k->i <= 10
      && hang_back && is_hangable_pos (&ptf, back_dir)) {
    k->hang_pos = ptf;
    pos2room (&k->hang_pos, k->f.c.room, &k->hang_pos);
    k->hang = true;
    play_sample (hang_on_fall_sample, k->f.c.room);
    kid_turn (k);
    return false;
  }

  if (k->i == 17) {
    kid_normal (k);
    return false;
  }

  select_frame (k, kid_jump_frameset, k->i + 1);

  if (k->f.b == kid_stabilize_frameset[0].frame) k->fo.dx = +2;
  if (k->f.b == kid_stabilize_frameset[1].frame) k->fo.dx = +6;
  if (k->f.b == kid_stabilize_frameset[2].frame) k->fo.dx = +4;
  if (k->f.b == kid_stabilize_frameset[3].frame) k->fo.dx = +0;

  return true;
}
开发者ID:jolfzverb,项目名称:mininim,代码行数:57,代码来源:kid-jump.c


示例5: HitZombie

void HitZombie(Zombie** a, int damage)
{
    (*a)->hp -= damage;
    play_sample(zombieHit,fxVol-10,((*a)->position.x/Resolution.x)*255,1000,0);
    if((*a)->hp <= 0)
    {
        play_sample(zombieDead,fxVol+10,((*a)->position.x/Resolution.x)*255,1000,0);
        KillZombie(&(*a), 1);
    }
}
开发者ID:BartoszF,项目名称:ZombieSlasher,代码行数:10,代码来源:zombie.c


示例6: VerifCollision

bool VerifCollision(struct Cobra *snake, struct Comida *comidas, int x, int y, int *xx, int *yy, int tamCobra, int *tipoCol, int *ptsComida, int *tamComida){
		 
		 //Colisão com o corpo
		 for (int i = 0;i < tamCobra;i++){
	   		if ( x >= snake[i].x && x <= snake[i].x+18 && y >= snake[i].y && y <= snake[i].y+18){				 
			   	*xx =  snake[i].x;
			   	*yy = snake[i].y;
			   *tipoCol = 1; 
		    }
		}
		
		//Colisão com obstáculos
			if(x > 740){
				 x=20; 
				 *tipoCol = 2; 
				 x = 20; 
				 y = 20;
	 		 }
			if(x < 20){
				 x=760; 
				 *tipoCol = 2; 
				 x = 20; 
				 y = 20;
	 		 }
			if(y > 540){
				 y=20; 
				 *tipoCol = 2; 
				 x = 20; 
				 y = 20;
 			 }
			if(y < 20){
				 y=560; 
				 *tipoCol = 2; 
				 x = 20; 
				 y = 20;
	 		 }
			
		//Colisão com comidas
		for(int i = 0;i<10;i++){
		    if(comidas[i].visible){
				if(x >= comidas[i].x && x <= comidas[i].x+19 && y >= comidas[i].y && y <= comidas[i].y+19){
					 comidas[i].visible = false;
					 play_sample(snakeBit,255,90,1000,0);  						 
					 play_sample(comidas[i].spDie,255,90,1000,0);  				
					 *tamComida = comidas[i].taman;
					 *ptsComida = comidas[i].ponto;
					 *tipoCol = 3;
				}		
            }
		}
		
		
	return true;	
}
开发者ID:hugodanieleng,项目名称:Snake,代码行数:54,代码来源:main.cpp


示例7: guard_die_spiked

void
guard_die_spiked (struct anim *g)
{
  if (con (&g->p)->fg != SPIKES_FLOOR) {
    guard_die_properly (g);
    return;
  }

  g->oaction = g->action;
  g->action = guard_die_spiked;
  g->f.flip = (g->f.dir == RIGHT) ? ALLEGRO_FLIP_HORIZONTAL : 0;

  if (g->oaction != guard_die_spiked) {
    g->splash = true;
    g->death_reason = SPIKES_DEATH;

    assert (con (&g->p)->fg == SPIKES_FLOOR);
    struct spikes_floor *s = spikes_floor_at_pos (&g->p);
    s->i = 4;
    s->state = 5;
    s->inactive = true;
    s->murdered_anim = g->id;

    if (g->type == SKELETON)
      play_sample (skeleton_sample, NULL, g->id);
    else play_sample (spiked_sample, NULL, g->id);

    struct anim *ke = get_anim_by_id (g->enemy_id);
    if (! ke) ke = get_anim_by_id (g->oenemy_id);
    if (ke && ke->id == current_kid_id
        && ! g->glory_sample
        && g->death_reason != SHADOW_FIGHT_DEATH) {
      play_sample (glory_sample, NULL, ke->id);
      g->glory_sample = true;
    }
    g->oenemy_id = -1;

    if (ke) upgrade_skill (&ke->skill, &g->skill);
  }

  g->current_lives = 0;

  int dy;
  if (g->type == SKELETON) dy = +45;
  else dy = (g->f.dir == LEFT) ? +32 : +31;

  ALLEGRO_BITMAP *bitmap = get_guard_die_spiked_bitmap (g->type);
  place_frame (&g->f, &g->f, bitmap,
               &g->p, (g->f.dir == LEFT) ? +8 : +9, dy);

  g->xf.b = NULL;
}
开发者ID:allisson128,项目名称:mininim,代码行数:52,代码来源:guard-die.c


示例8: play_sample

void ce_player::actorPick(ce_actor *actor){

	//Incriment score and remove actor from screen
	score += actor->points;
	actor->visible = false;

	//Play sound
	if (actor->type == cet_grain){
		play_sample(pick_grain,255,128,1000,0);
	}else if (actor->type == cet_egg){
		play_sample(pick_egg,255,128,1000,0);
	}
}
开发者ID:VictorLeach96,项目名称:ChuckieEgg,代码行数:13,代码来源:ce_player.cpp


示例9: play_sample

// Update
void key_manager::update(){
  // Pressing them keys
  // You haven't won
  if(!switch_flicked){
    // Got a correct letter
    if((key_queue.size() > 0) && (!joystick_enabled && key[key_queue.at(0).getValue()] && keyIsPressed == false) || (joystick_enabled && joy[0].button[key_queue.at(0).getValue()].b && buttonIsPressed == false)){
      // Nice sound
      play_sample( sounds[1],255,125,1000,0);
      key_queue.erase( key_queue.begin());

      // Add key to queue
      if( joystick_enabled){
        key_data newKey(random(0,3));
        key_queue.push_back(newKey);
      }
      else{
        key_data newKey(random(KEY_LEFT, KEY_DOWN));
        key_queue.push_back(newKey);
      }

      // Increase speed
      if( stair::scrollSpeed < stair::maxScrollSpeed)
        stair::scrollSpeed += 0.8;
    }
    else if( (keyDown() && keyIsPressed == false) || (buttonDown() && buttonIsPressed == false)){
      if(stair::scrollSpeed > 0)
        stair::scrollSpeed /= 4;
      play_sample(sounds[0],255,125,1000,0);
    }
  }
  // Stop
  else{
    stair::scrollSpeed = 0;
  }

  // Prevents held keys
  if(!joystick_enabled){
    keyIsPressed = keyDown();
  }
  if(joystick_enabled){
    buttonIsPressed = buttonDown();
  }

  // Slow stairs down
  if( stair::scrollSpeed > 0.01)
    stair::scrollSpeed -= 0.02;
  else{
    stair::scrollSpeed = 0;
  }
}
开发者ID:ADSgames,项目名称:JimsAlienAdventure,代码行数:51,代码来源:key_manager.cpp


示例10: physics_out

static void
physics_out (struct anim *k)
{
  /* depressible floors */
  if (k->i == 2) update_depressible_floor (k, -7, -13);
  else if (k->i == 5) update_depressible_floor (k, -5, -30);
  else if (k->i == 6) update_depressible_floor (k, -4, -11);
  else keep_depressible_floor (k);

  /* sound */
  if (k->oaction == kid_run_jump)
    play_sample (step_sample, k->f.c.room);
  if (k->i == 2 || k->i == 6)
    play_sample (step_sample, k->f.c.room);
}
开发者ID:jolfzverb,项目名称:mininim,代码行数:15,代码来源:kid-run.c


示例11: stop_sample

void ce_game::end_game(){
	isPlaying = false;

	//Stop sounds
	stop_sample(walk);
	stop_sample(jump);
	stop_sample(ladder);

	//Play ending sound
	if (hasWon){
		play_sample(win,255,128,1000,0);
	}else{
		play_sample(death,255,128,1000,0);
	}
}
开发者ID:VictorLeach96,项目名称:ChuckieEgg,代码行数:15,代码来源:game.cpp


示例12: tur_do_laser

static inline void tur_do_laser(game_data_t *gd, turret_t *turret)
{
	
	/* shoot something? */
	turret->laser_fire = 0;
	if (turret->target_monster != NULL) {

		if ((fixtoi(turret->angle) == fixtoi(turret->desired_angle)) && tur_target_within_range(turret, (int)turret->target_monster->x + 16, (int)turret->target_monster->y + 16)) {
			if (tur_target_within_sight(turret, (int)turret->target_monster->x + 16, (int)turret->target_monster->y + 16) == 1) {
				if (turret->fire_reset_count == 0) {
					turret->fire_reset_count = 1;
					turret->laser_fire = 1;
					
					stop_sample(gd->samples->gun_laser);
					play_sample(gd->samples->gun_laser, 255, 128, 1000, 0);
					
					/* register damage */
					monster_register_hit(turret->target_monster, 0.5);
				}
			}
		}

	}
	
	if (turret->fire_reset_count > 0)
		turret->fire_reset_count--;
		

	tur_rotate(turret);
	tur_target(turret);

}
开发者ID:tomrf,项目名称:turretz,代码行数:32,代码来源:turret.c


示例13: move_bullets

void move_bullets(void)
{
   BULLET *bullet = bullet_list;
   while (bullet) {
      bullet->y -= BULLET_SPEED;

      /* if the bullet is at the top of the screen, delete it */
      if (bullet->y < 8) {
         bullet = delete_bullet(bullet);
         goto bullet_updated;
      }
      else {

         /* shot an asteroid? */
         if (asteroid_collision(bullet->x, bullet->y, 20)) {
            score += 10;
            play_sample(data[BOOM_SPL].dat, 255, PAN(bullet->x), 1000, FALSE);
            /* delete the bullet that killed the alien */
            bullet = delete_bullet(bullet);
            goto bullet_updated;
         }
      }

      bullet = bullet->next;

      bullet_updated:;
   }
}
开发者ID:AntonLanghoff,项目名称:whitecatlib,代码行数:28,代码来源:bullet.c


示例14: eof_mix_play_note

void eof_mix_play_note(int note)
{
	if((note < EOF_MAX_VOCAL_TONES) && eof_sound_note[note])
	{
		(void) play_sample(eof_sound_note[note], 255.0 * (eof_tone_volume / 100.0), 127, 1000 + eof_audio_fine_tune, 0);	//Play the tone at the user specified cue volume
	}
}
开发者ID:cincodenada,项目名称:editor-on-fire,代码行数:7,代码来源:mix.c


示例15: makeSlider

int makeSlider(slider_t *theSlider)
{
  SAMPLE *slideNoise = makeSample("Menu_Sounds/SliderNoise.wav");
	BITMAP *bar = makeBitmap("Menu_Images/Slider.bmp");

	if (mouse_b && menu_mouseIsOverSlider(theSlider))
	{
			theSlider->position += (mouse_x - theSlider->position)/ 4;
            stop_sample(slideNoise);
            play_sample(slideNoise, 155, 0, 1000, 0);
	}
	draw_sprite(menuBuffer, bar, theSlider->position - 10, theSlider->top + 5);

    theSlider->current = (int)(((theSlider->position - theSlider->left) * theSlider->values)/theSlider->width) + 1;

    if (theSlider->current > theSlider->values)
    {
       theSlider->current = theSlider->values;
    }
    else if (theSlider->current < 1)
    {
       theSlider->current = 1;
    }
	return (theSlider->current);
}
开发者ID:ChrisCooper,项目名称:SPQR,代码行数:25,代码来源:main.c


示例16: GetX

void Basic_char::CollideWithBubble( Bubble * bubble, int scrnwdth, int scrnhght, DATAFILE * pop ) // CHECK FOR COLLISION WITH THE SMALL BUBBLE
{

    if( alive )
    {

    int distance = 0;

    int margin_x = bubble -> GetX() - x;
    int margin_y = bubble -> GetY() - y;

	// THE MARGIN SHOULD BE POSITIVE
    if( margin_x < 0 )
    margin_x *= -1;
    if( margin_y < 0 )
    margin_y *= -1;

    distance = sqrt( pow( margin_x, 2 ) + pow( margin_y, 2 ) ); // THE DISTANCE BETWEEN THE CENTRES OF THE PLAYER AND THE BUBBLE 

	// IF THE DISTANCE BETWEEN THEIR CENTRES IS SMALLER THAN THE SUM OF THEIR RADII THERE IS A COLLISION
    if( distance < 16 + 32 + bubbles_collected*10 )
    {
        bubble -> Respawn( scrnwdth, scrnhght );
        bubbles_collected++;
        play_sample( (SAMPLE*)pop[0].dat, 255, 128, 1000, 0 );
    }

    }

}
开发者ID:BozhidarHrusanov,项目名称:Small_projects,代码行数:30,代码来源:basic_char.cpp


示例17: tur_do_gun

static inline void tur_do_gun(game_data_t *gd, turret_t *turret)
{
	
	/* shoot something? */
	if (turret->target_monster != NULL) {
		if ((fixtoi(turret->angle) == fixtoi(turret->desired_angle)) && tur_target_within_range(turret, (int)turret->target_monster->x + 16, (int)turret->target_monster->y + 16)) {
			if (tur_target_within_sight(turret, (int)turret->target_monster->x + 16, (int)turret->target_monster->y + 16) == 1) {
				if (turret->fire_reset_count == 0) {
					turret->fire_reset_count = 100 / turret->fire_rate;
					bullet_add_bullet(turret, turret->target_monster, tur_get_distance(turret, (int)turret->target_monster->x + 16, (int)turret->target_monster->y + 16));	
					
					play_sample(gd->samples->gun_gun, 180, 128, 1000, 0);
					
				}
			}
		}
	}
	
	if (turret->fire_reset_count > 0)
		turret->fire_reset_count--;
		
	tur_rotate(turret);
	tur_target(turret);
				
}
开发者ID:tomrf,项目名称:turretz,代码行数:25,代码来源:turret.c


示例18: play_sample

int MYWAVE::play() {
    voice = play_sample(wave, vol, panning, 1000, repeat);

    _playing = true;

    return 1;
}
开发者ID:CisBetter,项目名称:ags,代码行数:7,代码来源:clip_mywave.cpp


示例19: update_mouse_hover

void update_mouse_hover(GUI *G)
{
	if(last_hover != G && G != NULL)
	{
		play_sample(highlight_sound, config[CFG_SFX_VOLUME], 128, 1000, 0);
	}
	last_hover = G;

	if(!info_label)
		return;
	if(!G)
		strcpy(info_label->text, "Membrane Massacre v2.0  Copyright (c) 2006-2007");
	else if(!strcmp(G->text,"Resume Game"))
		strcpy(info_label->text, "Continue your journey onward!");
	else if(!strcmp(G->text,"New Game"))
		strcpy(info_label->text, "Begin a new game in 'story' mode");
	else if(!strcmp(G->text,"Survival Mode"))
		strcpy(info_label->text, "Survive against hordes of cells to gain new ships and more..");
	else if(!strcmp(G->text,"Game Options"))
		strcpy(info_label->text, "Configure controls, graphics settings, and difficulty");
	else if(!strcmp(G->text,"Credits"))
		strcpy(info_label->text, "The fine folks who made Membrane Massacre possible");
	else if(!strcmp(G->text,"Exit"))
		strcpy(info_label->text, "Don't even THINK about it!");
}
开发者ID:noffle,项目名称:MembraneMassacre,代码行数:25,代码来源:menu.cpp


示例20: loser

void loser(){

	SAMPLE *som;
   	som = load_sample("loser.wav");
   	play_sample(som, 255, 128, 1000, FALSE);

}
开发者ID:emersonsbarros,项目名称:espaco-x,代码行数:7,代码来源:Game1.c



注:本文中的play_sample函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ play_sound函数代码示例发布时间:2022-05-30
下一篇:
C++ play_music函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap