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