2023-11-26 15:11:45 -05:00
|
|
|
/*
|
|
|
|
Copyright (c) 2023 : Ognjen 'xolatile' Milan Robovic
|
|
|
|
|
|
|
|
Xhartae is free software! You will redistribute it or modify it under the terms of the GNU General Public License by Free Software Foundation.
|
|
|
|
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.
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "../chapter/chapter_0.c"
|
|
|
|
#include "../chapter/chapter_1.c"
|
|
|
|
#include "../chapter/chapter_2.c"
|
|
|
|
|
|
|
|
static int player_x = 0;
|
|
|
|
static int player_y = 0;
|
|
|
|
|
|
|
|
static void player_move_up (void) { player_y -= 1; limit (& player_y, 0, curses_screen_height - 1); }
|
|
|
|
static void player_move_down (void) { player_y += 1; limit (& player_y, 0, curses_screen_height - 1); }
|
|
|
|
static void player_move_left (void) { player_x -= 1; limit (& player_x, 0, curses_screen_width - 1); }
|
|
|
|
static void player_move_right (void) { player_x += 1; limit (& player_x, 0, curses_screen_width - 1); }
|
|
|
|
|
|
|
|
int main (void) {
|
|
|
|
terminal_show_cursor (FALSE);
|
|
|
|
|
|
|
|
curses_configure ();
|
2023-11-28 15:30:55 -05:00
|
|
|
|
2023-11-26 15:11:45 -05:00
|
|
|
curses_bind (SIGNAL_ARROW_UP, player_move_up);
|
|
|
|
curses_bind (SIGNAL_ARROW_DOWN, player_move_down);
|
|
|
|
curses_bind (SIGNAL_ARROW_LEFT, player_move_left);
|
|
|
|
curses_bind (SIGNAL_ARROW_RIGHT, player_move_right);
|
2023-11-28 15:30:55 -05:00
|
|
|
|
2023-11-29 05:22:44 -05:00
|
|
|
curses_bind (SIGNAL_W, player_move_up);
|
|
|
|
curses_bind (SIGNAL_S, player_move_down);
|
|
|
|
curses_bind (SIGNAL_A, player_move_left);
|
|
|
|
curses_bind (SIGNAL_D, player_move_right);
|
|
|
|
|
2023-11-26 15:11:45 -05:00
|
|
|
while (curses_active) {
|
2023-11-29 05:22:44 -05:00
|
|
|
curses_render_background ('.', COLOUR_GREY, EFFECT_BOLD);
|
|
|
|
|
|
|
|
curses_render_rectangle (',', COLOUR_GREEN, EFFECT_NORMAL, 10, 10, 80, 24);
|
|
|
|
|
|
|
|
curses_render_character ('@', COLOUR_CYAN, EFFECT_BOLD, player_x, player_y);
|
|
|
|
|
|
|
|
for (int i = 0; i < 50; ++i) {
|
|
|
|
curses_render_character ('#', COLOUR_BLUE, EFFECT_BOLD, i, i);
|
|
|
|
}
|
2023-11-26 15:11:45 -05:00
|
|
|
|
|
|
|
curses_synchronize ();
|
|
|
|
}
|
|
|
|
|
|
|
|
terminal_show_cursor (TRUE);
|
|
|
|
|
|
|
|
return (EXIT_SUCCESS);
|
|
|
|
}
|