From 458ab270a8b7246a1a617e34c02aa74deca92ba6 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Mon, 15 Apr 2019 18:32:47 -0400 Subject: convert core to ansii c --- frontends/curses/curses_ui.c | 17 +++++++++-------- frontends/curses/meson.build | 13 +++++++------ 2 files changed, 16 insertions(+), 14 deletions(-) (limited to 'frontends/curses') diff --git a/frontends/curses/curses_ui.c b/frontends/curses/curses_ui.c index 5557ed9..a6572e4 100644 --- a/frontends/curses/curses_ui.c +++ b/frontends/curses/curses_ui.c @@ -72,9 +72,7 @@ void curses_init() { setlocale(LC_CTYPE, ""); initscr(); curs_set(0); - //noecho(); keypad(stdscr, TRUE); - //timeout(1000 / CETRIS_HZ); nodelay(stdscr, true); start_color(); @@ -109,9 +107,11 @@ void *game_loop(void) { void draw_board() { + int x, y; + mvaddstr(0, 0, PLAY_FIELD_STR); - for (int x = 0; x < CETRIS_BOARD_X; x++) { - for (int y = 0; y < CETRIS_BOARD_Y; y++) { + for (x = 0; x < CETRIS_BOARD_X; x++) { + for (y = 0; y < CETRIS_BOARD_Y; y++) { if (game.board[x][y].ghost) { attron(A_DIM); mvaddstr((y) + 1, x * 2 + X_OFFSET, BLOCK); @@ -132,8 +132,8 @@ void draw_board() { int index = game.current_index; attron(COLOR_PAIR(game.piece_queue[index].c)); - for (int x = 0; x < 4; x++) { - for (int y = 0; y < 4; y++) { + for (x = 0; x < 4; x++) { + for (y = 0; y < 4; y++) { if (game.piece_queue[index].m[y][x]) { if (game.piece_queue[index].t == I) { mvaddstr(6 + y, (x * 2) + 36, BLOCK); @@ -177,13 +177,14 @@ int main(void) { pthread_create(&thread, NULL, (void*)game_loop, (void*)0); #endif + int i; int down = 0; while(1) { int keys[50]; int key_count = 0; int moves[8]; memset(moves, 0, sizeof(int) * 8); while((keys[key_count] = getch()) != ERR) key_count++; if (down) move_piece(&game, USER_DOWN); - for (int i = 0; i < key_count; i++) { + for (i = 0; i < key_count; i++) { switch (keys[i]) { case 'q': endwin(); exit(1); case KEY_LEFT: @@ -209,7 +210,7 @@ int main(void) { } } if (!moves[USER_DOWN]) down = 0; - for (int i = 1; i < 8; i++) { + for (i = 1; i < 8; i++) { if (!moves[i]) stop_holding(&game, i); } erase(); diff --git a/frontends/curses/meson.build b/frontends/curses/meson.build index a390193..2671b3b 100644 --- a/frontends/curses/meson.build +++ b/frontends/curses/meson.build @@ -1,7 +1,8 @@ src = ['curses_ui.c'] -inc = [] -deps = [] +deps = [cetris] +inc = [cetris_inc] + if host_machine.system() == 'windows' inc += include_directories('win') deps += compiler.find_library('pdcurses', dirs: meson.current_source_dir() + '/win') @@ -10,7 +11,7 @@ else deps += dependency('threads') endif -executable('cetris_curses', src, - dependencies: [deps, cetris], - include_directories: [inc, cetris_inc], - install: false) +executable('cetris', src, + dependencies: deps, + include_directories: inc, + install: false) -- cgit v1.2.3-101-g0448