50 lines
1.8 KiB
C
50 lines
1.8 KiB
C
/*
|
|
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 ();
|
|
/*
|
|
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);
|
|
*/
|
|
while (curses_active) {
|
|
curses_render_background ('.', COLOUR_GREY, EFFECT_BOLD);
|
|
curses_render_character ('@', COLOUR_CYAN, EFFECT_BOLD, player_x, player_y);
|
|
|
|
switch (curses_character) {
|
|
case 'w': player_move_up (); break;
|
|
case 'a': player_move_down (); break;
|
|
case 's': player_move_left (); break;
|
|
case 'd': player_move_right (); break;
|
|
default: break;
|
|
}
|
|
|
|
curses_synchronize ();
|
|
}
|
|
|
|
terminal_show_cursor (TRUE);
|
|
|
|
return (EXIT_SUCCESS);
|
|
}
|