Sleep(100);\r
}\r
\r
-void update_play(bool can_jump = true) {\r
+void update_play(bool can_jump = true, int x_min = 0, int x_max = WIDTH - 1) {\r
if (get_dur(update_clock) >= update_time) {\r
update_clock = clock();\r
\r
if (keys[0] &&\r
- x > 0 &&\r
+ x > x_min &&\r
get_block(x - 1, y) != 'x')\r
move(-1, 0);\r
if (keys[1] &&\r
- x < WIDTH - 1 &&\r
+ x < x_max &&\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[2] && !keys_old[2] && jumping == 0 && can_jump) {\r
jumping = 1;\r
move(0, -1);\r
}\r
if (!jumping && get_block(x, y + 1) != 'x' && y < HEIGHT - 1)\r
move(0, +1);\r
-\r
- char block = get_block(x, y);\r
- switch (block) {\r
- case '/':\r
- case '\\':\r
- move_to(0, 24);\r
- break;\r
- case '?':\r
- puts("?");\r
- break;\r
- case 'O':\r
- puts("O");\r
- break;\r
- }\r
}\r
\r
int lvl = 0;\r
update_play();\r
if (x == 8) {\r
print_text(4, 8, "Collect ? for ???.", 30);\r
+ progress++;\r
+ }\r
+ break;\r
+ case 3:\r
+ update_play(true, 0, 22);\r
+ if (get_block(x, y) == '?') {\r
+ print_text(4, 10, "Avoid /\\.", 30);\r
+ progress++;\r
}\r
break;\r
+ case 4:\r
+ update_play();\r
+ break;\r
}\r
}\r
\r