fork download
  1. #include "DxLib.h"
  2. #include<time.h>
  3. #include<math.h>
  4. #include<stdlib.h>
  5.  
  6. #define PI 3.141592654
  7. #define Screen_Weight 1280
  8. #define Screen_Hight 720
  9.  
  10. int WINAPI WinMain(HINSTANCE,HINSTANCE,LPSTR,int)
  11. {
  12. //main
  13.  
  14. ChangeWindowMode(TRUE),DxLib_Init(), SetDrawScreen(DX_SCREEN_BACK);
  15. SetGraphMode(1280, 720, 32);
  16. srand(time(0));
  17.  
  18. //MapChip
  19.  
  20. static const int MapHeight = 20;
  21. static const int MapWidth = 130;
  22. int MapChip[MapHeight][MapWidth];
  23.  
  24. for (int i = 0; i < MapHeight; i++)
  25. {
  26. for (int j = 0; j < MapWidth; j++)
  27. {
  28. MapChip[i][j] = 0;
  29. }
  30. }
  31.  
  32. int Map[3];
  33. LoadDivGraph("画像/MapChip1.png", 3, 3, 1, 64, 64, Map);
  34.  
  35. FILE* fp = NULL;
  36.  
  37. fopen_s(&fp,"Stage1.txt", "r");
  38.  
  39. if (fp == NULL)
  40. {
  41. exit(EXIT_FAILURE);
  42. }
  43.  
  44. char ch;
  45. int h = 0, w = 0;
  46.  
  47. while ((ch = fgetc(fp)) != EOF)
  48. {
  49. if (ch == '\n')
  50. {
  51. h++;
  52. w = 0;
  53. }
  54. else
  55. {
  56. MapChip[h][w] = atoi(&ch);
  57. w++;
  58. }
  59. }
  60.  
  61. fclose(fp);
  62.  
  63.  
  64. int GameMode = 1;
  65.  
  66. int Font00 = CreateFontToHandle("BIZ UDPゴシック", 50, 5, DX_FONTTYPE_NORMAL);
  67. int FontScore = CreateFontToHandle("BIZ UDPゴシック", 20, 4, DX_FONTTYPE_NORMAL);
  68.  
  69. int PlayerX = 100, PlayerY = 300, PlayerMoveX = 0, PlayerMoveY = 0;
  70. int Player[4];
  71. int PlayerFlg = 1;
  72. LoadDivGraph("画像/player.png", 4, 4, 1, 64, 64, Player);
  73.  
  74. ーーーーーその他の初期設定のため省略ーーーーーーーーーーーーーー
  75.  
  76. int GameTime = 0;
  77. int ScroolCnt = 0, ScroolTime = 0;
  78.  
  79. while (ScreenFlip() == 0 && ProcessMessage() == 0 && ClearDrawScreen() == 0)
  80. {
  81. //Updata
  82.  
  83. if (GameMode == 1)
  84. {
  85. DrawStringToHandle(400, 100, "シューティングゲーム", GetColor(255, 255, 255), Font00);
  86. DrawStringToHandle(400, 500, "ゲームスタート -> S", GetColor(255, 255, 255), Font00);
  87.  
  88. if (CheckHitKey(KEY_INPUT_S) == 1)
  89. {
  90. GameMode = 2;
  91. }
  92.  
  93. }
  94. else if (GameMode == 2)
  95. {
  96. if (PlayerFlg == 1)
  97. {
  98. PlayerMoveX = 0;
  99. PlayerMoveY = 0;
  100.  
  101. if (CheckHitKey(KEY_INPUT_D) == 1)
  102. {
  103. PlayerMoveX += 10;
  104.  
  105.  
  106. }
  107.  
  108. if (CheckHitKey(KEY_INPUT_A) == 1)
  109. {
  110. PlayerMoveX -= 10;
  111.  
  112. }
  113.  
  114. if (CheckHitKey(KEY_INPUT_W) == 1)
  115. {
  116. PlayerMoveY -= 5;
  117.  
  118. }
  119.  
  120. if (CheckHitKey(KEY_INPUT_S) == 1)
  121. {
  122. PlayerMoveY += 5;
  123.  
  124. }
  125.  
  126. }
  127.  
  128. ーーーーーーーその他の処理のため省略ーーーーーーーーーーー
  129.  
  130. float PlayerTop = PlayerY - 32.0;
  131. float PlayerBottom = PlayerY + 32.0;
  132. float PlayerRight = PlayerX + 32.0;
  133. float PlayerLeft = PlayerX - 32.0;
  134.  
  135. float NextTop = PlayerTop + PlayerMoveY;
  136. float NextBottom = PlayerBottom + PlayerMoveY;
  137. float NextRight = PlayerRight + PlayerMoveX;
  138. float NextLeft = PlayerLeft + PlayerMoveX;
  139.  
  140. for (int h = 0; h < MapHeight; h++)
  141. {
  142. for (int w = 0; w < MapWidth; w++)
  143. {
  144. if (MapChip[h][w] != 1)
  145. {
  146. continue;
  147. }
  148.  
  149. float MapTop = (64 * h);
  150. float MapBottom = 64 * (h + 1);
  151. float MapRight = 64 * (w + 1) - ScroolTime * 6.4;
  152. float MapLeft = 64 * w - ScroolTime * 6.4;
  153.  
  154.  
  155.  
  156.  
  157. //左<右
  158. if (PlayerRight > MapLeft && PlayerLeft < MapRight)
  159. {
  160. //上
  161. //ブロックがめり込んでいるか確認した後、同じ辺を調べる
  162. if (NextBottom > MapTop && NextTop < MapTop)
  163. {
  164. //mapTopだけだったら半分埋まるから+32する
  165. PlayerY = MapTop - 32;
  166. PlayerMoveY = 0;
  167. }
  168.  
  169. //下
  170. else if (NextTop < MapBottom && NextBottom > MapBottom)
  171. {
  172. PlayerY = MapBottom + 32;
  173. PlayerMoveY = 0;
  174. }
  175. }
  176.  
  177.  
  178. //下<上
  179. else if (PlayerTop < MapBottom && PlayerBottom > MapTop)
  180. {
  181. //左
  182. if (NextRight > MapLeft && NextLeft < MapLeft)
  183. {
  184. PlayerX = MapLeft - 32;
  185. PlayerMoveX = 0;
  186. }
  187.  
  188. //右
  189. else if (NextLeft < MapRight && NextRight > MapRight)
  190. {
  191. PlayerX = MapRight + 32;
  192. PlayerMoveX = 0;
  193. }
  194. }
  195.  
  196. }
  197. }
  198.  
  199. //座標確定させる処理
  200. if (PlayerX + PlayerMoveX > 1280 - 32)
  201. {
  202. PlayerX = 1280 - 32;
  203. }
  204.  
  205. else if (PlayerX + PlayerMoveX< 32)
  206. {
  207. PlayerX = 32;
  208. }
  209. else
  210. {
  211. PlayerX += PlayerMoveX;
  212. }
  213.  
  214. PlayerY += PlayerMoveY;
  215.  
  216.  
  217. if (CheckHitKey(KEY_INPUT_O) == 1)
  218. {
  219. PlayerFlg = 1;
  220. }
  221.  
  222. if (ShotCoolTime > 0)
  223. {
  224. ShotCoolTime--;
  225. }
  226. else
  227. {
  228. ShotCoolTime = 0;
  229. }
  230.  
  231.  
  232.  
  233. //Draw
  234.  
  235.  
  236.  
  237.  
  238. for (int i = 0; i < MapHeight; i++)
  239. {
  240. for (int j = 0; j < MapWidth; j++)
  241. {
  242. /*if (j > MapWidth)
  243.   {
  244.   break;
  245.   }*/
  246.  
  247.  
  248. switch (MapChip[i][j])
  249. {
  250. case 0:
  251.  
  252. DrawGraph((64 * j - (6.4 * ScroolTime)), (64 * i), Map[0], TRUE);
  253. break;
  254.  
  255. case 1:
  256.  
  257. DrawGraph((64 * j - (6.4 * ScroolTime)), (64 * i), Map[1], TRUE);
  258. break;
  259. }
  260.  
  261. }
  262. }
  263.  
  264. ーーーーーその他の描画処理のため省略
  265.  
  266.      if (PlayerFlg == 1)
  267.     {
  268.    DrawRotaGraph(PlayerX, PlayerY, 1.0, PI / 2, Player[0], TRUE);
  269.     }
  270.  
  271. GameTime++;
  272.  
  273. ScroolTime++;
  274.  
  275.  
  276. }
  277.  
  278. else if(GameMode == 3)
  279. {
  280. ーーーーーその他の処理のため省略ーーーーーーーーーー
  281. }
  282. }
  283.  
  284. DxLib_End(); // DXライブラリ終了処理
  285. return 0;
  286.  
  287. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c:1:10: fatal error: DxLib.h: No such file or directory
 #include "DxLib.h"
          ^~~~~~~~~
compilation terminated.
stdout
Standard output is empty