Guest User

Untitled

a guest
Jun 17th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. #include "DxLib.h"
  2. #include "math.h"
  3.  
  4. int Key[256];
  5.  
  6. int gpUpdateKey() {
  7. char tmpKey[256];
  8. GetHitKeyStateAll(tmpKey);
  9.  
  10. for (int i = 0; i < 256; i++) {
  11. if (tmpKey[i] != 0) {
  12. Key[i]++;
  13. }
  14. else {
  15. Key[i] = 0;
  16. }
  17. }
  18.  
  19. return 0;
  20. }
  21.  
  22. //斜めは0.71,
  23. float m = 5.0;
  24. float move = 5.0;//移動量
  25. #define IP 3.14159265359;
  26. float angle = 0.0;
  27.  
  28. int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
  29. {
  30. ChangeWindowMode(TRUE), DxLib_Init(), SetDrawScreen(DX_SCREEN_BACK);//画面モード
  31.  
  32. float x= 320; float y = 240;
  33. int Handle = LoadGraph("mario.png");
  34.  
  35. while (ScreenFlip() == 0 && ProcessMessage() == 0 && ClearDrawScreen() == 0 && gpUpdateKey() == 0) {
  36.  
  37. if (Key[KEY_INPUT_LEFT] >= 1 || Key[KEY_INPUT_RIGHT] >= 1) {
  38. if (Key[KEY_INPUT_DOWN] >= 1 || Key[KEY_INPUT_UP] >= 1) {
  39. move = 0.71f * m;
  40. }
  41. }
  42. else {
  43. move = 1.0f * m;
  44. }
  45.  
  46. if (Key[KEY_INPUT_RIGHT] >= 1) {
  47. if (Key[KEY_INPUT_A] >= 1) {
  48. angle += 0.01f;
  49. }
  50. else {
  51. x += move;
  52. }
  53. }
  54.  
  55. if (Key[KEY_INPUT_LEFT] >= 1) {
  56. if (Key[KEY_INPUT_A] >= 1) {
  57. angle -= 0.01f;
  58. }
  59. else {
  60. x -= move;
  61. }
  62. }
  63.  
  64. if (Key[KEY_INPUT_UP] >= 1) {
  65. y-= move;
  66. }
  67.  
  68. if (Key[KEY_INPUT_DOWN] >= 1) {
  69. y+=move;
  70. }
  71.  
  72. DrawRotaGraph((int)x,(int)y,1.0,angle,Handle,TRUE);
  73. }
  74.  
  75. DxLib_End(); // DXライブラリ使用の終了処理
  76. return 0; // ソフトの終了
  77. }
  78.  
  79. (x,y) = (r*cos(th), r*sin(th));
  80.  
  81. object.location.x += r*cos(th);
  82. object.location.y += r*sin(th);
Add Comment
Please, Sign In to add comment