/* ---------------------------------------------------------------------------- * Play the sample. * max_override_pos: Override the currently playing sound * only if it's already in this position, or beyond. * This is in seconds. 0 means always override. -1 means never override. * loop: Loop the sound? * gain: Volume, 0 - 1. * pan: Panning, 0 - 1 (0.5 is centered). * speed: Playing speed. */ void sample_struct::play( const float max_override_pos, const bool loop, const float gain, const float pan, const float speed ) { if(!sample || !instance) return; if(max_override_pos != 0 && al_get_sample_instance_playing(instance)) { float secs = al_get_sample_instance_position(instance) / (float) 44100; if( (secs < max_override_pos && max_override_pos > 0) || max_override_pos == -1 ) { return; } } al_set_sample_instance_playmode( instance, (loop ? ALLEGRO_PLAYMODE_LOOP : ALLEGRO_PLAYMODE_ONCE) ); al_set_sample_instance_gain(instance, gain); al_set_sample_instance_pan(instance, pan); al_set_sample_instance_speed(instance, speed); al_set_sample_instance_position(instance, 0); al_set_sample_instance_playing( instance, true); }
void Pause_Draw(struct Game* game) { game->gamestate=game->loadstate; game->loadstate=GAMESTATE_PAUSE; DrawGameState(game); game->loadstate=game->gamestate; game->gamestate=GAMESTATE_PAUSE; //al_draw_tinted_bitmap(game->pause.bitmap,al_map_rgba_f(1,1,1,0.75),0,0,0); //al_draw_bitmap(game->pause.bitmap); al_draw_filled_rectangle(0, 0, game->viewportWidth, game->viewportHeight, al_map_rgba_f(0,0,0,0.4)); al_draw_text_with_shadow(game->menu.font_title, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.05, ALLEGRO_ALIGN_CENTRE, "Cadence Throw"); al_draw_text_with_shadow(game->menu.font_subtitle, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.225, ALLEGRO_ALIGN_CENTRE, "Throwing Wifes is Magic"); DrawMenuState(game); // al_draw_filled_rectangle(0, game->viewportHeight*0.8, game->viewportWidth, game->viewportHeight, al_map_rgba_f(0,0,0,0.3)); al_draw_text_with_shadow(game->menu.font, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.82, ALLEGRO_ALIGN_CENTRE, "Your task is to save Spike by throwing your wife."); al_draw_text_with_shadow(game->menu.font, al_map_rgb(255,255,255), game->viewportWidth*0.5, game->viewportHeight*0.9, ALLEGRO_ALIGN_CENTRE, "Adjust throw power with Space button. Be careful!"); if (al_get_sample_instance_position(game->level.music)<100000) al_set_sample_instance_position(game->level.music, 150000); // UGLY AS FUUUUUUUUUUUUCK }
static int allua_sample_instance_set_position(lua_State * L) { ALLUA_sample_instance si = allua_check_sample_instance(L, 1); unsigned long val = luaL_checkint(L, 2); lua_pushboolean(L, al_set_sample_instance_position(si, val)); return 1; }