X-Git-Url: https://gitweb.ps.run/npengine/blobdiff_plain/e456e009de8d20dfc3dc743f82dbcbcb194a899c..f7e4fe9f4c198045f54f83ffe379fd7a20d8dd76:/src/main.cpp diff --git a/src/main.cpp b/src/main.cpp index 13778d5..5493148 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -16,19 +16,20 @@ const int WIDTH = 43, HEIGHT = 25; int x = 0, y = 0; bool right = true; +clock_t update_clock = clock(); +double update_time = 40; + bool keys[4] = { false, false, false, false }; bool keys_old[4] = { false, false, false, false }; int jumping = 0; clock_t jump_clock = clock(); -double jump_time1 = 0.01; -double jump_time2 = 0.05; +double jump_time1 = 50; +double jump_time2 = 100; int jump_height = 3; -DWORD wait_time = 50; - - +DWORD wait_time = 10; void press_down(WORD vk) { INPUT ip; @@ -208,33 +209,25 @@ void print_text(int text_x, int text_y, const char *text, int delay) { Sleep(100); } -enum GameState { - GS_START, GS_INTRO1, GS_INTRO2 -}; - -clock_t update_clock = clock(); -double update_time = 30; - void update_play(bool can_jump = true) { - if (get_dur(update_clock) >= update_time) + if (get_dur(update_clock) >= update_time) { update_clock = clock(); - else - return; + + if (keys[0] && + x > 0 && + get_block(x - 1, y) != 'x') + move(-1, 0); + if (keys[1] && + x < WIDTH - 1 && + get_block(x + 1, y) != 'x') + move(+1, 0); + } // bool left = false; // bool right = false; // bool up = false; // bool down = false; - if (keys[0] && - x > 0 && - get_block(x - 1, y) != 'x') - move(-1, 0); - if (keys[1] && - x < WIDTH - 1 && - get_block(x + 1, y) != 'x') - move(+1, 0); - // else if (keys[2] && !keys_old[2] && jumping == 0 && can_jump) { jumping = 1; move(0, -1); @@ -272,10 +265,12 @@ void update_play(bool can_jump = true) { } } -enum GameState game_state = GS_START; -void update_game() { - switch (game_state) { - case GS_START: +int lvl = 0; + +void intro() { + static int progress = 0; + switch (progress) { + case 0: press(VK_DOWN); press(VK_RIGHT); press(VK_RIGHT); @@ -284,17 +279,29 @@ void update_game() { print_text(4, 2, "Move with left/right.", 30); - game_state = GS_INTRO1; + progress++; break; - case GS_INTRO1: + case 1: update_play(false); if (x == 5) { print_text(4, 4, "Jump with up.", 30); - game_state = GS_INTRO2; + print_text(4, 6, "Stand on x.", 30); + progress++; } break; - case GS_INTRO2: + case 2: update_play(); + if (x == 8) { + print_text(4, 8, "Collect ? for ???.", 30); + } + break; + } +} + +void update_game() { + switch (lvl) { + case 0: + intro(); break; } } @@ -369,7 +376,7 @@ int main(int argc, char **argv) { keys_old[2] = keys[2]; keys_old[3] = keys[3]; - WaitForSingleObject( pi.hProcess, 10); + WaitForSingleObject( pi.hProcess, wait_time); SetWindowPos(hwnd, HWND_TOPMOST, 100, 100, 750, 750, SWP_SHOWWINDOW); }