コード例 #1
0
ファイル: Main.cpp プロジェクト: resmuell/RetreatDefense
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow ){
	ChangeWindowMode(TRUE);
	gFPS.SetDefaultFPS(60);
	if( DxLib_Init() == -1 ){
		 return -1;	// エラーが起きたら直ちに終了
	}
	ChangeFontType(DX_FONTTYPE_ANTIALIASING_EDGE);
	SetMouseDispFlag(TRUE);
	gameManager.SetStage(gameManager.Load);
	for(;;){ //メインループ
		ClearDrawScreen();
		if(ProcessMessage()==-1 || GameMain()==1){break;} //ゲーム本体を実行
		//FPS描画
		int NowFPS = gFPS.Get();
		int Col = (int)(255 * NowFPS / gFPS.GetDefaultFPS());
		//DrawFormatString(500,450,GetColor(255,Col,Col),"FPS: %d",NowFPS);
		ScreenFlip();
		if((GetJoypadInputState( DX_INPUT_KEY_PAD1 ) & PAD_INPUT_10) !=0){
			GetDateTime( &Date );
			std::stringstream fname;
			fname <<"img" << Date.Year << Date.Mon << Date.Day <<Date.Hour <<Date.Min <<GetNowCount() << ".png";
			SaveDrawScreenToPNG( 0 , 0 , 480 , 480 ,fname.str().c_str()) ;
		}
		gFPS.Fix();
	}

	DxLib_End() ;		// DXライブラリ使用の終了処理

	return 0 ;		// ソフトの終了
}
コード例 #2
0
ファイル: test_draw.cpp プロジェクト: mauvecow/DxPortLib
int main(int argc, char **argv) {
#ifdef DXPORTLIB
    SetUseCharSet(DX_CHARSET_EXT_UTF8);
#endif
    
    SetWindowText(_T("DxPortLib Test App"));
    SetWindowSizeChangeEnableFlag(TRUE);
    
    SetGraphMode(640, 480, 32);
    ChangeWindowMode(TRUE);
    
    if (DxLib_Init() == -1) {
        return -1;
    }
    
    SRand(0);
    InitBounceThings();
    
    int isWindowed = TRUE;
    int wasPressed = 0;
    int timerDelta = 0;
    int timeLast = GetNowCount();
    int screenshotWasPressed = 0;
    int drawScreen = MakeScreen(640, 480, FALSE);
    
    while (ProcessMessage() == 0
#ifndef DX_NON_INPUT
        && CheckHitKey(KEY_INPUT_ESCAPE) == 0
#endif
    ) {
        /* If Alt+Enter is pressed, flip to fullscreen mode. */
        if (CheckHitKey(KEY_INPUT_RETURN)
            && (CheckHitKey(KEY_INPUT_LALT) || CheckHitKey(KEY_INPUT_RALT))
        ) {
            if (wasPressed == 0) {
                isWindowed = 1 - isWindowed;
                ChangeWindowMode(isWindowed);
            }
            wasPressed = 1;
        } else {
            wasPressed = 0;
        }
        
        /* Game logic here */
        MoveBounceThings();
        
        /* Draw logic here */
        SetDrawScreen(drawScreen);
        SetDrawBright(255, 255, 255);
        SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 255);
        DrawFillBox(0, 0, 640, 480, 0xFF000000);
        DrawLineBox(10, 10, 630, 470, 0xFFFFFFFF);
        SetDrawBlendMode(DX_BLENDMODE_ALPHA, 128);
        DrawFillBox(20, 20, 620, 460, GetColor(0x90, 0x80, 0x70));
        
        DrawBounceThings();
        
        if (CheckHitKey(KEY_INPUT_S)) {
            if (screenshotWasPressed == 0) {
                SaveDrawScreenToPNG(0, 0, 640, 480, _T("test_draw_screenshot.png"));
                screenshotWasPressed = 1;
            }
        } else {
            screenshotWasPressed = 0;
        }
        
        SetDrawScreen(DX_SCREEN_BACK);
        DrawGraph(0, 0, drawScreen, FALSE);
        
        ScreenFlip();

        /* Time to next frame automatically... */
        int newTime = GetNowCount();
        timerDelta += newTime - timeLast;
        timeLast = newTime;

        int n = timerDelta;
        if (n > 16) {
            n = 16;
        }
        timerDelta -= n;

        WaitTimer(16 - n);
    }
    
    DxLib_End();
    
    return 0;
}