void PasPlay::DrawPlayerStatusBar(int Alpha){ // 自機のステータスを表示する int HPBoxTLX = 52; // 表示開始位置 int HPBoxTLY = 555; int HPBoxWidth = ( (float)mUnitAdmin->GetPlayerUnit()->GetHP() / (float)Player::Instance()->GetMaxHP() ) * 131.0f; // 塗りつぶすバーの長さ int HPBoxHeight = 8; // 高さ /*== HPバー ================*/ SetDrawBlendMode(DX_BLENDMODE_ALPHA, Alpha); // 透明度を引数から設定 DrawFillBox(HPBoxTLX, HPBoxTLY, HPBoxTLX + HPBoxWidth, HPBoxTLY + HPBoxHeight, GetColor(20,220,210)); // 塗りつぶし長方形を描画(HP) /*== EPバー ================*/ int EPBoxTLY = HPBoxTLY + HPBoxHeight+2; // 塗り長(EP) DrawFillBox(HPBoxTLX, EPBoxTLY, HPBoxTLX +131, EPBoxTLY + HPBoxHeight, GetColor(215,220,60)); /*== フレーム ================*/ DrawGraph(0,550, GhPlayerStatus, true); // フレーム表示 SetDrawBlendMode(DX_BLENDMODE_NOBLEND, 0); }
void Game::Play(){//ゲーム全体の各処理 int zx, zy,check=0; DX_Init(true, zx, zy,check);//DX初期化 if (check == -1){ return; } int Title_BG = Load_Title_Rand();//背景決め while (1){ //デバッグコマンド //1-タイトル //2-本編 //3-途中経過 //4-ゲーム終了 if (CheckHitKey(KEY_INPUT_1)){ Change_Phase(GAME_TITLE); } if (CheckHitKey(KEY_INPUT_2)){ Change_Phase(GAME_PLAY); } if (CheckHitKey(KEY_INPUT_3)){ Change_Phase(GAME_PAUSE); } if (CheckHitKey(KEY_INPUT_4)){ Change_Phase(GAME_END); } switch (game_phase){ case 1://タイトル ClearDrawScreen();//描画、画面初期化 DrawGraph(0, 0, Title_BG, false);//背景描画 ScreenFlip();//描画、画面切り替え break; case 2://本編 ClearDrawScreen();//描画、画面初期化 Mouse mouse; GetMousePoint(&mouse.x, &mouse.y); //田んぼ DrawFillBox(20, 20, 620, 520, Colors::Brown); //ステータス DrawFillBox(20, 560, 1004, 748, Colors::White); //ボタン if (Mouse_Sq(660, 20, 300, 100, mouse)){ DrawFillBox(660, 20, 960, 120, Colors::Red); } else DrawFillBox(660, 20, 960, 120, Colors::White); if (Mouse_Sq(660, 140, 300, 100, mouse)){ DrawFillBox(660, 140, 960, 240, Colors::Blue); } else DrawFillBox(660, 140, 960, 240, Colors::White); if (Mouse_Sq(660, 260, 300, 100, mouse)){ DrawFillBox(660, 260, 960, 360,Colors::Green); } else DrawFillBox(660, 260, 960, 360, Colors::White); if (Mouse_Sq(660, 380, 300, 100, mouse)){ DrawFillBox(660, 380, 960, 480, Colors::Yellow); } else DrawFillBox(660, 380, 960, 480, Colors::White); ScreenFlip();//描画、画面切り替え break; case 3://途中経過 ClearDrawScreen();//描画、画面初期化 DrawFillBox(zx, zy, zx + 20, zy + 20, 0xff00ff); ScreenFlip();//描画、画面切り替え break; case 4://ゲーム終了 ClearDrawScreen();//描画、画面初期化 DrawFillBox(zx, zy, zx + 20, zy + 20, 0xffff00); ScreenFlip();//描画、画面切り替え break; } } }
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; }
void UIPictCell::onOverWhileCallback(UIView* view) { UIPictCell* cell = static_cast<UIPictCell *>(view); if(!cell->isSelectBorderEnable) { return; } const int borderLineColor = cell->borderColor; const int middleBorderLineColor = cell->borderColor - 0x101010; // 上の横線 DrawLine( cell->relativeFrame.minX(), cell->relativeFrame.minY() + cell->borderWidth / 2, cell->relativeFrame.maxX(), cell->relativeFrame.minY() + cell->borderWidth / 2, borderLineColor, cell->borderWidth); // 左の縦線 DrawLine( cell->relativeFrame.minX() + cell->borderWidth / 2, cell->relativeFrame.minY(), cell->relativeFrame.minX() + cell->borderWidth / 2, cell->relativeFrame.maxY(), borderLineColor, cell->borderWidth); // 下の横線 DrawLine( cell->relativeFrame.minX(), cell->relativeFrame.maxY() - cell->borderWidth / 2, cell->relativeFrame.maxX(), cell->relativeFrame.maxY() - cell->borderWidth / 2, borderLineColor, cell->borderWidth); // 右の縦線 DrawLine( cell->relativeFrame.maxX() - cell->borderWidth / 2, cell->relativeFrame.minY(), cell->relativeFrame.maxX() - cell->borderWidth / 2, cell->relativeFrame.maxY(), borderLineColor, cell->borderWidth); //##------------------------------------------------------ // 左上の線 // 左上のボックス DrawFillBox( cell->relativeFrame.minX(), cell->relativeFrame.minY(), cell->relativeFrame.minX() + 1, cell->relativeFrame.minY() + 1, middleBorderLineColor); DrawLine( cell->relativeFrame.minX() + 1, cell->relativeFrame.minY() + 1, cell->relativeFrame.minX() + cell->borderWidth + 1, cell->relativeFrame.minY() + cell->borderWidth + 1, middleBorderLineColor, sqrt(cell->borderWidth)); // 右下の線 // 右下のボックス DrawFillBox( cell->relativeFrame.maxX() - 2, cell->relativeFrame.maxY() - 2, cell->relativeFrame.maxX(), cell->relativeFrame.maxY(), middleBorderLineColor); DrawLine( cell->relativeFrame.maxX() - cell->borderWidth - 1, cell->relativeFrame.maxY() - cell->borderWidth - 1, cell->relativeFrame.maxX() - 1, cell->relativeFrame.maxY() - 1, middleBorderLineColor, sqrt(cell->borderWidth)); // 左下の線 // 左下のボックス DrawFillBox( cell->relativeFrame.minX(), cell->relativeFrame.maxY() - 2, cell->relativeFrame.minX() + 2, cell->relativeFrame.maxY(), middleBorderLineColor); DrawLine( cell->relativeFrame.minX() + 1, cell->relativeFrame.maxY() - 1, cell->relativeFrame.minX() + cell->borderWidth + 1, cell->relativeFrame.maxY() - cell->borderWidth - 1, middleBorderLineColor, sqrt(cell->borderWidth)); DrawFillBox( cell->relativeFrame.maxX() - 2, cell->relativeFrame.minY() + 2, cell->relativeFrame.maxX(), cell->relativeFrame.minY(), middleBorderLineColor); DrawLine( cell->relativeFrame.maxX() - cell->borderWidth - 1, cell->relativeFrame.minY() + cell->borderWidth + 1, cell->relativeFrame.maxX() - 1, cell->relativeFrame.minY() + 1, middleBorderLineColor, sqrt(cell->borderWidth)); }