static int l_playsound( lua_State* L ) { rl_sound_t* sound = *(rl_sound_t**)luaL_checkudata( L, 1, "sound" ); rl_sound_stop_all(); rl_sound_play( sound, lua_toboolean( L, 2 ), NULL ); return 0; }
void retro_run( void ) { const rl_config_t* config = rl_get_config(); input_poll_cb(); unsigned width = WIDTH - state.imgdata.width; unsigned height = HEIGHT - state.imgdata.height; for ( unsigned i = 0; i < COUNT; i++ ) { int bounced = 0; smile_t* smile = state.smiles + i; smile->sprite->x += smile->dx; smile->sprite->y += smile->dy; if ( smile->sprite->x < 0 || smile->sprite->x > width ) { smile->dx = -smile->dx; smile->sprite->x += smile->dx; bounced = 1; } if ( smile->sprite->y < 0 || smile->sprite->y > height ) { smile->dy = -smile->dy; smile->sprite->y += smile->dy; bounced = 1; } if ( bounced ) { rl_sound_play( &state.sound, 0, NULL ); } } rl_sprites_blit(); video_cb( (void*)rl_backgrnd_fb( NULL, NULL ), WIDTH, HEIGHT, ( WIDTH + config->backgrnd_margin ) * 2 ); rl_sprites_unblit(); audio_cb( rl_sound_mix(), config->samples_per_frame ); }