More to come...
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

51 wiersze
1.9KB

  1. /*
  2. Copyright (c) 2023 : Ognjen 'xolatile' Milan Robovic
  3. Xhartae is free software! You will redistribute it or modify it under the terms of the GNU General Public License by Free Software Foundation.
  4. And when you do redistribute it or modify it, it will use either version 3 of the License, or (at yours truly opinion) any later version.
  5. It is distributed in the hope that it will be useful or harmful, it really depends... But no warranty what so ever, seriously. See GNU/GPLv3.
  6. */
  7. #include "../chapter/chapter_0.c"
  8. #include "../chapter/chapter_1.c"
  9. #include "../chapter/chapter_2.c"
  10. static int player_x = 0;
  11. static int player_y = 0;
  12. static void player_move_up (void) { player_y -= 1; limit (& player_y, 0, curses_screen_height - 1); }
  13. static void player_move_down (void) { player_y += 1; limit (& player_y, 0, curses_screen_height - 1); }
  14. static void player_move_left (void) { player_x -= 1; limit (& player_x, 0, curses_screen_width - 1); }
  15. static void player_move_right (void) { player_x += 1; limit (& player_x, 0, curses_screen_width - 1); }
  16. int main (void) {
  17. terminal_show_cursor (FALSE);
  18. curses_configure ();
  19. curses_bind (SIGNAL_ARROW_UP, player_move_up);
  20. curses_bind (SIGNAL_ARROW_DOWN, player_move_down);
  21. curses_bind (SIGNAL_ARROW_LEFT, player_move_left);
  22. curses_bind (SIGNAL_ARROW_RIGHT, player_move_right);
  23. while (curses_active) {
  24. curses_render_background (' ', COLOUR_WHITE, EFFECT_NORMAL);
  25. curses_render_rectangle ('.', COLOUR_GREY, EFFECT_BOLD, 0, 0, 80, 24);
  26. curses_render_character ('@', COLOUR_CYAN, EFFECT_BOLD, player_x, player_y);
  27. //~switch (curses_character) {
  28. //~case 'w': player_move_up (); break;
  29. //~case 's': player_move_down (); break;
  30. //~case 'a': player_move_left (); break;
  31. //~case 'd': player_move_right (); break;
  32. //~default: break;
  33. //~}
  34. curses_synchronize ();
  35. }
  36. terminal_show_cursor (TRUE);
  37. return (EXIT_SUCCESS);
  38. }