本文整理汇总了C++中sound_play函数的典型用法代码示例。如果您正苦于以下问题:C++ sound_play函数的具体用法?C++ sound_play怎么用?C++ sound_play使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sound_play函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ui_check_who_won
void ui_check_who_won()
{
char *line, *who_str = NULL;
int who, len;
if (!move_fout)
return;
fprintf (move_fout, "WHO_WON \n");
fflush (move_fout);
line = line_read(move_fin);
if (g_strncasecmp(line, "ACK", 3))
{
// NAK ==> not implemented
ui_gameover = FALSE;
sb_set_score ("");
return;
}
line += 4;
line = g_strstrip(line);
who_str = line;
while(!isspace(*line) && *line) line++;
while(isspace(*line)) line++;
sb_set_score (line);
if (!g_strncasecmp(who_str, "NYET", 4))
{
ui_gameover = FALSE;
return;
}
ui_stopped = TRUE;
ui_gameover = TRUE;
if (opt_logfile)
fprintf(opt_logfile, "RESULT: %s\n", who_str);
if (!state_gui_active)
ui_cleanup();
sb_update ();
if (game_single_player && !ui_cheated && !g_strncasecmp(who_str, "WON", 3))
{
gboolean retval;
retval = prefs_add_highscore (line, sb_get_human_time ());
if (retval)
sound_play (SOUND_HIGHSCORE);
else
sound_play (SOUND_WON);
if (game_levels)
{
GameLevel *next_level = game_levels;
while (next_level->name)
{
if (next_level->game == opt_game)
break;
next_level++;
}
next_level++;
if (next_level->name)
menu_put_level (next_level->name);
}
}
if (game_single_player && !ui_cheated && !g_strncasecmp(who_str, "LOST", 4))
sound_play (SOUND_LOST);
}
示例2: player_equip_item
void player_equip_item(u16 inv_slot)
{
PLAYER_EQUIPPED_ITEM = inv_slot;
//TODO: Do these transfer to Indy?
if(tile_metadata[player_inventory[PLAYER_EQUIPPED_ITEM]] & TILE_LIGHTSABER)
sound_play(0x1F);
else if(tile_metadata[player_inventory[PLAYER_EQUIPPED_ITEM]] & TILE_LIGHT_BLASTER || tile_metadata[player_inventory[PLAYER_EQUIPPED_ITEM]] & TILE_HEAVY_BLASTER)
sound_play(0x20);
else if(tile_metadata[player_inventory[PLAYER_EQUIPPED_ITEM]] & TILE_THE_FORCE)
sound_play(0x34);
}
示例3: player_step
void
player_step(Player *P, int key_left, int key_right, int key_jump)
{
Collision C = {0};
// Left & right.
int dx = 0;
if (key_right) {
dx = +1;
}
if (key_left) {
dx = -1;
}
scene_entity_move_x(&GAME->scene, P->E, dx * 2, &C);
// Jump & fall.
static int PLAYER_JUMP[] = { 5, 4, 3, 2, 2, 1, 1, 1 };
if (key_jump && P->grounded) {
P->jump = 1;
sound_play(&GAME->sound_jump);
}
if (!P->jump) {
P->fall = minimum(P->fall + 1, 16);
if (!scene_entity_move_y(&GAME->scene, P->E, P->fall, &C)) {
if (!P->grounded) {
sound_play(&GAME->sound_land);
P->grounded = 1;
}
P->fall = 2;
} else {
P->grounded = 0;
}
} else {
P->grounded = 0;
P->jump++;
if (P->jump >= array_count(PLAYER_JUMP) ||
scene_entity_move_y(&GAME->scene, P->E, -(PLAYER_JUMP[P->jump - 1] * 2), &C) == false)
{
P->jump = 0;
}
}
// Draw the player.
rect_draw_push(P->E->box, 2, 10);
}
示例4: update
void update(objectmachine_t *obj, player_t **team, int team_size, brick_list_t *brick_list, item_list_t *item_list, object_list_t *object_list)
{
objectdecorator_t *dec = (objectdecorator_t*)obj;
objectdecorator_enemy_t *me = (objectdecorator_enemy_t*)obj;
objectmachine_t *decorated_machine = dec->decorated_machine;
object_t *object = obj->get_object_instance(obj);
int i, score;
score = (int)expression_evaluate(me->score);
/* player x object collision */
for(i=0; i<team_size; i++) {
player_t *player = team[i];
if(actor_pixelperfect_collision(object->actor, player->actor)) {
if(player_is_attacking(player) || player->invincible) {
/* I've been defeated */
player_bounce(player, object->actor);
level_add_to_score(score);
level_create_item(IT_EXPLOSION, v2d_add(object->actor->position, v2d_new(0,-15)));
level_create_animal(object->actor->position);
sound_play( soundfactory_get("destroy") );
object->state = ES_DEAD;
}
else {
/* The player has been hit by me */
player_hit(player, object->actor);
}
}
}
decorated_machine->update(decorated_machine, team, team_size, brick_list, item_list, object_list);
}
示例5: handle_logic
/* misc */
void handle_logic(item_t *item, item_t *other, player_t **team, int team_size, void (*stepin)(item_t*,player_t*), void (*stepout)(item_t*))
{
int i;
int nobody_is_pressing_me = TRUE;
switch_t *me = (switch_t*)item;
actor_t *act = item->actor;
/* step in */
for(i=0; i<team_size; i++) {
player_t *player = team[i];
if(pressed_the_switch(item, player)) {
nobody_is_pressing_me = FALSE;
if(!me->is_pressed) {
stepin(other, player);
sound_play( soundfactory_get("switch") );
actor_change_animation(act, sprite_get_animation("SD_SWITCH", 1));
me->is_pressed = TRUE;
}
}
}
/* step out */
if(nobody_is_pressing_me) {
if(me->is_pressed) {
stepout(other);
actor_change_animation(act, sprite_get_animation("SD_SWITCH", 0));
me->is_pressed = FALSE;
}
}
}
示例6: ui_get_machine_move
int ui_get_machine_move ()
{
byte *move;
if (player_to_play == HUMAN || ui_stopped)
return FALSE;
if (!opt_infile)
{
move = move_fread_ack (move_fin);
if (!move)
{
sb_error ("Couldn't make move\n", TRUE);
ui_stopped = TRUE;
sb_update ();
return FALSE;
}
if (opt_logfile)
move_fwrite (move, opt_logfile);
}
else // file mode
{
//TODO: should communicate the move to the engine
move = move_fread (opt_infile);
if (opt_logfile)
move_fwrite (move, opt_logfile);
}
board_apply_refresh (move, NULL);
if (!game_single_player)
cur_pos.player = (cur_pos.player == WHITE ? BLACK : WHITE);
cur_pos.num_moves ++;
sound_play (SOUND_MACHINE_MOVE);
ui_check_who_won ();
sb_update ();
ui_send_make_move ();
return FALSE;
}
示例7: savesnap
void savesnap()
{
sound_stop();
savesnap(-1);
eat();
sound_play();
}
示例8: VbExBeep
VbError_t VbExBeep(uint32_t msec, uint32_t frequency)
{
int res;
if (frequency) {
res = sound_start(frequency);
} else {
res = sound_stop();
}
if (res > 0) {
// The previous call had an error.
return VBERROR_UNKNOWN;
} else if (res < 0) {
// Non-blocking beeps aren't supported.
if (msec > 0 && sound_play(msec, frequency))
return VBERROR_UNKNOWN;
return VBERROR_NO_BACKGROUND_SOUND;
} else {
// The non-blocking call worked. Delay if requested.
if (msec > 0) {
mdelay(msec);
if (sound_stop())
return VBERROR_UNKNOWN;
}
return VBERROR_SUCCESS;
}
}
示例9: game_trans_start_game
int game_trans_start_game() {
sound_play(START_BEGIN, START_END);
PLAYER_DRIVE_set_modification(mod_disable_motors_and_servos, 3);
player_lives = GAME_LIVES;
LASER_TAG_set_hit_LED(0);
return 0;
}
示例10: gui2_poll
//poll input for gui2
void gui2_poll()
{
static u32 old_joy1 = 0;
u32 new_joy1,joy1 = 0;
//hack to make sure key isnt held down
if(joykeys[config.gui_keys[0]]) joy1 |= INPUT_MENU;
if(joykeys[config.gui_keys[1]]) joy1 |= INPUT_LOADSTATE;
if(joykeys[config.gui_keys[2]]) joy1 |= INPUT_SAVESTATE;
if(joykeys[config.gui_keys[4]]) joy1 |= INPUT_SCREENSHOT;
new_joy1 = joy1 & ~old_joy1;
old_joy1 = joy1;
//end hack
if(new_joy1 & INPUT_MENU) {
//dont let user exit gui if rom is not loaded
if((pce == 0) || (pce->rom == 0))
return;
gui_active ^= 1;
memset(gui_draw_getscreen(),GUI_COLOR_OFFSET,gui_draw_getscreenpitch()*gui_draw_getscreenheight());
if(gui_active == 0)
sound_play();
else {
sound_pause();
video_copyscreen();
}
}
else if(gui_active) return;
else if(new_joy1 & INPUT_LOADSTATE) loadstate();
else if(new_joy1 & INPUT_SAVESTATE) savestate();
#ifdef SCREENSHOTS
else if(new_joy1 & INPUT_SCREENSHOT)screenshot();
#endif
}
示例11: oled_game_over
void oled_game_over(){
oled_clear_screen();
sound_play(GAMEOVER); //Play game over music
char message1[] = "GAME OVER";
//char message2[] = "YOU DIED";
oled_goto_line(3);
oled_changeColumn(2);
oled_print(message1);
_delay_ms(3000);
sound_play(SILENCE); //prevent looping
_delay_ms(1000);
}
示例12: phaser
void phaser(int ship, int x, int y)
{
int bank = weapon_get_bank(ship,x,y);
if (bank < 0)
return;
int id = -1;
int i;
int c = 0;
for (i=0; i<50; i++) {
if (shots_active[i].type == WEAPON_INACTIVE) {
if (id < 0)
id = i;
} else if (shots_active[i].type == WEAPON_PHASER) {
if (shots_active[i].ship == ship && shots_active[i].bank == bank)
c++;
}
}
if (c >= ships[ship].weapons[bank] || id < 0)
return;
sound_play(SND_PHASER);
shots_active[id].type = WEAPON_PHASER;
shots_active[id].ship = ship;
shots_active[id].bank = bank;
shots_active[id].tx = x;
shots_active[id].ty = y;
shots_active[id].ticks = 0;
shots_active[id].pos = 0;
}
示例13: main_poke
void main_poke()
{
sound_stop();
DialogBox(hIn, MAKEINTRESOURCE(IDD_POKE), wnd, pokedlg);
eat();
sound_play();
}
示例14: opensnap
void opensnap()
{
sound_stop();
opensnap(0);
eat();
sound_play();
}
示例15: falling_behavior
/* fireball 떨어질때의 행동 */
void falling_behavior(item_t *fireball, brick_list_t *brick_list)
{
int i, n;
float sqrsize = 2, diff = -2;
actor_t *act = fireball->actor;
brick_t *down;
/* 그에 따른 움직임, 카메라 시점 */
act->speed.x = 0.0f;
act->mirror = (act->speed.y < 0.0f) ? IF_VFLIP : IF_NONE;
actor_move(act, actor_particle_movement(act, level_gravity()));
actor_change_animation(act, sprite_get_animation("SD_FIREBALL", 0));
/* 파괴하기 위한 목표 */
actor_corners(act, sqrsize, diff, brick_list, NULL, NULL, NULL, NULL, &down, NULL, NULL, NULL);
actor_handle_clouds(act, diff, NULL, NULL, NULL, NULL, &down, NULL, NULL, NULL);
if(down) {
/* 지면에 닿을 때의 소리 */
fireball_set_behavior(fireball, disappearing_behavior);
sound_play( soundfactory_get("fire2") );
/* 좀 더 작은 fireball 생성 */
n = 2 + random(3);
for(i=0; i<n; i++) {
item_t *obj = level_create_item(IT_FIREBALL, act->position);
fireball_set_behavior(obj, smallfire_behavior);
obj->actor->speed = v2d_new(((float)i/(float)n)*400.0f-200.0f, -120.0f-random(240.0f));
}
}
}