本文整理汇总了C++中play_sample函数的典型用法代码示例。如果您正苦于以下问题:C++ play_sample函数的具体用法?C++ play_sample怎么用?C++ play_sample使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了play_sample函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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 );
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例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:;
}
}
示例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
}
}
示例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);
}