コード例 #1
0
ファイル: audio.c プロジェクト: dns/CLove
static int l_audio_setVolumeGlobal(lua_State* state){
	double volume = lua_tonumber(state, 1);
	if(volume <= 0.0f)
		volume = 0.0f;
	else if (volume >= 1.0f)
		volume = 1.0f;

	audio_setVolume(volume);
	return 1;
}
コード例 #2
0
ファイル: audio.c プロジェクト: dns/CLove
Obj* c_audio_setGlobalVolume(void* root, Obj** env, Obj** list)
{

	if (length(*list) != 2)
		error("Expected <custom> and an int.");

	Obj* arg = eval(root, env, &(*list)->car);
	float volume = creo_tointeger(root, env, list, 1);

	if(volume <= 0.0f)
		volume = 0.0f;
	else if (volume >= 1.0f)
		volume = 1.0f;

	audio_setVolume(volume);

	return True;
}
コード例 #3
0
ファイル: menustate.c プロジェクト: ratalaika/big-15
/**
 * Initialize the menustate
 * 
 * @return GFraMe error code
 */
static GFraMe_ret ms_init(struct stMenustate *ms) {
    GFraMe_ret rv;
    GFraMe_save sv;
    int tmp, ctrPl1, ctrPl2;
    
    ms->pO = 0;
    ms->pM = 0;
    // Check if there's already a saved game
    rv = GFraMe_save_bind(&sv, SAVEFILE);
    ASSERT_NR(rv == GFraMe_ret_ok);
    // Check if something other than the version is written
    if (sv.size > 50)
        ms->hasSave = 1;
    else
        ms->hasSave = 0;
    GFraMe_save_close(&sv);
    
    // Check the configurations
    rv = GFraMe_save_bind(&sv, CONFFILE);
    GFraMe_assertRet(rv == GFraMe_ret_ok, "Error reading config file", __ret);
    // Try to read both players control mode
    ctrPl1 = -1;
    ctrPl2 = -1;
    rv = GFraMe_save_read_int(&sv, "ctr_pl1", &tmp);
    if (rv == GFraMe_ret_ok)
        ctrPl1 = tmp;
    rv = GFraMe_save_read_int(&sv, "ctr_pl2", &tmp);
    if (rv == GFraMe_ret_ok)
        ctrPl2 = tmp;
    // set the control scheme
    if (ctrPl1 != -1 && ctrPl2 != -1) {
        tmp = ctr_setModeForce(ID_PL1, ctrPl1);
        if (tmp)
            tmp = ctr_setModeForce(ID_PL2, ctrPl2);
        // In case any error happened, set the default
        if (!tmp)
            ctr_setDef();
    }
    else
        ctr_setDef();
    // Set the song volume
    rv = GFraMe_save_read_int(&sv, "music", &tmp);
    if (rv == GFraMe_ret_ok)
        audio_setVolume(tmp);
    else
        audio_setVolume(60);
    // Set the sfx volume
    rv = GFraMe_save_read_int(&sv, "sfx", &tmp);
    if (rv == GFraMe_ret_ok)
        sfx_setVolume(tmp);
    else
        sfx_setVolume(50);
    GFraMe_save_close(&sv);
    
    // Zero some variables
    ms->lastPressedTime = 0;
    ms->firstPress = 0;
    // Set the selected option
    if (ms->hasSave)
        ms->curOpt = 0;
    else
        ms->curOpt = 1;
    // Set text position
    ms->textX = 112;
    ms->textY = 176;
    // Set the dev icon position
    ms->iconX = 35 * 8;
    ms->iconY = 25 * 8;
    // Start the menu
    ms->runMenu = 1;
    // Set the title position
    ms->isTitleSet = 0;
    ms->j1X = 82;
    ms->j1Yf = -32.0f;
    ms->j1Y = -32;
    ms->j2X = 122;
    ms->j2Yf = -40.0f;
    ms->j2Y = -40;
    ms->aX = 154;
    ms->aYf = -48.0f;
    ms->aY = -48;
    ms->tX = 194;
    ms->tYf = -54.0f;
    ms->tY = -54;
    ms->idleTime = 0;
    
    rv = map_init(&ms->pM);
    GFraMe_assertRet(rv == GFraMe_ret_ok, "Failed to load background", __ret);
    rv = map_loadf(ms->pM, "maps/mainmenu.gfm");
    GFraMe_assertRet(rv == GFraMe_ret_ok, "Failed to load background", __ret);
    
    rv = obj_getNew(&ms->pO);
    GFraMe_assertRet(rv == GFraMe_ret_ok, "Failed to load background", __ret);
    obj_setZero(ms->pO);
    obj_setBounds(ms->pO, 8*8, 17*8, 2*8, 2*8);
    obj_setID(ms->pO, ID_HEARTUP);
    obj_setCommonEvent(ms->pO, CE_NONE);
    
    cam_x = 0;
    cam_y = 0;
    cam_setMapDimension(40, 30);
    
    audio_playMenu();
    
    rv = GFraMe_ret_ok;
__ret:
    
    return rv;
}