Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "DxLib.h"
- #include "math.h"
- int Key[256];
- int gpUpdateKey() {
- char tmpKey[256];
- GetHitKeyStateAll(tmpKey);
- for (int i = 0; i < 256; i++) {
- if (tmpKey[i] != 0) {
- Key[i]++;
- }
- else {
- Key[i] = 0;
- }
- }
- return 0;
- }
- //斜めは0.71,
- float m = 5.0;
- float move = 5.0;//移動量
- #define IP 3.14159265359;
- float angle = 0.0;
- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
- {
- ChangeWindowMode(TRUE), DxLib_Init(), SetDrawScreen(DX_SCREEN_BACK);//画面モード
- float x= 320; float y = 240;
- int Handle = LoadGraph("mario.png");
- while (ScreenFlip() == 0 && ProcessMessage() == 0 && ClearDrawScreen() == 0 && gpUpdateKey() == 0) {
- if (Key[KEY_INPUT_LEFT] >= 1 || Key[KEY_INPUT_RIGHT] >= 1) {
- if (Key[KEY_INPUT_DOWN] >= 1 || Key[KEY_INPUT_UP] >= 1) {
- move = 0.71f * m;
- }
- }
- else {
- move = 1.0f * m;
- }
- if (Key[KEY_INPUT_RIGHT] >= 1) {
- if (Key[KEY_INPUT_A] >= 1) {
- angle += 0.01f;
- }
- else {
- x += move;
- }
- }
- if (Key[KEY_INPUT_LEFT] >= 1) {
- if (Key[KEY_INPUT_A] >= 1) {
- angle -= 0.01f;
- }
- else {
- x -= move;
- }
- }
- if (Key[KEY_INPUT_UP] >= 1) {
- y-= move;
- }
- if (Key[KEY_INPUT_DOWN] >= 1) {
- y+=move;
- }
- DrawRotaGraph((int)x,(int)y,1.0,angle,Handle,TRUE);
- }
- DxLib_End(); // DXライブラリ使用の終了処理
- return 0; // ソフトの終了
- }
- (x,y) = (r*cos(th), r*sin(th));
- object.location.x += r*cos(th);
- object.location.y += r*sin(th);
Add Comment
Please, Sign In to add comment