Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save LoadDragon0000000000/8f90147adcd3552e2e6e9bf0bcc88bb6 to your computer and use it in GitHub Desktop.
Save LoadDragon0000000000/8f90147adcd3552e2e6e9bf0bcc88bb6 to your computer and use it in GitHub Desktop.
#include "DxLib.h"
float PlayerX = 0;
float PlayerY = 240;
bool RightKeyON = false;
void SetLeftWall(float x);
int WINAPI WinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ LPSTR, _In_ int) {
// ---ここから設定---
ChangeWindowMode(TRUE), SetMainWindowText("バグりにくい衝突処理"), SetGraphMode(640, 480, 32),
SetDoubleStartValidFlag(TRUE); DxLib_Init(), SetDrawScreen(DX_SCREEN_BACK);
// ---ここまで設定---
// ゲームループ
while (ScreenFlip() == 0 && ProcessMessage() == 0 && ClearDrawScreen() == 0) {
RightKeyON = CheckHitKey(KEY_INPUT_RIGHT);
if (RightKeyON == true) {
++PlayerX;
}
SetLeftWall(320.0f);
DrawCircle(PlayerX, PlayerY, 30, GetColor(255, 0, 0), true);
}
DxLib_End(); return 0;
}
// 左壁の作成
void SetLeftWall(float x) {
if (x - 3.0f <= PlayerX && PlayerX) {
if (x - 0.10f <= PlayerX) {
PlayerX = x - 0.10f;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment