Beispiel #1
0
/**
 * Playstate implementation. Must initialize it, run the loop and clean it up
 */
state playstate(int doLoad) {
    GFraMe_ret rv;
    state ret;
    
    ret = -1;
    rv = ps_init(doLoad);
    GFraMe_assertRet(rv == GFraMe_ret_ok, "Failed to init playstate", __ret);
    
    GFraMe_event_init(_maxUfps, _maxDfps);
    
    _ps_pause = 0;
    _psRunning = 1;
    while (gl_running && _psRunning) {
#ifdef DEBUG
        unsigned int t;
#endif
        
        ps_event();
        timer_update();
        if (_ps_pause) {
            ps_doPause();
            if (_ps_onOptions) {
                options();
                _ps_onOptions = 0;
                _ps_lastPress = 300;
            }
        }
        else {
            if (gv_isZero(SWITCH_MAP))
                ps_update();
            else {
                rv = ps_switchMap();
                GFraMe_assertRet(rv == GFraMe_ret_ok, "Failed to switch maps",
                    __ret);
            }
        }
        ps_draw();
        
#ifdef DEBUG
        t = SDL_GetTicks();
        if (t >= _time) {
            GFraMe_log("t=%04i, U=%03i/%03i D=%03i/%03i", _time - _ltime,
                _updCalls, _maxUfps, _drwCalls, _maxDfps);
            _updCalls = 0;
            _drwCalls = 0;
            _ltime = _time;
            _time = SDL_GetTicks() + 1000;
        }
#endif
    }
    
    if (_timerTilCredits >= 5000)
        ret = CREDITS;
    else
        ret = MENUSTATE;
__ret:
    ps_clean();
    
    return ret;
}
Beispiel #2
0
int main(int argc, char *argv[]) {
	GFraMe_ret rv;
	GFraMe_wndext ext;
	
	ext.atlas = "new-atlas-2";
	ext.atlasWidth = 256;
	ext.atlasHeight = 256;
	ext.flags = 0;
	
	// Init the framework
	rv = GFraMe_init(320, 240, 640, 480, "com.gfmgamecorner",
		"BugSquasher", GFraMe_window_resizable, &ext, 60, 1, 0);
	GFraMe_assertRet(rv == GFraMe_ret_ok, "Failed to init the framework", _exit);
	
#ifndef GFRAME_MOBILE
	setIcon();
#endif
	
	// Init the audio player
	rv = GFraMe_audio_player_init();
	GFraMe_assertRet(rv == GFraMe_ret_ok, "Failed to init the audio", _exit);
	// Load the textures
	rv = global_init();
	GFraMe_assertRet(rv == GFraMe_ret_ok, "Failed to create global stuff", _exit);
	
	GFraMe_audio_player_play_bgm(&gl_song, 0.625);
	
	// TODO clear events (there may be a few frames issued)
	// Run the main loop
	gl_running = 1;
	while (gl_running) {
		ms_loop();
		ps_loop();
		gos_loop();
	}
	
_exit:
#ifdef GFRAME_MOBILE
GFraMe_log("asd");
	GFraMe_log_close();
GFraMe_log("qwe");
#endif
	GFraMe_audio_player_clear();
	global_clear();
	GFraMe_quit();
	return rv;
}