From 27a9537652d975477f664c266f8c3b7a56a25529 Mon Sep 17 00:00:00 2001 From: Andrew Opalach Date: Wed, 13 Mar 2019 18:39:49 -0400 Subject: more restruture --- frontend/ncurses/ncurses_ui.c | 20 +++++++++++--------- frontend/sdl/.border.jpeg-autosave.kra | Bin 71027 -> 0 bytes frontend/sdl/sdl_ui.c | 10 +++++----- 3 files changed, 16 insertions(+), 14 deletions(-) delete mode 100644 frontend/sdl/.border.jpeg-autosave.kra (limited to 'frontend') diff --git a/frontend/ncurses/ncurses_ui.c b/frontend/ncurses/ncurses_ui.c index 7a92c0f..98f2b4b 100644 --- a/frontend/ncurses/ncurses_ui.c +++ b/frontend/ncurses/ncurses_ui.c @@ -35,17 +35,17 @@ " \\--------------------/" #else #define BLOCK "[]" -#define PLAY_FIELD_STR " ┏━━━━━━━━━━━━━━━━━━━━┓ ┏━━━━━━━━━━━━━━━┓ \n"\ +#define PLAY_FIELD_STR " ┏━━━━━━━━━━━┓ ┏━━━━━━━━━\n"\ " ┃ ┃ ┃ ┃ \n"\ - " ┃ ┃ ┗━━━━━━━━━━━━━━━┛ \n"\ + " ┃ ┃ ━━━━━━━━━┛ \n"\ " ┃ ┃ \n"\ " ┃ ┃ \n"\ - " ┃ ┃ ┏━━━━━━━━━━━┓ \n"\ + " ┃ ┃ ┏━━━━━━┓ \n"\ " ┃ ┃ ┃ ┃ \n"\ " ┃ ┃ ┃ ┃ \n"\ " ┃ ┃ ┃ ┃ \n"\ " ┃ ┃ ┃ ┃ \n"\ - " ┃ ┃ ┗━━━━━━━━━━━┛ \n"\ + " ┃ ┃ ┗━━━━━━┛ \n"\ " ┃ ┃ \n"\ " ┃ ┃ \n"\ " ┃ ┃ \n"\ @@ -56,7 +56,7 @@ " ┃ ┃ \n"\ " ┃ ┃ \n"\ " ┃ ┃ \n"\ - " ┗━━━━━━━━━━━━━━━━━━━━┛ " + " ┗━━━━━━━━━━━┛ " #endif #define X_OFFSET 8 @@ -86,16 +86,16 @@ void curses_init() { void draw_board() { mvaddstr(0, 0, PLAY_FIELD_STR); - for (int x = 0; x < BOARD_X; x++) { - for (int y = BOARD_VISABLE; y < BOARD_Y; y++) { + for (int x = 0; x < CETRIS_BOARD_X; x++) { + for (int y = CETRIS_BOARD_VISABLE; y < CETRIS_BOARD_Y; y++) { if (game.board[x][y].occupied) { attron(COLOR_PAIR(game.board[x][y].c)); if (game.board[x][y].remove_tick > 0) { if (game.tick % 2 == 0) { - mvaddstr((y - BOARD_VISABLE) + 1, x * 2 + X_OFFSET, BLOCK); + mvaddstr((y - CETRIS_BOARD_VISABLE) + 1, x * 2 + X_OFFSET, BLOCK); } } else { - mvaddstr((y - BOARD_VISABLE) + 1, x * 2 + X_OFFSET, BLOCK); + mvaddstr((y - CETRIS_BOARD_VISABLE) + 1, x * 2 + X_OFFSET, BLOCK); } attroff(COLOR_PAIR(game.board[x][y].c)); } @@ -161,6 +161,8 @@ int main(void) { init_game(&game); } break; + default: + clear_held_key(&game.input); } update_game_tick(&game); erase(); diff --git a/frontend/sdl/.border.jpeg-autosave.kra b/frontend/sdl/.border.jpeg-autosave.kra deleted file mode 100644 index 69f596a..0000000 Binary files a/frontend/sdl/.border.jpeg-autosave.kra and /dev/null differ diff --git a/frontend/sdl/sdl_ui.c b/frontend/sdl/sdl_ui.c index 8eaecab..c5c9917 100644 --- a/frontend/sdl/sdl_ui.c +++ b/frontend/sdl/sdl_ui.c @@ -141,11 +141,11 @@ void draw_stuff() { free(lines); SDL_SetRenderDrawColor(render, 255, 255, 255, 124); - for (int x = 0; x < BOARD_X + 1; x++) { + for (int x = 0; x < CETRIS_BOARD_X + 1; x++) { int rx = BOARD_OFFSET_X + 1 + (x * 25); SDL_RenderDrawLine(render, rx, BOARD_OFFSET_Y + 1, rx, BOARD_OFFSET_Y + 500); } - for (int y = 0; y < BOARD_Y - BOARD_VISABLE + 1; y++) { + for (int y = 0; y < CETRIS_BOARD_Y - CETRIS_BOARD_VISABLE + 1; y++) { int ry = BOARD_OFFSET_Y + (y * 25); SDL_RenderDrawLine(render, BOARD_OFFSET_X + 1, ry, BOARD_OFFSET_X + 250, ry); } @@ -153,13 +153,13 @@ void draw_stuff() { sdl_color c; SDL_Rect r = {0, 0, 25, 25}; - for (int x = 0; x < BOARD_X; x++) { - for (int y = BOARD_VISABLE; y < BOARD_Y; y++) { + for (int x = 0; x < CETRIS_BOARD_X; x++) { + for (int y = CETRIS_BOARD_VISABLE; y < CETRIS_BOARD_Y; y++) { if (g.board[x][y].occupied) { c = colors[g.board[x][y].c]; SDL_SetTextureColorMod(block, c.r, c.g, c.b); r.x = BOARD_OFFSET_X + x * 25; - r.y = BOARD_OFFSET_Y + (y - BOARD_VISABLE) * 25; + r.y = BOARD_OFFSET_Y + (y - CETRIS_BOARD_VISABLE) * 25; SDL_RenderCopy(render, block, NULL, &r); } } -- cgit v1.2.3-101-g0448