From baa18d56a2b2ab604ef452d95ee7bafa7d6d7376 Mon Sep 17 00:00:00 2001 From: Miguel Angel Astor Romero Date: Sat, 1 Mar 2014 14:23:23 -0430 Subject: [PATCH 01/26] Added project files. --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index b3504ee..9846a60 100644 --- a/.gitignore +++ b/.gitignore @@ -15,5 +15,6 @@ obj/ *.app bin/ -# Emacs backups +# Assorted files *~ +Cyberpunk-Jam From 667e1b1691454be73ef4606447d4456b6badfdff Mon Sep 17 00:00:00 2001 From: Miguel Angel Astor Romero Date: Sat, 1 Mar 2014 22:43:28 -0430 Subject: [PATCH 02/26] Tested some island and unicode rendering. --- Makefile | 16 +++++-- include/constants.h | 45 +++++++++++------- include/game_state.h | 22 +++++++++ include/in_game.h | 13 ++++++ src/game_state.c | 10 ++++ src/in_game.c | 94 +++++++++++++++++++++++++++++++++++++ src/main.c | 109 +++++++++++++++++++++++++++++++------------ 7 files changed, 258 insertions(+), 51 deletions(-) create mode 100644 include/game_state.h create mode 100644 include/in_game.h create mode 100644 src/game_state.c create mode 100644 src/in_game.c diff --git a/Makefile b/Makefile index c2c281c..a0ef6b4 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,10 @@ CC = gcc -SOURCES = src/main.c -OBJECTS = obj/main.o +SOURCES = src/main.c src/game_state.c src/in_game.c +OBJECTS = obj/main.o obj/game_state.o obj/in_game.o TARGET = bin/cyjam -CFLAGS = -Wall -I./include +CFLAGS = -Wall -I./include -std=c99 LDFLAGS = -L./lib -LDLIBS = -lm -lisland -lfov -lncurses +LDLIBS = -lm -lisland -lfov -lncursesw all: CFLAGS += -O3 all: $(TARGET) @@ -15,7 +15,13 @@ debug: $(TARGET) $(TARGET): $(OBJECTS) $(CC) -o $(TARGET) $(OBJECTS) $(CLFAGS) $(LDFLAGS) $(LDLIBS) -obj/main.o: src/main.c +obj/main.o: src/main.c include/constants.h include/game_state.h + $(CC) -c -o $@ $< $(CFLAGS) + +obj/game_state.o: src/game_state.c include/game_state.h include/in_game.h + $(CC) -c -o $@ $< $(CFLAGS) + +obj/in_game.o: src/in_game.c include/in_game.h include/game_state.h $(CC) -c -o $@ $< $(CFLAGS) clean: diff --git a/include/constants.h b/include/constants.h index ae042e0..6d5d7a2 100644 --- a/include/constants.h +++ b/include/constants.h @@ -1,22 +1,35 @@ -#pragma once +/** + * Copyright (c) 2014, Miguel Angel Astor Romero. All rights reserved. + * See the file LICENSE for more details. + */ + #ifndef STATE_CONSTS_H #define STATE_CONSTS_H -static const int BAR_COLOR = 1; -static const int BSC_COLOR = 2; -static const int HLT_COLOR = 3; -static const int OFF_COLOR = 4; -static const int DIM_COLOR = 5; -static const int LIT_COLOR = 6; -static const int GUI_COLOR = 7; -static const int EMP_COLOR = 8; +#if defined(_WIN32) || defined(_WIN64) || defined(__MINGW32__) +#define F_SEP "\\" +#elif defined(__linux__) || defined(__GNUC__) +#define F_SEP "/" +#else +#error "Unrecognized system." +#endif -static const int INTRO_STATE = 0; -static const int MENU_STATE = 1; -static const int LOAD_STATE = 2; -static const int SCORE_STATE = 3; -static const int GAME_STATE = 4; - -static const int QUIT_STATE = -1; +enum COLORS { + BAR_COLOR = 1, + BSC_COLOR, + HLT_COLOR, + OFF_COLOR, + DIM_COLOR, + LIT_COLOR, + GUI_COLOR, + EMP_COLOR, + DW_COLOR, + SW_COLOR, + SN_COLOR, + GR_COLOR, + FR_COLOR, + HL_COLOR, + MN_COLOR +}; #endif diff --git a/include/game_state.h b/include/game_state.h new file mode 100644 index 0000000..9fe435e --- /dev/null +++ b/include/game_state.h @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2014, Miguel Angel Astor Romero. All rights reserved. + * See the file LICENSE for more details. + */ + +#ifndef GAME_STATE_H +#define GAME_STATE_H + +static const int NUM_STATES = 4; + +typedef enum GAME_STATE_NAMES { INTRO = 0, MENU = 1, IN_GAME = 2, GAME_OVER = 3 } gsname_t; + +typedef struct GAME_STATE { + gsname_t name; + void (*input)(); + gsname_t (*update)(); + void (*render)(int, int); +} gs_t; + +extern void initStateArray(gs_t **); + +#endif diff --git a/include/in_game.h b/include/in_game.h new file mode 100644 index 0000000..be4d39a --- /dev/null +++ b/include/in_game.h @@ -0,0 +1,13 @@ +/** + * Copyright (c) 2014, Miguel Angel Astor Romero. All rights reserved. + * See the file LICENSE for more details. + */ + +#ifndef IN_GAME_H +#define IN_GAME_H + +#include "game_state.h" + +extern void initInGameState(gs_t *); + +#endif diff --git a/src/game_state.c b/src/game_state.c new file mode 100644 index 0000000..088d0bd --- /dev/null +++ b/src/game_state.c @@ -0,0 +1,10 @@ +#include "game_state.h" +#include "in_game.h" + +void initStateArray(gs_t ** s){ + int i; + + for(i = 0; i < NUM_STATES; i++){ + initInGameState(&((*s)[i])); + } +} diff --git a/src/in_game.c b/src/in_game.c new file mode 100644 index 0000000..95ec1be --- /dev/null +++ b/src/in_game.c @@ -0,0 +1,94 @@ +#include +#include +#include + +#include "constants.h" +#include "in_game.h" + +static const int I_SIZE = 257; +static int ** imap; + +void input(); +gsname_t update(); +void render(int, int); + +void initInGameState( gs_t * gs) { + int n, i; + float ** map; + + gs->name = IN_GAME; + gs->input = &input; + gs->update = &update; + gs->render = &render; + + n = I_SIZE; + + map = ( float ** ) malloc ( sizeof ( float * ) * n); + for ( i = 0; i < n; ++i ) { + map[ i ] = ( float * ) calloc ( n, sizeof ( float ) ); + } + + imap = ( int ** ) malloc ( sizeof ( int * ) * n); + for ( i = 0; i < n; ++i ) { + imap[ i ] = ( int * ) calloc ( n, sizeof ( int ) ); + } + + ds ( &map, n ); + island ( &imap, n ); + normInt ( &imap, n ); + norm ( &map, n ); + mult ( &map, &imap, n ); + smooth( &imap, n ); + normInt ( &imap, n ); + + free(map); +} + +void input(){ + +} + +gsname_t update(){ + return IN_GAME; +} + +void render(int w, int h){ + int i, j; + + for(i = 0; i < w; i++){ + for(j = 0; j < h; j++){ + move(j, i); + + switch(terrainType( imap[(i + (I_SIZE/4)) % I_SIZE][(j + (I_SIZE/4)) % I_SIZE] )){ + case DEEP_WATER: + attron(COLOR_PAIR(DW_COLOR)); + printw("~"); + break; + case SHALLOW_WATER: + attron(COLOR_PAIR(SW_COLOR)); + printw("~"); + break; + case SAND: + attron(COLOR_PAIR(SN_COLOR)); + printw("."); + break; + case GRASS: + attron(COLOR_PAIR(GR_COLOR)); + printw("\u2591"); + break; + case FOREST: + attron(COLOR_PAIR(FR_COLOR)); + printw("\u2660"); + break; + case HILL: + attron(COLOR_PAIR(HL_COLOR)); + printw("\u2302"); + break; + case MOUNTAIN: + attron(COLOR_PAIR(MN_COLOR)); + printw("\u25B2"); + break; + } + } + } +} diff --git a/src/main.c b/src/main.c index ea0bcf7..0ad93f3 100644 --- a/src/main.c +++ b/src/main.c @@ -10,12 +10,15 @@ #include #include #include -#include +#include #include +#include #include #include #include + #include "constants.h" +#include "game_state.h" void leave(void); void manage_signal(int signal); @@ -28,11 +31,19 @@ static int w = 0, h = 0; int main() { bool finished = false; - char *home_dir = getenv("HOME"); - char *data_dir; - char *log_file; - time_t raw_date; - struct tm *current_date; +#if defined(_WIN32) || defined(_WIN64) || defined(__MINGW32__) + char * home_dir = getenv("APPDATA"); +#elif defined(__linux__) || defined(__GNUC__) + char * home_dir = getenv("HOME"); +#else +#error "Unrecoginized compiler." +#endif + char * data_dir; + char * log_file; + time_t raw_date; + struct tm * current_date; + gs_t * states; + int c_state; atexit(leave); signal(SIGINT, manage_signal); @@ -45,12 +56,12 @@ int main() { /* If we got the user's home directory, build the data directory path. */ data_dir = (char*)malloc(strlen(home_dir) + 7); strcpy(data_dir, home_dir); - strcat(data_dir, "/.tomb"); + strcat(data_dir, F_SEP ".cyjam"); /* Redirect stderr output to a file. */ log_file = (char*)malloc(strlen(data_dir) + 8); strcpy(log_file, data_dir); - strcat(log_file, "/stderr"); + strcat(log_file, F_SEP "stderr"); freopen(log_file, "a", stderr); /* Log the current date and time. */ @@ -61,13 +72,11 @@ int main() { /* Try to create the data directory with permissions 775. */ if(mkdir(data_dir, S_IRWXU | S_IWGRP | S_IRGRP| S_IROTH | S_IXOTH) == 0){ /* The data directory was sucessfully created. */ - //init_scores(data_dir); }else{ if(errno != EEXIST){ /* The directory does not exists and could not be created. */ - perror("\tmain.c"); + perror("\t" __FILE__); fprintf(stderr, "\tdata_dir is: %s\n", data_dir); - //init_scores(NULL); }else{ /* The directory already exits. */ //init_scores(data_dir); @@ -75,22 +84,31 @@ int main() { } }else{ /* If there is no HOME environment variable, quit. */ - fprintf(stderr, "\tmain.c: Couldn't find the user's home directory\n"); + fprintf(stderr, "\t%s: Couldn't find the user's home directory\n", __FILE__); return EXIT_FAILURE; } /* Start ncurses. */ if(start_ncurses() != 0){ - fprintf(stderr, "\tmain.c: Ncurses could not be initialized.\n"); + fprintf(stderr, "\t%s: Ncurses could not be initialized.\n", __FILE__); return EXIT_FAILURE; } set_colors(); - do{ - clear_screen(); + c_state = 2; + + states = (gs_t *)malloc(sizeof(gs_t) * NUM_STATES); + initStateArray(&states); - refresh(); - }while(!finished); + do{ + clear_screen(); + + states[c_state].input(); + c_state = states[c_state].update(); + states[c_state].render(w, h); + + refresh(); + }while(!finished); return EXIT_SUCCESS; } @@ -101,8 +119,8 @@ void leave(void){ /* Finish ncurses. */ endwin(); - /* Close the scores database and todays log. */ - // close_scores(); + + /* Mark the end of this run's log. */ for(i = 0; i < 80; i++) fprintf(stderr, "-"); fprintf(stderr, "\n"); @@ -113,12 +131,19 @@ void manage_signal(int signal){ switch(signal){ case SIGINT: fprintf(stderr, "\tSIGINT caught.\n"); + exit(EXIT_SUCCESS); break; + case SIGSEGV: fprintf(stderr, "\tSegmentation fault.\n"); + exit(EXIT_FAILURE); + break; + case SIGTERM: + fprintf(stderr, "\tSIGTERM caught.\n"); exit(EXIT_FAILURE); break; + } } @@ -127,40 +152,51 @@ void on_resize(int signal){ /* Request the new size of the terminal. */ ioctl(1, TIOCGWINSZ, &ws); - /* Resize ncurse's stdscr. */ + + /* Resize ncurses's stdscr. */ resizeterm(ws.ws_row, ws.ws_col); + /* Get the new size of the window. */ getmaxyx(stdscr, h, w); + fprintf(stderr, "\tSIGWINCH caught. (W: %d, H: %d)\n", w, h); } int start_ncurses(void){ WINDOW *win_ptr; int ret_code; + + setlocale(LC_ALL, ""); + /* Prepare the terminal. */ win_ptr = initscr(); if(win_ptr == NULL) return -1; + /* Enable special characters. */ ret_code = keypad(stdscr, TRUE); if(ret_code == ERR) return -1; + /* Disable line buffering. */ ret_code = cbreak(); if(ret_code == ERR) return -1; + /* Disable echo. */ ret_code = noecho(); if(ret_code == ERR) return -1; + /* Hide the cursor. */ ret_code = curs_set(FALSE); if(ret_code == ERR) return -1; + /* Initialize the screen size variables. */ getmaxyx(stdscr, h, w); - return 0; + return EXIT_SUCCESS; } void set_colors(void){ @@ -168,16 +204,29 @@ void set_colors(void){ ret_code = start_color(); if(ret_code == OK){ if(has_colors() == TRUE){ - init_pair(1, COLOR_WHITE, COLOR_RED); /* The color for the top and bottom bars. */ - init_pair(2, COLOR_WHITE, COLOR_BLACK); /* Basic text color. */ - init_pair(3, COLOR_YELLOW, COLOR_BLACK); /* Highlighted text color. */ - init_pair(4, COLOR_BLUE, COLOR_BLACK); /* Lights off color. */ - init_pair(5, COLOR_RED, COLOR_BLACK); /* Dim light color. */ - init_pair(6, COLOR_YELLOW, COLOR_BLACK); /* Lights on color. */ - init_pair(7, COLOR_YELLOW, COLOR_YELLOW); /* Main GUI bar color. */ - init_pair(8, COLOR_WHITE, COLOR_WHITE); /* Empty GUI bar color. */ + init_color(COLOR_MAGENTA, 0, 0, 500); + + init_pair(BAR_COLOR, COLOR_WHITE, COLOR_RED); /* The color for the top and bottom bars. */ + init_pair(BSC_COLOR, COLOR_WHITE, COLOR_BLACK); /* Basic text color. */ + init_pair(HLT_COLOR, COLOR_YELLOW, COLOR_BLACK); /* Highlighted text color. */ + init_pair(OFF_COLOR, COLOR_BLUE, COLOR_BLACK); /* Lights off color. */ + init_pair(DIM_COLOR, COLOR_RED, COLOR_BLACK); /* Dim light color. */ + init_pair(LIT_COLOR, COLOR_YELLOW, COLOR_BLACK); /* Lights on color. */ + init_pair(GUI_COLOR, COLOR_YELLOW, COLOR_YELLOW); /* Main GUI bar color. */ + init_pair(EMP_COLOR, COLOR_WHITE, COLOR_WHITE); /* Empty GUI bar color. */ + + init_pair(DW_COLOR, COLOR_MAGENTA, COLOR_BLACK); + init_pair(SW_COLOR, COLOR_BLUE, COLOR_BLACK); + init_pair(SN_COLOR, COLOR_YELLOW, COLOR_BLACK); + init_pair(GR_COLOR, COLOR_GREEN, COLOR_BLACK); + init_pair(FR_COLOR, COLOR_GREEN, COLOR_BLACK); + init_pair(HL_COLOR, COLOR_RED, COLOR_BLACK); + init_pair(MN_COLOR, COLOR_WHITE, COLOR_BLACK); } - } + }else{ + fprintf(stderr, "\t%s: Colors not supported.\n", __FILE__); + exit(EXIT_FAILURE); + } } void clear_screen(void){ From 2c582f76c413a490246d4ea73937ed025e35d6e3 Mon Sep 17 00:00:00 2001 From: Miguel Angel Astor Romero Date: Sun, 2 Mar 2014 01:21:00 -0430 Subject: [PATCH 03/26] Calculates and reports frames per second. --- src/main.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/main.c b/src/main.c index 0ad93f3..ca9ebcf 100644 --- a/src/main.c +++ b/src/main.c @@ -30,7 +30,7 @@ void on_resize(int); static int w = 0, h = 0; int main() { - bool finished = false; + int finished = 0; #if defined(_WIN32) || defined(_WIN64) || defined(__MINGW32__) char * home_dir = getenv("APPDATA"); #elif defined(__linux__) || defined(__GNUC__) @@ -38,6 +38,9 @@ int main() { #else #error "Unrecoginized compiler." #endif + FILE * f; /* To avoid a warning. */ + clock_t then, now, delta; + unsigned int fps = 0, pfps = 0; char * data_dir; char * log_file; time_t raw_date; @@ -62,7 +65,8 @@ int main() { log_file = (char*)malloc(strlen(data_dir) + 8); strcpy(log_file, data_dir); strcat(log_file, F_SEP "stderr"); - freopen(log_file, "a", stderr); + f = freopen(log_file, "a", stderr); + fclose(f); /* Log the current date and time. */ time(&raw_date); @@ -95,18 +99,37 @@ int main() { } set_colors(); + /* Create the state data structures. */ c_state = 2; - states = (gs_t *)malloc(sizeof(gs_t) * NUM_STATES); initStateArray(&states); + /* Start the game loop. */ + then = clock(); do{ clear_screen(); states[c_state].input(); c_state = states[c_state].update(); + + if(c_state == -1) finished = 1; + states[c_state].render(w, h); + fps++; + + now = clock(); + delta = now - then; + if((int)delta / (int)CLOCKS_PER_SEC == 1){ + then = now; + pfps = fps; + fps = 0; + } + + move(0, 0); + attron(COLOR_PAIR(BAR_COLOR)); + printw("FPS: %u", pfps); + refresh(); }while(!finished); @@ -215,8 +238,8 @@ void set_colors(void){ init_pair(GUI_COLOR, COLOR_YELLOW, COLOR_YELLOW); /* Main GUI bar color. */ init_pair(EMP_COLOR, COLOR_WHITE, COLOR_WHITE); /* Empty GUI bar color. */ - init_pair(DW_COLOR, COLOR_MAGENTA, COLOR_BLACK); - init_pair(SW_COLOR, COLOR_BLUE, COLOR_BLACK); + init_pair(DW_COLOR, COLOR_BLUE, COLOR_BLACK); + init_pair(SW_COLOR, COLOR_CYAN, COLOR_BLACK); init_pair(SN_COLOR, COLOR_YELLOW, COLOR_BLACK); init_pair(GR_COLOR, COLOR_GREEN, COLOR_BLACK); init_pair(FR_COLOR, COLOR_GREEN, COLOR_BLACK); From 488647e0de4196aecef0a06317ac6fbb0dbcc57e Mon Sep 17 00:00:00 2001 From: Miguel Angel Astor Romero Date: Sun, 2 Mar 2014 12:14:08 -0430 Subject: [PATCH 04/26] Correctly handle resize events. --- src/main.c | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/main.c b/src/main.c index ca9ebcf..2f049c2 100644 --- a/src/main.c +++ b/src/main.c @@ -27,7 +27,7 @@ void set_colors(void); void clear_screen(void); void on_resize(int); -static int w = 0, h = 0; +static int w = 0, h = 0, resize = 0; int main() { int finished = 0; @@ -66,7 +66,6 @@ int main() { strcpy(log_file, data_dir); strcat(log_file, F_SEP "stderr"); f = freopen(log_file, "a", stderr); - fclose(f); /* Log the current date and time. */ time(&raw_date); @@ -109,6 +108,18 @@ int main() { do{ clear_screen(); + if(resize){ + endwin(); + refresh(); + + getmaxyx(stdscr, h, w); + + fprintf(stderr, "\tSIGWINCH caught. (W: %d, H: %d)\n", w, h); + + resize = 0; + signal(SIGWINCH, on_resize); + } + states[c_state].input(); c_state = states[c_state].update(); @@ -133,6 +144,8 @@ int main() { refresh(); }while(!finished); + fclose(f); + return EXIT_SUCCESS; } @@ -171,18 +184,18 @@ void manage_signal(int signal){ } void on_resize(int signal){ - struct winsize ws; + /*struct winsize ws;*/ /* Request the new size of the terminal. */ - ioctl(1, TIOCGWINSZ, &ws); + /*ioctl(1, TIOCGWINSZ, &ws);*/ /* Resize ncurses's stdscr. */ - resizeterm(ws.ws_row, ws.ws_col); + /*resizeterm(ws.ws_row, ws.ws_col);*/ /* Get the new size of the window. */ - getmaxyx(stdscr, h, w); + /*getmaxyx(stdscr, h, w);*/ - fprintf(stderr, "\tSIGWINCH caught. (W: %d, H: %d)\n", w, h); + resize = 1; } int start_ncurses(void){ From 3e91d797bb1432db780731b4000188cf6890db84 Mon Sep 17 00:00:00 2001 From: Miguel Angel Astor Romero Date: Sun, 2 Mar 2014 14:56:23 -0430 Subject: [PATCH 05/26] Removed some needless comments. --- src/main.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/main.c b/src/main.c index 2f049c2..5ed2198 100644 --- a/src/main.c +++ b/src/main.c @@ -108,6 +108,7 @@ int main() { do{ clear_screen(); + /* Handle terminal resize. */ if(resize){ endwin(); refresh(); @@ -184,17 +185,6 @@ void manage_signal(int signal){ } void on_resize(int signal){ - /*struct winsize ws;*/ - - /* Request the new size of the terminal. */ - /*ioctl(1, TIOCGWINSZ, &ws);*/ - - /* Resize ncurses's stdscr. */ - /*resizeterm(ws.ws_row, ws.ws_col);*/ - - /* Get the new size of the window. */ - /*getmaxyx(stdscr, h, w);*/ - resize = 1; } From f1a6eda4805dd150faff0afc5f1ff2554bdea26a Mon Sep 17 00:00:00 2001 From: Miguel Angel Astor Romero Date: Sun, 2 Mar 2014 16:35:14 -0430 Subject: [PATCH 06/26] Some testing here and there. --- src/in_game.c | 16 +++++++++++++--- src/main.c | 21 ++++++++++++--------- 2 files changed, 25 insertions(+), 12 deletions(-) diff --git a/src/in_game.c b/src/in_game.c index 95ec1be..0d3af11 100644 --- a/src/in_game.c +++ b/src/in_game.c @@ -41,11 +41,20 @@ void initInGameState( gs_t * gs) { smooth( &imap, n ); normInt ( &imap, n ); + for ( i = 0; i < n; ++i ) { + free(map[ i ]); + } free(map); } void input(){ + int key = 0; + key = getch(); + + if(key != ERR){ + fprintf(stderr, "\t%s: Caught keycode %d\n", __FILE__, key); + } } gsname_t update(){ @@ -62,11 +71,11 @@ void render(int w, int h){ switch(terrainType( imap[(i + (I_SIZE/4)) % I_SIZE][(j + (I_SIZE/4)) % I_SIZE] )){ case DEEP_WATER: attron(COLOR_PAIR(DW_COLOR)); - printw("~"); + printw("\u2248"); break; case SHALLOW_WATER: attron(COLOR_PAIR(SW_COLOR)); - printw("~"); + printw("\u2248"); break; case SAND: attron(COLOR_PAIR(SN_COLOR)); @@ -74,7 +83,7 @@ void render(int w, int h){ break; case GRASS: attron(COLOR_PAIR(GR_COLOR)); - printw("\u2591"); + printw("n"); break; case FOREST: attron(COLOR_PAIR(FR_COLOR)); @@ -89,6 +98,7 @@ void render(int w, int h){ printw("\u25B2"); break; } + //printw("\u2588"); } } } diff --git a/src/main.c b/src/main.c index 5ed2198..30bdfeb 100644 --- a/src/main.c +++ b/src/main.c @@ -27,10 +27,11 @@ void set_colors(void); void clear_screen(void); void on_resize(int); -static int w = 0, h = 0, resize = 0; +static int w = 0, h = 0; +static bool resize = FALSE; int main() { - int finished = 0; + bool finished = FALSE; #if defined(_WIN32) || defined(_WIN64) || defined(__MINGW32__) char * home_dir = getenv("APPDATA"); #elif defined(__linux__) || defined(__GNUC__) @@ -106,8 +107,6 @@ int main() { /* Start the game loop. */ then = clock(); do{ - clear_screen(); - /* Handle terminal resize. */ if(resize){ endwin(); @@ -117,14 +116,14 @@ int main() { fprintf(stderr, "\tSIGWINCH caught. (W: %d, H: %d)\n", w, h); - resize = 0; + resize = FALSE; signal(SIGWINCH, on_resize); } states[c_state].input(); c_state = states[c_state].update(); - if(c_state == -1) finished = 1; + if(c_state == -1) finished = TRUE; states[c_state].render(w, h); @@ -180,12 +179,11 @@ void manage_signal(int signal){ fprintf(stderr, "\tSIGTERM caught.\n"); exit(EXIT_FAILURE); break; - } } void on_resize(int signal){ - resize = 1; + resize = TRUE; } int start_ncurses(void){ @@ -219,6 +217,11 @@ int start_ncurses(void){ if(ret_code == ERR) return -1; + /* Set delay. */ + ret_code = nodelay(stdscr, TRUE); + if(ret_code == ERR) + return -1; + /* Initialize the screen size variables. */ getmaxyx(stdscr, h, w); @@ -246,7 +249,7 @@ void set_colors(void){ init_pair(SN_COLOR, COLOR_YELLOW, COLOR_BLACK); init_pair(GR_COLOR, COLOR_GREEN, COLOR_BLACK); init_pair(FR_COLOR, COLOR_GREEN, COLOR_BLACK); - init_pair(HL_COLOR, COLOR_RED, COLOR_BLACK); + init_pair(HL_COLOR, COLOR_WHITE, COLOR_BLACK); init_pair(MN_COLOR, COLOR_WHITE, COLOR_BLACK); } }else{ From 073407c752098f6cb4cb060c5f00c99c5ba49d45 Mon Sep 17 00:00:00 2001 From: Miguel Angel Astor Romero Date: Sun, 2 Mar 2014 18:56:56 -0430 Subject: [PATCH 07/26] Removed useless headers. Playing with the render. --- Makefile | 1 - src/game_state.c | 5 +++++ src/in_game.c | 44 +++++++++++++++++++++++++++++++++++++++++--- src/main.c | 7 +------ 4 files changed, 47 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index a0ef6b4..ff64137 100644 --- a/Makefile +++ b/Makefile @@ -26,4 +26,3 @@ obj/in_game.o: src/in_game.c include/in_game.h include/game_state.h clean: $(RM) $(TARGET) $(OBJECTS) - diff --git a/src/game_state.c b/src/game_state.c index 088d0bd..b838173 100644 --- a/src/game_state.c +++ b/src/game_state.c @@ -1,3 +1,8 @@ +/** + * Copyright (c) 2014, Miguel Angel Astor Romero. All rights reserved. + * See the file LICENSE for more details. + */ + #include "game_state.h" #include "in_game.h" diff --git a/src/in_game.c b/src/in_game.c index 0d3af11..f303431 100644 --- a/src/in_game.c +++ b/src/in_game.c @@ -1,4 +1,10 @@ +/** + * Copyright (c) 2014, Miguel Angel Astor Romero. All rights reserved. + * See the file LICENSE for more details. + */ + #include +#include #include #include @@ -7,13 +13,16 @@ static const int I_SIZE = 257; static int ** imap; +static bool ** wmap; +static bool w_mov = FALSE; +static clock_t then; void input(); gsname_t update(); void render(int, int); void initInGameState( gs_t * gs) { - int n, i; + int n, i, j; float ** map; gs->name = IN_GAME; @@ -23,6 +32,8 @@ void initInGameState( gs_t * gs) { n = I_SIZE; + srand(time(NULL)); + map = ( float ** ) malloc ( sizeof ( float * ) * n); for ( i = 0; i < n; ++i ) { map[ i ] = ( float * ) calloc ( n, sizeof ( float ) ); @@ -33,6 +44,14 @@ void initInGameState( gs_t * gs) { imap[ i ] = ( int * ) calloc ( n, sizeof ( int ) ); } + wmap = ( bool ** ) malloc ( sizeof ( bool * ) * n); + for ( i = 0; i < n; ++i ) { + wmap[ i ] = ( bool * ) calloc ( n, sizeof ( bool ) ); + for(j = 0; j < n; ++j){ + wmap[i][j] = rand() % 2; + } + } + ds ( &map, n ); island ( &imap, n ); normInt ( &imap, n ); @@ -62,8 +81,16 @@ gsname_t update(){ } void render(int w, int h){ + clock_t now, delta; int i, j; + now = clock(); + delta = now - then; + if((float)delta / (float)CLOCKS_PER_SEC >= 0.25f){ + then = now; + w_mov = TRUE; + } + for(i = 0; i < w; i++){ for(j = 0; j < h; j++){ move(j, i); @@ -71,11 +98,21 @@ void render(int w, int h){ switch(terrainType( imap[(i + (I_SIZE/4)) % I_SIZE][(j + (I_SIZE/4)) % I_SIZE] )){ case DEEP_WATER: attron(COLOR_PAIR(DW_COLOR)); - printw("\u2248"); + if(w_mov) + wmap[(i + (I_SIZE/4)) % I_SIZE][(j + (I_SIZE/4)) % I_SIZE] = !wmap[(i + (I_SIZE/4)) % I_SIZE][(j + (I_SIZE/4)) % I_SIZE]; + if(wmap[(i + (I_SIZE/4)) % I_SIZE][(j + (I_SIZE/4)) % I_SIZE]) + printw("\u2248"); + else + printw("~"); break; case SHALLOW_WATER: attron(COLOR_PAIR(SW_COLOR)); - printw("\u2248"); + if(w_mov) + wmap[(i + (I_SIZE/4)) % I_SIZE][(j + (I_SIZE/4)) % I_SIZE] = !wmap[(i + (I_SIZE/4)) % I_SIZE][(j + (I_SIZE/4)) % I_SIZE]; + if(wmap[(i + (I_SIZE/4)) % I_SIZE][(j + (I_SIZE/4)) % I_SIZE]) + printw("\u2248"); + else + printw("~"); break; case SAND: attron(COLOR_PAIR(SN_COLOR)); @@ -101,4 +138,5 @@ void render(int w, int h){ //printw("\u2588"); } } + w_mov = FALSE; } diff --git a/src/main.c b/src/main.c index 30bdfeb..471ca50 100644 --- a/src/main.c +++ b/src/main.c @@ -6,16 +6,12 @@ #include #include #include -#include #include #include #include #include -#include #include -#include #include -#include #include "constants.h" #include "game_state.h" @@ -37,7 +33,7 @@ int main() { #elif defined(__linux__) || defined(__GNUC__) char * home_dir = getenv("HOME"); #else -#error "Unrecoginized compiler." +#error "Unrecognized system." #endif FILE * f; /* To avoid a warning. */ clock_t then, now, delta; @@ -83,7 +79,6 @@ int main() { fprintf(stderr, "\tdata_dir is: %s\n", data_dir); }else{ /* The directory already exits. */ - //init_scores(data_dir); } } }else{ From fe08d66af469003bb325bc3a922c0fb0227abb86 Mon Sep 17 00:00:00 2001 From: Miguel Angel Astor Romero Date: Mon, 3 Mar 2014 21:54:15 -0430 Subject: [PATCH 08/26] Player character now moves. --- include/constants.h | 30 ++--- include/game_state.h | 8 +- src/game_state.c | 8 +- src/in_game.c | 306 ++++++++++++++++++++++++++++++------------- src/main.c | 136 +++++++++---------- 5 files changed, 303 insertions(+), 185 deletions(-) diff --git a/include/constants.h b/include/constants.h index 6d5d7a2..00ec5bb 100644 --- a/include/constants.h +++ b/include/constants.h @@ -15,21 +15,21 @@ #endif enum COLORS { - BAR_COLOR = 1, - BSC_COLOR, - HLT_COLOR, - OFF_COLOR, - DIM_COLOR, - LIT_COLOR, - GUI_COLOR, - EMP_COLOR, - DW_COLOR, - SW_COLOR, - SN_COLOR, - GR_COLOR, - FR_COLOR, - HL_COLOR, - MN_COLOR + BAR_COLOR = 1, + BSC_COLOR, + HLT_COLOR, + OFF_COLOR, + DIM_COLOR, + LIT_COLOR, + GUI_COLOR, + EMP_COLOR, + DW_COLOR, + SW_COLOR, + SN_COLOR, + GR_COLOR, + FR_COLOR, + HL_COLOR, + MN_COLOR }; #endif diff --git a/include/game_state.h b/include/game_state.h index 9fe435e..34be94d 100644 --- a/include/game_state.h +++ b/include/game_state.h @@ -11,10 +11,10 @@ static const int NUM_STATES = 4; typedef enum GAME_STATE_NAMES { INTRO = 0, MENU = 1, IN_GAME = 2, GAME_OVER = 3 } gsname_t; typedef struct GAME_STATE { - gsname_t name; - void (*input)(); - gsname_t (*update)(); - void (*render)(int, int); + gsname_t name; + void (*input)(); + gsname_t (*update)(); + void (*render)(int, int); } gs_t; extern void initStateArray(gs_t **); diff --git a/src/game_state.c b/src/game_state.c index b838173..43f9620 100644 --- a/src/game_state.c +++ b/src/game_state.c @@ -7,9 +7,9 @@ #include "in_game.h" void initStateArray(gs_t ** s){ - int i; + int i; - for(i = 0; i < NUM_STATES; i++){ - initInGameState(&((*s)[i])); - } + for(i = 0; i < NUM_STATES; i++){ + initInGameState(&((*s)[i])); + } } diff --git a/src/in_game.c b/src/in_game.c index f303431..9375aeb 100644 --- a/src/in_game.c +++ b/src/in_game.c @@ -11,132 +11,250 @@ #include "constants.h" #include "in_game.h" -static const int I_SIZE = 257; +typedef struct PLAYER { + unsigned short x; + unsigned short y; +} player_t; + +static const int I_SIZE = 513; static int ** imap; static bool ** wmap; static bool w_mov = FALSE; +static bool uK, dK, lK, rK; static clock_t then; +static player_t player; void input(); gsname_t update(); void render(int, int); +void drawGui(int, int); +void setPlayerStart(); void initInGameState( gs_t * gs) { - int n, i, j; - float ** map; + int n, i, j; + float ** map; - gs->name = IN_GAME; - gs->input = &input; - gs->update = &update; - gs->render = &render; + gs->name = IN_GAME; + gs->input = &input; + gs->update = &update; + gs->render = &render; - n = I_SIZE; + n = I_SIZE; - srand(time(NULL)); + srand(time(NULL)); - map = ( float ** ) malloc ( sizeof ( float * ) * n); - for ( i = 0; i < n; ++i ) { - map[ i ] = ( float * ) calloc ( n, sizeof ( float ) ); - } + map = ( float ** ) malloc ( sizeof ( float * ) * n); + for ( i = 0; i < n; ++i ) { + map[ i ] = ( float * ) calloc ( n, sizeof ( float ) ); + } - imap = ( int ** ) malloc ( sizeof ( int * ) * n); - for ( i = 0; i < n; ++i ) { - imap[ i ] = ( int * ) calloc ( n, sizeof ( int ) ); - } + imap = ( int ** ) malloc ( sizeof ( int * ) * n); + for ( i = 0; i < n; ++i ) { + imap[ i ] = ( int * ) calloc ( n, sizeof ( int ) ); + } - wmap = ( bool ** ) malloc ( sizeof ( bool * ) * n); - for ( i = 0; i < n; ++i ) { - wmap[ i ] = ( bool * ) calloc ( n, sizeof ( bool ) ); - for(j = 0; j < n; ++j){ - wmap[i][j] = rand() % 2; - } - } + wmap = ( bool ** ) malloc ( sizeof ( bool * ) * n); + for ( i = 0; i < n; ++i ) { + wmap[ i ] = ( bool * ) calloc ( n, sizeof ( bool ) ); + for(j = 0; j < n; ++j){ + wmap[i][j] = rand() % 2; + } + } - ds ( &map, n ); - island ( &imap, n ); - normInt ( &imap, n ); - norm ( &map, n ); - mult ( &map, &imap, n ); - smooth( &imap, n ); - normInt ( &imap, n ); + ds ( &map, n ); + island ( &imap, n ); + normInt ( &imap, n ); + norm ( &map, n ); + mult ( &map, &imap, n ); + smooth( &imap, n ); + normInt ( &imap, n ); - for ( i = 0; i < n; ++i ) { - free(map[ i ]); - } - free(map); + for ( i = 0; i < n; ++i ) { + free(map[ i ]); + } + free(map); + + setPlayerStart(); + uK = dK = lK = rK = FALSE; } void input(){ - int key = 0; + int key = 0; - key = getch(); + key = getch(); - if(key != ERR){ - fprintf(stderr, "\t%s: Caught keycode %d\n", __FILE__, key); - } + if(key != ERR){ + fprintf(stderr, "\t%s: Caught keycode %d\n", __FILE__, key); + if(key == KEY_UP) uK = TRUE; + if(key == KEY_DOWN) dK = TRUE; + if(key == KEY_LEFT) lK = TRUE; + if(key == KEY_RIGHT) rK = TRUE; + } } gsname_t update(){ - return IN_GAME; + if(uK){ + if(terrainType( imap[player.x][player.y - 1] ) != DEEP_WATER && terrainType( imap[player.x][player.y - 1] ) != MOUNTAIN) player.y -= 1; + uK = FALSE; + } + + if(dK){ + if(terrainType( imap[player.x][player.y + 1]) != DEEP_WATER && terrainType( imap[player.x][player.y + 1]) != MOUNTAIN ) player.y += 1; + dK = FALSE; + } + + if(lK){ + if(terrainType( imap[player.x - 1][player.y]) != DEEP_WATER && terrainType( imap[player.x - 1][player.y]) != MOUNTAIN) player.x -= 1; + lK = FALSE; + } + + if(rK){ + if(terrainType( imap[player.x + 1][player.y]) != DEEP_WATER && terrainType( imap[player.x + 1][player.y]) != MOUNTAIN) player.x += 1; + rK = FALSE; + } + + return IN_GAME; } void render(int w, int h){ - clock_t now, delta; - int i, j; + clock_t now, delta; + int i, j, pi, pj, ioff, joff, di, dj; - now = clock(); - delta = now - then; - if((float)delta / (float)CLOCKS_PER_SEC >= 0.25f){ - then = now; - w_mov = TRUE; - } + now = clock(); + delta = now - then; + if((float)delta / (float)CLOCKS_PER_SEC >= 0.25f){ + then = now; + w_mov = TRUE; + } - for(i = 0; i < w; i++){ - for(j = 0; j < h; j++){ - move(j, i); + pi = (((w - 1) - 27) / 2) + 27; + pj = (h - 2) / 2 + 1; - switch(terrainType( imap[(i + (I_SIZE/4)) % I_SIZE][(j + (I_SIZE/4)) % I_SIZE] )){ - case DEEP_WATER: - attron(COLOR_PAIR(DW_COLOR)); - if(w_mov) - wmap[(i + (I_SIZE/4)) % I_SIZE][(j + (I_SIZE/4)) % I_SIZE] = !wmap[(i + (I_SIZE/4)) % I_SIZE][(j + (I_SIZE/4)) % I_SIZE]; - if(wmap[(i + (I_SIZE/4)) % I_SIZE][(j + (I_SIZE/4)) % I_SIZE]) - printw("\u2248"); - else - printw("~"); - break; - case SHALLOW_WATER: - attron(COLOR_PAIR(SW_COLOR)); - if(w_mov) - wmap[(i + (I_SIZE/4)) % I_SIZE][(j + (I_SIZE/4)) % I_SIZE] = !wmap[(i + (I_SIZE/4)) % I_SIZE][(j + (I_SIZE/4)) % I_SIZE]; - if(wmap[(i + (I_SIZE/4)) % I_SIZE][(j + (I_SIZE/4)) % I_SIZE]) - printw("\u2248"); - else - printw("~"); - break; - case SAND: - attron(COLOR_PAIR(SN_COLOR)); - printw("."); - break; - case GRASS: - attron(COLOR_PAIR(GR_COLOR)); - printw("n"); - break; - case FOREST: - attron(COLOR_PAIR(FR_COLOR)); - printw("\u2660"); - break; - case HILL: - attron(COLOR_PAIR(HL_COLOR)); - printw("\u2302"); - break; - case MOUNTAIN: - attron(COLOR_PAIR(MN_COLOR)); - printw("\u25B2"); - break; - } - //printw("\u2588"); + ioff = (w - 28) / 2; + joff = (h - 2) / 2; + + for(i = 27; i < w - 1; i++){ + for(j = 1; j < h - 1; j++){ + move(j, i); + + di = i - 27 + player.x - ioff; + dj = j - 1 + player.y - joff; + + if( di < 0 || di >= I_SIZE){ + printw(" "); + }else{ + switch(terrainType( imap[di][dj] )){ + case DEEP_WATER: + attron(COLOR_PAIR(DW_COLOR)); + if(w_mov) + wmap[di][dj] = !wmap[di][dj]; + if(wmap[di][dj]) + printw("\u2248"); + else + printw("~"); + break; + case SHALLOW_WATER: + attron(COLOR_PAIR(SW_COLOR)); + if(w_mov) + wmap[di][dj] = !wmap[di][dj]; + if(wmap[di][dj]) + printw("\u2248"); + else + printw("~"); + break; + case SAND: + attron(COLOR_PAIR(SN_COLOR)); + printw("."); + break; + case GRASS: + attron(COLOR_PAIR(GR_COLOR)); + printw("n"); + break; + case FOREST: + attron(COLOR_PAIR(FR_COLOR)); + printw("\u2660"); + break; + case HILL: + attron(COLOR_PAIR(HL_COLOR)); + printw("\u2302"); + break; + case MOUNTAIN: + attron(COLOR_PAIR(MN_COLOR)); + printw("\u25B2"); + break; + } + } + } + } + w_mov = FALSE; + + move(pj, pi); + attron(COLOR_PAIR(BSC_COLOR)); + printw(/*"\u263A"*/ "@"); + + drawGui(w, h); +} + +void drawGui(int w, int h){ + int i, j; + + attron(COLOR_PAIR(BSC_COLOR)); + + /* Clear the gui space. */ + for(i = 1; i < 26; i++){ + for(j = 1; j < h - 1; j++){ + move(j, i); + printw(" "); + } + } + + /* Upper horizontal bar. */ + move(0, 0); + printw("\u2554"); + for(i = 0; i < w - 2; i++){ + if(i != 25){ + printw("\u2550"); + }else{ + printw("\u2566"); + } + } + printw("\u2557"); + + /* Lower horizontal bar. */ + move(h - 1, 0); + printw("\u255A"); + for(i = 0; i < w - 2; i++){ + if(i != 25){ + printw("\u2550"); + }else{ + printw("\u2569"); + } + } + printw("\u255D"); + + /* Vertical bars. */ + for(i = 1; i < h - 1; i++){ + move(i, 0); + printw("\u2551"); + move(i, 26); + printw("\u2551"); + move(i, w-1); + printw("\u2551"); + } +} + +void setPlayerStart(){ + int x, y; + bool posFound = false; + + while(!posFound){ + x = (I_SIZE / 4) + (rand() % (I_SIZE / 2)); + y = (I_SIZE / 4) + (rand() % (I_SIZE / 2)); + + if(terrainType(imap[x][y]) == GRASS){ + player.x = x; + player.y = y; + posFound = true; } } - w_mov = FALSE; } diff --git a/src/main.c b/src/main.c index 471ca50..648d0b1 100644 --- a/src/main.c +++ b/src/main.c @@ -29,21 +29,21 @@ static bool resize = FALSE; int main() { bool finished = FALSE; #if defined(_WIN32) || defined(_WIN64) || defined(__MINGW32__) - char * home_dir = getenv("APPDATA"); + char * home_dir = getenv("APPDATA"); #elif defined(__linux__) || defined(__GNUC__) - char * home_dir = getenv("HOME"); + char * home_dir = getenv("HOME"); #else #error "Unrecognized system." #endif - FILE * f; /* To avoid a warning. */ - clock_t then, now, delta; - unsigned int fps = 0, pfps = 0; - char * data_dir; - char * log_file; - time_t raw_date; - struct tm * current_date; - gs_t * states; - int c_state; + FILE * f; /* To avoid a warning. */ + clock_t then, now, delta; + unsigned int fps = 0, pfps = 0; + char * data_dir; + char * log_file; + time_t raw_date; + struct tm * current_date; + gs_t * states; + int c_state; atexit(leave); signal(SIGINT, manage_signal); @@ -94,52 +94,52 @@ int main() { } set_colors(); - /* Create the state data structures. */ - c_state = 2; - states = (gs_t *)malloc(sizeof(gs_t) * NUM_STATES); - initStateArray(&states); + /* Create the state data structures. */ + c_state = 2; + states = (gs_t *)malloc(sizeof(gs_t) * NUM_STATES); + initStateArray(&states); - /* Start the game loop. */ - then = clock(); + /* Start the game loop. */ + then = clock(); do{ - /* Handle terminal resize. */ - if(resize){ - endwin(); - refresh(); + /* Handle terminal resize. */ + if(resize){ + endwin(); + refresh(); - getmaxyx(stdscr, h, w); + getmaxyx(stdscr, h, w); - fprintf(stderr, "\tSIGWINCH caught. (W: %d, H: %d)\n", w, h); + fprintf(stderr, "\tSIGWINCH caught. (W: %d, H: %d)\n", w, h); - resize = FALSE; - signal(SIGWINCH, on_resize); - } + resize = FALSE; + signal(SIGWINCH, on_resize); + } - states[c_state].input(); - c_state = states[c_state].update(); + states[c_state].input(); + c_state = states[c_state].update(); - if(c_state == -1) finished = TRUE; + if(c_state == -1) finished = TRUE; - states[c_state].render(w, h); + states[c_state].render(w, h); - fps++; + fps++; - now = clock(); - delta = now - then; - if((int)delta / (int)CLOCKS_PER_SEC == 1){ - then = now; - pfps = fps; - fps = 0; - } + now = clock(); + delta = now - then; + if((int)delta / (int)CLOCKS_PER_SEC == 1){ + then = now; + pfps = fps; + fps = 0; + } - move(0, 0); - attron(COLOR_PAIR(BAR_COLOR)); - printw("FPS: %u", pfps); + move(1, 1); + attron(COLOR_PAIR(BSC_COLOR)); + printw("FPS: %u", pfps); - refresh(); - }while(!finished); + refresh(); + }while(!finished); - fclose(f); + fclose(f); return EXIT_SUCCESS; } @@ -151,7 +151,7 @@ void leave(void){ /* Finish ncurses. */ endwin(); - /* Mark the end of this run's log. */ + /* Mark the end of this run's log. */ for(i = 0; i < 80; i++) fprintf(stderr, "-"); fprintf(stderr, "\n"); @@ -162,30 +162,30 @@ void manage_signal(int signal){ switch(signal){ case SIGINT: fprintf(stderr, "\tSIGINT caught.\n"); - exit(EXIT_SUCCESS); + exit(EXIT_SUCCESS); break; case SIGSEGV: fprintf(stderr, "\tSegmentation fault.\n"); - exit(EXIT_FAILURE); - break; + exit(EXIT_FAILURE); + break; case SIGTERM: - fprintf(stderr, "\tSIGTERM caught.\n"); + fprintf(stderr, "\tSIGTERM caught.\n"); exit(EXIT_FAILURE); break; } } void on_resize(int signal){ - resize = TRUE; + resize = TRUE; } int start_ncurses(void){ WINDOW *win_ptr; int ret_code; - setlocale(LC_ALL, ""); + setlocale(LC_ALL, ""); /* Prepare the terminal. */ win_ptr = initscr(); @@ -212,9 +212,9 @@ int start_ncurses(void){ if(ret_code == ERR) return -1; - /* Set delay. */ - ret_code = nodelay(stdscr, TRUE); - if(ret_code == ERR) + /* Set delay. */ + ret_code = nodelay(stdscr, TRUE); + if(ret_code == ERR) return -1; /* Initialize the screen size variables. */ @@ -228,29 +228,29 @@ void set_colors(void){ ret_code = start_color(); if(ret_code == OK){ if(has_colors() == TRUE){ - init_color(COLOR_MAGENTA, 0, 0, 500); + init_color(COLOR_MAGENTA, 0, 0, 500); - init_pair(BAR_COLOR, COLOR_WHITE, COLOR_RED); /* The color for the top and bottom bars. */ + init_pair(BAR_COLOR, COLOR_WHITE, COLOR_RED); /* The color for the top and bottom bars. */ init_pair(BSC_COLOR, COLOR_WHITE, COLOR_BLACK); /* Basic text color. */ init_pair(HLT_COLOR, COLOR_YELLOW, COLOR_BLACK); /* Highlighted text color. */ - init_pair(OFF_COLOR, COLOR_BLUE, COLOR_BLACK); /* Lights off color. */ - init_pair(DIM_COLOR, COLOR_RED, COLOR_BLACK); /* Dim light color. */ + init_pair(OFF_COLOR, COLOR_BLUE, COLOR_BLACK); /* Lights off color. */ + init_pair(DIM_COLOR, COLOR_RED, COLOR_BLACK); /* Dim light color. */ init_pair(LIT_COLOR, COLOR_YELLOW, COLOR_BLACK); /* Lights on color. */ init_pair(GUI_COLOR, COLOR_YELLOW, COLOR_YELLOW); /* Main GUI bar color. */ init_pair(EMP_COLOR, COLOR_WHITE, COLOR_WHITE); /* Empty GUI bar color. */ - init_pair(DW_COLOR, COLOR_BLUE, COLOR_BLACK); - init_pair(SW_COLOR, COLOR_CYAN, COLOR_BLACK); - init_pair(SN_COLOR, COLOR_YELLOW, COLOR_BLACK); - init_pair(GR_COLOR, COLOR_GREEN, COLOR_BLACK); - init_pair(FR_COLOR, COLOR_GREEN, COLOR_BLACK); - init_pair(HL_COLOR, COLOR_WHITE, COLOR_BLACK); - init_pair(MN_COLOR, COLOR_WHITE, COLOR_BLACK); + init_pair(DW_COLOR, COLOR_BLUE, COLOR_BLACK); + init_pair(SW_COLOR, COLOR_CYAN, COLOR_BLACK); + init_pair(SN_COLOR, COLOR_YELLOW, COLOR_BLACK); + init_pair(GR_COLOR, COLOR_GREEN, COLOR_BLACK); + init_pair(FR_COLOR, COLOR_GREEN, COLOR_BLACK); + init_pair(HL_COLOR, COLOR_WHITE, COLOR_BLACK); + init_pair(MN_COLOR, COLOR_WHITE, COLOR_BLACK); } }else{ - fprintf(stderr, "\t%s: Colors not supported.\n", __FILE__); - exit(EXIT_FAILURE); - } + fprintf(stderr, "\t%s: Colors not supported.\n", __FILE__); + exit(EXIT_FAILURE); + } } void clear_screen(void){ From aaca6d984b8d46076a852b3e5f3d8e69e94e09d1 Mon Sep 17 00:00:00 2001 From: Miguel Angel Astor Romero Date: Tue, 4 Mar 2014 12:51:25 -0430 Subject: [PATCH 09/26] Started working on the level editor. --- editor/editor.py | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100755 editor/editor.py diff --git a/editor/editor.py b/editor/editor.py new file mode 100755 index 0000000..d6e810c --- /dev/null +++ b/editor/editor.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python + +# Copyright (c) 2014, Miguel Angel Astor Romero. All rights reserved. +# See the file LICENSE for more details. + +import pygame + +SCREEN_SIZE = (800, 600) +TITLE = "Cyberpunk Jam 2014 - Level editor" +FPS = 60 + +def main(): + # Local variables + done = False + + # Initialize Pygame and pgs4a. + pygame.init() + clock = pygame.time.Clock() + screen = pygame.display.set_mode(SCREEN_SIZE, pygame.HWSURFACE | pygame.DOUBLEBUF) + pygame.mouse.set_visible(False) + + # Main game loop. + while(not done): + try: + fps = clock.get_fps() + 0.001 + pygame.display.set_caption(TITLE + ": " + str(int(fps))) + + # Input capture. + for event in pygame.event.get(): + if (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE) or event.type == pygame.QUIT: + done = True + + # Update cycle. + + # Render cycle. + screen.fill((0, 0, 0)) + + pygame.display.update() + clock.tick(FPS) + + except KeyboardInterrupt: + done = True + + pygame.quit() + +if __name__ == "__main__": + main() From 2a0527b12bf95f814b03da9491636351b0398271 Mon Sep 17 00:00:00 2001 From: Miguel Angel Astor Romero Date: Tue, 4 Mar 2014 17:10:35 -0430 Subject: [PATCH 10/26] Basic map editor finished. --- editor/editor.py | 375 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 367 insertions(+), 8 deletions(-) diff --git a/editor/editor.py b/editor/editor.py index d6e810c..aa9f6f3 100755 --- a/editor/editor.py +++ b/editor/editor.py @@ -3,38 +3,397 @@ # Copyright (c) 2014, Miguel Angel Astor Romero. All rights reserved. # See the file LICENSE for more details. +""" +The map editor for TITLE PENDING, a game for the Cyberpunk Jam 2014. + +Usage: + *) Click on a game_map cell to set it's type. + Use the keypad numbers to change the type of cell a cell will turn into + when clicked. The active cell type is displayed on the title bar. + + *) Left click to place an object on the game_map. + Objects have to be edited by hand once the game_map has been saved. Use + the keys 'd', 'k', 'p', 'n', 'e' and 'q' to set the active object type. + The active object type is displayed on the title bar. + + *) Press 'p' to set the player's starting position. + + *) Press 's' to save the map to the text file 'map_file.map'. This will + replace any previous map with the same name! + + Press escape to quit. +""" + import pygame -SCREEN_SIZE = (800, 600) -TITLE = "Cyberpunk Jam 2014 - Level editor" -FPS = 60 +CELL_SIZE = 10 +MAP_SIZE = (64, 64) +SCREEN_SIZE = ((MAP_SIZE[1] * CELL_SIZE) + 1, (MAP_SIZE[0] * CELL_SIZE) + 1) +SCREEN_FLAGS = pygame.HWSURFACE | pygame.DOUBLEBUF +TITLE = "Cyberpunk Jam 2014 - Level editor" +FPS = 60 + +# Cell types +VOID = 0 +SOLID_WALL = 1 +SECRET_WALL = 2 +CLEAR_WALL = 3 +NEON_WALL = 4 +WINDOW_WALL = 5 +EMPTY_FLOOR = 6 +RUG = 7 +WATER = 8 +BAR = 9 + +# Object types +DOOR = 0 +KEY = 1 +PERSON = 2 +PLAYER = 3 +EXIT = 4 + +def get_object_type_name(game_object): + """ Return a string name for an object type. """ + name = "" + if game_object == DOOR: + name = "DOOR" + elif game_object == KEY: + name = "KEY" + elif game_object == PERSON: + name = "PERSON" + elif game_object == PLAYER: + name = "PLAYER" + elif game_object == EXIT: + name = "EXIT" + elif game_object == None: + name = "NONE" + else: + raise ValueError("Invalid object type.") + + return name + +def get_object_type_color(game_object): + """ Return a string name for an object type. """ + color = (0, 0, 0) + if game_object == DOOR: + color = (255, 0, 255) + elif game_object == KEY: + color = (255, 255, 0) + elif game_object == PERSON: + color = (0, 255, 255) + elif game_object == PLAYER: + color = (128, 255, 0) + elif game_object == EXIT: + color = (255, 0, 255) + else: + raise ValueError("Invalid object type.") + + return color + +def get_floor_type_name(floor_type): + """ Return a string name for a floor type. """ + name = "" + + if floor_type == VOID: + name = "VOID" + elif floor_type == SOLID_WALL: + name = "SOLID WALL" + elif floor_type == SECRET_WALL: + name = "SECRET WALL" + elif floor_type == CLEAR_WALL: + name = "CLEAR WALL" + elif floor_type == NEON_WALL: + name = "NEON WALL" + elif floor_type == WINDOW_WALL: + name = "WINDOW" + elif floor_type == EMPTY_FLOOR: + name = "EMPTY FLOOR" + elif floor_type == RUG: + name = "RUG" + elif floor_type == WATER: + name = "WATER" + elif floor_type == BAR: + name = "BAR" + else: + raise ValueError("Invalid floor type.") + + return name + +def get_floor_type_color(floor_type): + """ Return a string name for a floor type. """ + color = (0, 0, 0) + + if floor_type == VOID: + color = (0, 0, 0) + elif floor_type == SOLID_WALL: + color = (255, 255, 255) + elif floor_type == SECRET_WALL: + color = (128, 128, 128) + elif floor_type == CLEAR_WALL: + color = (50, 50, 50) + elif floor_type == NEON_WALL: + color = (255, 0, 0) + elif floor_type == WINDOW_WALL: + color = (128, 128, 255) + elif floor_type == EMPTY_FLOOR: + color = (128, 128, 0) + elif floor_type == RUG: + color = (128, 0, 128) + elif floor_type == WATER: + color = (64, 64, 255) + elif floor_type == BAR: + color = (255, 255, 0) + else: + raise ValueError("Invalid floor type.") + + return color + +def save_map(game_map): + p_id = 0 + dialogs = list() + f = open("map_file.map", "w") + + f.write("[MAP]\n") + f.write(str(MAP_SIZE [0]) + " " + str(MAP_SIZE[1]) + "\n") + for i in range(0, MAP_SIZE[0]): + for j in range(0, MAP_SIZE[1]): + f_t = game_map[i][j].get_type(); + f.write(str(f_t)) + f.write("\n") + + f.write("[PLAYER]\n") + f.write("%player = X Y\n") + for i in range(0, MAP_SIZE[0]): + for j in range(0, MAP_SIZE[1]): + o_t = game_map[i][j].get_object(); + if o_t is not None and o_t == PLAYER: + f.write("player = " + str(i) + " " + str(j) + "\n") + + f.write("[EXITS]\n") + f.write("%exit = X Y MAP_NAME MAP_X MAP_Y\n") + for i in range(0, MAP_SIZE[0]): + for j in range(0, MAP_SIZE[1]): + o_t = game_map[i][j].get_object(); + if o_t is not None and o_t == EXIT: + f.write("exit = " + str(i) + " " + str(j)) + f.write(" map_file.map 0 0\n") + + f.write("[DOORS]\n") + f.write("%door = X Y ID UNLOCKED\n") + for i in range(0, MAP_SIZE[0]): + for j in range(0, MAP_SIZE[1]): + o_t = game_map[i][j].get_object(); + if o_t is not None and o_t == DOOR: + f.write("door = " + str(i) + " " + str(j) + " 0" + " 0\n") + + f.write("[KEYS]\n") + f.write("%key = X Y ID\n") + for i in range(0, MAP_SIZE[0]): + for j in range(0, MAP_SIZE[1]): + o_t = game_map[i][j].get_object(); + if o_t is not None and o_t == KEY: + f.write("key = " + str(i) + " " + str(j) + " 0\n") + + f.write("[PERSONS]\n") + f.write("%person = X Y NAME DIALOG_ID\n") + for i in range(0, MAP_SIZE[0]): + for j in range(0, MAP_SIZE[1]): + o_t = game_map[i][j].get_object(); + if o_t is not None and o_t == PERSON: + f.write("person = " + str(i) + " " + str(j)) + f.write(" SOMEONE " + str(p_id) + "\n") + dialogs.append(p_id) + p_id += 1 + + f.write("[DIALOGS]\n") + f.write("%dialog = ID TEXT\n") + for id in dialogs: + text = " Heavy boxes perform quick waltzes and jigs.\n" + f.write("dialog = " + str(id) + text) + + f.close() + +class Cell: + """ A game_map cell. """ + def __init__(self, x_size, y_size): + """ Create a new cell. """ + self.x_size = x_size + self.y_size = y_size + + self.floor_type = VOID + self.game_object = None + + # Create the drawing rectangles. + self.border = pygame.Rect((0, 0), (CELL_SIZE, CELL_SIZE)) + self.cell = pygame.Rect((0, 0), (CELL_SIZE - 2, CELL_SIZE - 2)) + + def set_type(self, floor_type): + """ Set this cell floor type. Raises a value error if the type is + not valid. """ + if floor_type < VOID or floor_type > BAR: + raise ValueError("Floor type must be a number between 0 and 9.") + else: + self.floor_type = floor_type + + def get_type(self): + """ Returns this cell's type. """ + return self.floor_type + + def set_object(self, game_object): + """ Set this cells object. """ + if game_object is not None and game_object < DOOR or game_object > EXIT: + raise ValueError("Object type must be a number between 0 and 2.") + else: + self.game_object = game_object + + def get_object(self): + """ Return this cell's object. """ + return self.game_object + + def draw(self, canvas, x_pos, y_pos): + """ Render this cell at the given position on the given screen. """ + self.border.center = (x_pos, y_pos) + self.cell.center = (x_pos, y_pos) + pygame.draw.rect(canvas, (0, 0, 255), self.border) + + color = get_floor_type_color(self.floor_type) + pygame.draw.rect(canvas, color, self.cell) + + if self.game_object is not None and self.game_object < PLAYER: + r = (CELL_SIZE - 2) // 2 + color = get_object_type_color(self.game_object) + pygame.draw.circle(canvas, color, (x_pos, y_pos), r, 1) + elif self.game_object is not None and self.game_object >= PLAYER: + r = (CELL_SIZE - 3) // 2 + color = get_object_type_color(self.game_object) + pygame.draw.circle(canvas, color, (x_pos, y_pos), r, 0) def main(): + """ Application entry point. """ # Local variables done = False + game_map = list() + curr_obj = None + curr_fl = VOID + obj_str = "" + fl_str = "" + mouse_pos = (0, 0) + mouse_r_click = False + mouse_l_click = False - # Initialize Pygame and pgs4a. + # Initialize Pygame. pygame.init() clock = pygame.time.Clock() - screen = pygame.display.set_mode(SCREEN_SIZE, pygame.HWSURFACE | pygame.DOUBLEBUF) - pygame.mouse.set_visible(False) + screen = pygame.display.set_mode(SCREEN_SIZE, SCREEN_FLAGS) + pygame.mouse.set_visible(True) + + for i in range(0, MAP_SIZE[0]): + game_map.append([Cell(10, 10) for j in range(0, MAP_SIZE[1])]) # Main game loop. while(not done): try: fps = clock.get_fps() + 0.001 - pygame.display.set_caption(TITLE + ": " + str(int(fps))) + + # Set title bar. + obj_str = get_object_type_name(curr_obj) + fl_str = get_floor_type_name(curr_fl) + title = TITLE + " :: FPS: " + str(int(fps)) + title += " :: " + obj_str + " :: " + fl_str + pygame.display.set_caption(title) # Input capture. for event in pygame.event.get(): - if (event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE) or event.type == pygame.QUIT: + if event.type == pygame.QUIT: + done = True + + if event.type == pygame.MOUSEBUTTONDOWN: + mouse_pos = event.pos + if event.button == 1: + mouse_r_click = True + elif event.button == 3: + mouse_l_click = True + + if event.type == pygame.MOUSEMOTION: + if mouse_r_click: + mouse_pos = event.pos + + if event.type == pygame.MOUSEBUTTONUP: + mouse_pos = event.pos + if event.button == 1: + mouse_r_click = False + elif event.button == 3: + mouse_l_click = False + + if event.type == pygame.KEYDOWN: + if event.key == pygame.K_ESCAPE: done = True + if event.key == pygame.K_d: + curr_obj = DOOR + if event.key == pygame.K_k: + curr_obj = KEY + if event.key == pygame.K_p: + curr_obj = PERSON + if event.key == pygame.K_q: + curr_obj = PLAYER + if event.key == pygame.K_e: + curr_obj = EXIT + if event.key == pygame.K_n: + curr_obj = None + + if event.key == pygame.K_0: + curr_fl = VOID + if event.key == pygame.K_1: + curr_fl = SOLID_WALL + if event.key == pygame.K_2: + curr_fl = SECRET_WALL + if event.key == pygame.K_3: + curr_fl = CLEAR_WALL + if event.key == pygame.K_4: + curr_fl = NEON_WALL + if event.key == pygame.K_5: + curr_fl = WINDOW_WALL + if event.key == pygame.K_6: + curr_fl = EMPTY_FLOOR + if event.key == pygame.K_7: + curr_fl = RUG + if event.key == pygame.K_8: + curr_fl = WATER + if event.key == pygame.K_9: + curr_fl = BAR + + if event.key == pygame.K_s: + save_map(game_map) + # Update cycle. + if mouse_r_click: + i = mouse_pos[1] // CELL_SIZE + j = mouse_pos[0] // CELL_SIZE + if i >= MAP_SIZE[0]: + i = MAP_SIZE[0] - 1 + if j >= MAP_SIZE[1]: + j = MAP_SIZE[1] - 1 + game_map[i][j].set_type(curr_fl) + + if mouse_l_click: + i = mouse_pos[1] // CELL_SIZE + j = mouse_pos[0] // CELL_SIZE + if i >= MAP_SIZE[0]: + i = MAP_SIZE[0] - 1 + if j >= MAP_SIZE[1]: + j = MAP_SIZE[1] - 1 + game_map[i][j].set_object(curr_obj) # Render cycle. screen.fill((0, 0, 0)) + for i in range(0, MAP_SIZE[0]): + for j in range(0, MAP_SIZE[1]): + x = (j * CELL_SIZE) + (CELL_SIZE // 2) + y = (i * CELL_SIZE) + (CELL_SIZE // 2) + game_map[i][j].draw(screen, x, y) + pygame.display.update() clock.tick(FPS) From 04621deb256c38471b77d557a850bf2db00803d0 Mon Sep 17 00:00:00 2001 From: Miguel Angel Astor Romero Date: Wed, 5 Mar 2014 20:54:24 -0430 Subject: [PATCH 11/26] Map reader done. --- Makefile | 9 +++-- editor/editor.py | 6 ++-- include/map.h | 47 +++++++++++++++++++++++++ src/in_game.c | 34 +++++++++++++----- src/map.c | 92 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 174 insertions(+), 14 deletions(-) create mode 100644 include/map.h create mode 100644 src/map.c diff --git a/Makefile b/Makefile index ff64137..915c81d 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ CC = gcc -SOURCES = src/main.c src/game_state.c src/in_game.c -OBJECTS = obj/main.o obj/game_state.o obj/in_game.o +SOURCES = src/main.c src/game_state.c src/in_game.c src/map.c +OBJECTS = obj/main.o obj/game_state.o obj/in_game.o obj/map.o TARGET = bin/cyjam CFLAGS = -Wall -I./include -std=c99 LDFLAGS = -L./lib @@ -21,7 +21,10 @@ obj/main.o: src/main.c include/constants.h include/game_state.h obj/game_state.o: src/game_state.c include/game_state.h include/in_game.h $(CC) -c -o $@ $< $(CFLAGS) -obj/in_game.o: src/in_game.c include/in_game.h include/game_state.h +obj/in_game.o: src/in_game.c include/in_game.h include/game_state.h include/map.h + $(CC) -c -o $@ $< $(CFLAGS) + +obj/map.o: src/map.c include/map.h $(CC) -c -o $@ $< $(CFLAGS) clean: diff --git a/editor/editor.py b/editor/editor.py index aa9f6f3..6d691df 100755 --- a/editor/editor.py +++ b/editor/editor.py @@ -13,10 +13,10 @@ Usage: *) Left click to place an object on the game_map. Objects have to be edited by hand once the game_map has been saved. Use - the keys 'd', 'k', 'p', 'n', 'e' and 'q' to set the active object type. - The active object type is displayed on the title bar. + the keys 'd', 'k', 'p', 'n' and 'e' to set the active object type. The + active object type is displayed on the title bar. - *) Press 'p' to set the player's starting position. + *) Press 'q' to set the player's starting position. *) Press 's' to save the map to the text file 'map_file.map'. This will replace any previous map with the same name! diff --git a/include/map.h b/include/map.h new file mode 100644 index 0000000..a38a962 --- /dev/null +++ b/include/map.h @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2014, Miguel Angel Astor Romero. All rights reserved. + * See the file LICENSE for more details. + */ + +#ifndef MAP_H +#define MAP_H + +static const int MAX_MAP_SIZE = 64; + +typedef enum FLOOR_TYPES { + VOID = 0, + SOLID_WALL, + SECRET_WALL, + CLEAR_WALL, + NEON_WALL, + WINDOW_WALL, + EMPTY_FLOOR, + RUG, + WATER, + BAR + } floor_t; + +typedef enum OBJECT_TYPES { + DOOR = 0, + KEY, + PERSON, + PLAYER_START, + EXIT, + NONE = 9989 + } obj_t; + +typedef enum ERROR_CODES { + NO_ERROR = 0, + FILE_NOT_FOUND, + OUT_OF_MEMORY, + PREMATURE_EOF, + MAP_TOO_LARGE + } errcode_t; + +typedef struct MAP_CELL{ + floor_t f; +} map_cell_t; + +extern errcode_t readMapData(const char *, map_cell_t ***, int *, int *); + +#endif diff --git a/src/in_game.c b/src/in_game.c index 9375aeb..32b10b9 100644 --- a/src/in_game.c +++ b/src/in_game.c @@ -10,6 +10,7 @@ #include "constants.h" #include "in_game.h" +#include "map.h" typedef struct PLAYER { unsigned short x; @@ -23,6 +24,8 @@ static bool w_mov = FALSE; static bool uK, dK, lK, rK; static clock_t then; static player_t player; +static map_cell_t ** map; +static int mW, mH; void input(); gsname_t update(); @@ -32,7 +35,7 @@ void setPlayerStart(); void initInGameState( gs_t * gs) { int n, i, j; - float ** map; + float ** fmap; gs->name = IN_GAME; gs->input = &input; @@ -43,9 +46,9 @@ void initInGameState( gs_t * gs) { srand(time(NULL)); - map = ( float ** ) malloc ( sizeof ( float * ) * n); + fmap = ( float ** ) malloc ( sizeof ( float * ) * n); for ( i = 0; i < n; ++i ) { - map[ i ] = ( float * ) calloc ( n, sizeof ( float ) ); + fmap[ i ] = ( float * ) calloc ( n, sizeof ( float ) ); } imap = ( int ** ) malloc ( sizeof ( int * ) * n); @@ -61,21 +64,36 @@ void initInGameState( gs_t * gs) { } } - ds ( &map, n ); + ds ( &fmap, n ); island ( &imap, n ); normInt ( &imap, n ); - norm ( &map, n ); - mult ( &map, &imap, n ); + norm ( &fmap, n ); + mult ( &fmap, &imap, n ); smooth( &imap, n ); normInt ( &imap, n ); for ( i = 0; i < n; ++i ) { - free(map[ i ]); + free(fmap[ i ]); } - free(map); + free(fmap); setPlayerStart(); uK = dK = lK = rK = FALSE; + + /*map = ( map_cell_t ** ) malloc ( sizeof ( map_cell_t * ) * 32); + for ( i = 0; i < 32; ++i ) { + map[ i ] = ( map_cell_t * ) calloc ( 32 , sizeof ( map_cell_t ) ); + } + + errcode_t rc = readMapData("map_file.map", &map, &mW, &mH); + + fprintf(stderr, "\t%s: readMapData() returned %d\n", __FILE__, rc); + fprintf(stderr, "\t%s: Map size is (%d, %d).\n", __FILE__, mW, mH); + + for ( i = 0; i < 32; ++i ) { + free(map[ i ]); + } + free(map);*/ } void input(){ diff --git a/src/map.c b/src/map.c new file mode 100644 index 0000000..38a46ba --- /dev/null +++ b/src/map.c @@ -0,0 +1,92 @@ +/** + * Copyright (c) 2014, Miguel Angel Astor Romero. All rights reserved. + * See the file LICENSE for more details. + */ +#define _GNU_SOURCE +#include +#include +#include + +#include "map.h" + +errcode_t readMapData(const char * file, map_cell_t *** map, int * w, int * h){ + char *buffer; + FILE * f; + size_t n = 2048; + + f = fopen(file, "r"); + if(f == NULL) return FILE_NOT_FOUND; + + buffer = (char*)calloc(n + 1, sizeof(char)); + if(buffer == NULL) return OUT_OF_MEMORY; + + while(getline(&buffer, &n, f) != -1){ + if(strcmp(buffer, "[MAP]\n") == 0){ + int rc, i, j; + char *end; + + fprintf(stderr, "\t%s.readMapData() : found a map.\n", __FILE__); + + rc = getline(&buffer, &n, f); + if(rc == -1){ + free(buffer); + return PREMATURE_EOF; + } + + *w = strtol(buffer, &end, 10); + *h = strtol(end, NULL, 10); + + if((*w <= 0 || *w > MAX_MAP_SIZE) || (*h <= 0 || *h > MAX_MAP_SIZE)){ + *w = -1; + *h = -1; + free(buffer); + return MAP_TOO_LARGE; + } + + for(i = 0; i < *w; i++){ + rc = getline(&buffer, &n, f); + if(rc == -1){ + free(buffer); + return PREMATURE_EOF; + } + + /* Skip commentaries. */ + if(buffer[0] == '%'){ + i--; + continue; + } + + for(j = 0; buffer[j] && j < *h; j++){ + if(buffer[j] >= '0' && buffer[j] <= '9'){ + switch(buffer[j]){ + case '0': (*map)[i][j].f = VOID; break; + case '1': (*map)[i][j].f = SOLID_WALL; break; + case '2': (*map)[i][j].f = SECRET_WALL; break; + case '3': (*map)[i][j].f = CLEAR_WALL; break; + case '4': (*map)[i][j].f = NEON_WALL; break; + case '5': (*map)[i][j].f = WINDOW_WALL; break; + case '6': (*map)[i][j].f = EMPTY_FLOOR; break; + case '7': (*map)[i][j].f = RUG; break; + case '8': (*map)[i][j].f = WATER; break; + case '9': (*map)[i][j].f = BAR; break; + default: + fprintf(stderr, "\t%s.readMapData() : Invalid character %c in map file %s\n", __FILE__, buffer[j], file); + (*map)[i][j].f = VOID; + break; + } + }else{ + fprintf(stderr, "\t%s.readMapData() : Invalid character %c in map file %s\n", __FILE__, buffer[j], file); + (*map)[i][j].f = VOID; + } + } + } + /* Skip the rest of the file. */ + break; + } + } + + fclose(f); + free(buffer); + + return NO_ERROR; +} From 55e707c1cec875581581216df4dcc8417dd5c18a Mon Sep 17 00:00:00 2001 From: Miguel Angel Astor Romero Date: Thu, 6 Mar 2014 01:58:49 -0430 Subject: [PATCH 12/26] Map file correctly loaded. --- include/map.h | 20 +++- src/in_game.c | 43 +++++++- src/map.c | 280 +++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 339 insertions(+), 4 deletions(-) diff --git a/include/map.h b/include/map.h index a38a962..d4223d0 100644 --- a/include/map.h +++ b/include/map.h @@ -6,7 +6,9 @@ #ifndef MAP_H #define MAP_H -static const int MAX_MAP_SIZE = 64; +#define MAX_MAP_SIZE 64 +#define MAX_OBJECTS 512 +#define MAX_STR 128 typedef enum FLOOR_TYPES { VOID = 0, @@ -27,6 +29,7 @@ typedef enum OBJECT_TYPES { PERSON, PLAYER_START, EXIT, + DIALOG, NONE = 9989 } obj_t; @@ -35,13 +38,26 @@ typedef enum ERROR_CODES { FILE_NOT_FOUND, OUT_OF_MEMORY, PREMATURE_EOF, - MAP_TOO_LARGE + MAP_TOO_LARGE, + INVALID_KEY } errcode_t; typedef struct MAP_CELL{ floor_t f; } map_cell_t; +typedef struct OBJECT { + obj_t type; + short x, y, eX, eY, sX, sY; + short id; + short dId; + char name[MAX_STR]; + char target[MAX_STR]; + char dialog[MAX_STR]; + unsigned char unlocked; +} game_obj_t; + extern errcode_t readMapData(const char *, map_cell_t ***, int *, int *); +extern errcode_t readMapObjects(const char *, game_obj_t **, int *); #endif diff --git a/src/in_game.c b/src/in_game.c index 32b10b9..3c63c2a 100644 --- a/src/in_game.c +++ b/src/in_game.c @@ -25,13 +25,15 @@ static bool uK, dK, lK, rK; static clock_t then; static player_t player; static map_cell_t ** map; -static int mW, mH; +game_obj_t objs[MAX_OBJECTS]; +static int mW, mH, nO; void input(); gsname_t update(); void render(int, int); void drawGui(int, int); void setPlayerStart(); +void initObjects(); void initInGameState( gs_t * gs) { int n, i, j; @@ -85,11 +87,30 @@ void initInGameState( gs_t * gs) { map[ i ] = ( map_cell_t * ) calloc ( 32 , sizeof ( map_cell_t ) ); } + initObjects(); + errcode_t rc = readMapData("map_file.map", &map, &mW, &mH); fprintf(stderr, "\t%s: readMapData() returned %d\n", __FILE__, rc); fprintf(stderr, "\t%s: Map size is (%d, %d).\n", __FILE__, mW, mH); + game_obj_t * objsP = objs; + rc = readMapObjects("map_file.map", &objsP, &nO); + fprintf(stderr, "\t%s: readMapObjects() returned %d\n", __FILE__, rc); + fprintf(stderr, "\t%s: Number of objects is %d.\n", __FILE__, nO); + + for(i = 0; i < nO; i++){ + fprintf(stderr, "\t%s: Object %d\n", __FILE__, i); + fprintf(stderr, "\t\t Type %d\n", (int)objs[i].type); + fprintf(stderr, "\t\t x: %d -- y: %d -- eX: %d -- eY: %d -- sX: %d -- sY: %d\n", objs[i].x, objs[i].x, objs[i].eX, objs[i].eY, objs[i].sX, objs[i].sY); + fprintf(stderr, "\t\t iD: %d -- dId %d\n", objs[i].id, objs[i].dId); + fprintf(stderr, "\t\t name: %s\n", objs[i].name); + fprintf(stderr, "\t\t target: %s\n", objs[i].target); + fprintf(stderr, "\t\t dialog: %s\n", objs[i].dialog); + fprintf(stderr, "\t\t unlocked: %d\n", objs[i].unlocked); + fprintf(stderr, "\n"); + } + for ( i = 0; i < 32; ++i ) { free(map[ i ]); } @@ -276,3 +297,23 @@ void setPlayerStart(){ } } } + +void initObjects(){ + int i; + + for(i = 0; i < MAX_OBJECTS; ++i){ + objs[i].type = NONE; + objs[i].x = 0; + objs[i].y = 0; + objs[i].eX = 0; + objs[i].eY = 0; + objs[i].sX = 0; + objs[i].sY = 0; + objs[i].id = 0; + objs[i].dId = 0; + objs[i].name[0] = '\0'; + objs[i].target[0] = '\0'; + objs[i].dialog[0] = '\0'; + objs[i].unlocked = 0; + } +} diff --git a/src/map.c b/src/map.c index 38a46ba..df52593 100644 --- a/src/map.c +++ b/src/map.c @@ -2,6 +2,7 @@ * Copyright (c) 2014, Miguel Angel Astor Romero. All rights reserved. * See the file LICENSE for more details. */ + #define _GNU_SOURCE #include #include @@ -10,9 +11,9 @@ #include "map.h" errcode_t readMapData(const char * file, map_cell_t *** map, int * w, int * h){ + size_t n = 2048; char *buffer; FILE * f; - size_t n = 2048; f = fopen(file, "r"); if(f == NULL) return FILE_NOT_FOUND; @@ -90,3 +91,280 @@ errcode_t readMapData(const char * file, map_cell_t *** map, int * w, int * h){ return NO_ERROR; } + +errcode_t readMapObjects(const char * file, game_obj_t ** objArr, int *nObj){ + size_t n = 2048; + int rc; + char *buffer; + FILE * f; + + *nObj = 0; + + f = fopen(file, "r"); + if(f == NULL) return FILE_NOT_FOUND; + + buffer = (char*)calloc(n + 1, sizeof(char)); + if(buffer == NULL) return OUT_OF_MEMORY; + + rc = getline(&buffer, &n, f); + if(rc == -1){ + free(buffer); + return PREMATURE_EOF; + } + + while(*nObj < MAX_OBJECTS && rc != -1){ + if(buffer[0] == '%') continue; + + if(strcmp(buffer, "[MAP]\n") == 0){ + int i, w; + + rc = getline(&buffer, &n, f); + if(rc == -1){ + free(buffer); + return PREMATURE_EOF; + } + + w = strtol(buffer, NULL, 10); + + for(i = 0; i <= w; ++i){ + rc = getline(&buffer, &n, f); + if(rc == -1){ + free(buffer); + return PREMATURE_EOF; + } + } + + }else if(strcmp(buffer, "[PLAYER]\n") == 0){ + do{ + rc = getline(&buffer, &n, f); + if(rc == -1) break; + + if(buffer[0] == '%') continue; + else if(buffer[0] == 'p'){ + int i; + + for(i = 0; buffer[i] && buffer[i] != '='; ++i); + + if(strncmp(buffer, "player =", i) == 0){ + int sX, sY; + char *end; + + sX = strtol(&buffer[i + 1], &end, 10); + sY = strtol(end, NULL, 10); + + (*objArr)[*nObj].type = PLAYER_START; + (*objArr)[*nObj].sX = sX; + (*objArr)[*nObj].sY = sY; + + *nObj += 1; + + }else{ + fprintf(stderr, "\t%s.readMapObjects(): Skipped invalid data in PLAYER key in map file %s.\n", __FILE__, file); + fprintf(stderr, "\t%s.readMapObjects(): The invalid line is %s.\n", __FILE__, buffer); + continue; + } + } + }while(buffer[0] != '['); + + }else if(strcmp(buffer, "[EXITS]\n") == 0){ + do{ + rc = getline(&buffer, &n, f); + if(rc == -1) break; + + if(buffer[0] == '%') continue; + else if(buffer[0] == 'e'){ + int i; + + for(i = 0; buffer[i] && buffer[i] != '='; ++i); + + if(strncmp(buffer, "exit =", i) == 0){ + int x, y, eX, eY; + char *end, *end2, *end3; + + x = strtol(&buffer[i + 1], &end, 10); + y = strtol(end, &end2, 10); + end2++; + + (*objArr)[*nObj].type = EXIT; + (*objArr)[*nObj].x = x; + (*objArr)[*nObj].y = y; + + for(i = 0; end2[i] && end2[i] != ' '; ++i); + + strncpy((*objArr)[*nObj].target, end2, i); + (*objArr)[*nObj].target[i] = '\0'; + + eX = strtol(&end2[i], &end3, 10); + eY = strtol(end3, NULL, 10); + + (*objArr)[*nObj].eX = eX; + (*objArr)[*nObj].eY = eY; + + *nObj += 1; + + }else{ + fprintf(stderr, "\t%s.readMapObjects(): Skipped invalid data in EXITS key in map file %s.\n", __FILE__, file); + fprintf(stderr, "\t%s.readMapObjects(): The invalid line is %s.\n", __FILE__, buffer); + continue; + } + } + }while(buffer[0] != '['); + + }else if(strcmp(buffer, "[DOORS]\n") == 0){ + do{ + rc = getline(&buffer, &n, f); + if(rc == -1) break; + + if(buffer[0] == '%') continue; + else if(buffer[0] == 'd'){ + int i; + + for(i = 0; buffer[i] && buffer[i] != '='; ++i); + + if(strncmp(buffer, "door =", i) == 0){ + int dX, dY, dId, un; + char *end, *end2, *end3; + + dX = strtol(&buffer[i + 1], &end, 10); + dY = strtol(end, &end2, 10); + dId = strtol(end2, &end3, 10); + un = strtol(end3, NULL, 10); + + (*objArr)[*nObj].type = DOOR; + (*objArr)[*nObj].x = dX; + (*objArr)[*nObj].y = dY; + (*objArr)[*nObj].id = dId; + (*objArr)[*nObj].unlocked = un; + + *nObj += 1; + + }else{ + fprintf(stderr, "\t%s.readMapObjects(): Skipped invalid data in DOORS key in map file %s.\n", __FILE__, file); + fprintf(stderr, "\t%s.readMapObjects(): The invalid line is %s.\n", __FILE__, buffer); + continue; + } + } + }while(buffer[0] != '['); + + }else if(strcmp(buffer, "[KEYS]\n") == 0){ + do{ + rc = getline(&buffer, &n, f); + if(rc == -1) break; + + if(buffer[0] == '%') continue; + else if(buffer[0] == 'k'){ + int i; + + for(i = 0; buffer[i] && buffer[i] != '='; ++i); + + if(strncmp(buffer, "key =", i) == 0){ + int kX, kY, kId; + char *end, *end2; + + kX = strtol(&buffer[i + 1], &end, 10); + kY = strtol(end, &end2, 10); + kId = strtol(end2, NULL, 10); + + (*objArr)[*nObj].type = KEY; + (*objArr)[*nObj].x = kX; + (*objArr)[*nObj].y = kY; + (*objArr)[*nObj].id = kId; + + *nObj += 1; + + }else{ + fprintf(stderr, "\t%s.readMapObjects(): Skipped invalid data in KEYS key in map file %s.\n", __FILE__, file); + fprintf(stderr, "\t%s.readMapObjects(): The invalid line is %s.\n", __FILE__, buffer); + continue; + } + } + }while(buffer[0] != '['); + + }else if(strcmp(buffer, "[PERSONS]\n") == 0){ + do{ + rc = getline(&buffer, &n, f); + if(rc == -1) break; + + if(buffer[0] == '%') continue; + else if(buffer[0] == 'p'){ + int i; + + for(i = 0; buffer[i] && buffer[i] != '='; ++i); + + if(strncmp(buffer, "person =", i) == 0){ + int pX, pY, pDId; + char *end, *end2; + + pX = strtol(&buffer[i + 1], &end, 10); + pY = strtol(end, &end2, 10); + end2++; + + (*objArr)[*nObj].type = PERSON; + (*objArr)[*nObj].x = pX; + (*objArr)[*nObj].y = pY; + + for(i = 0; end2[i] && end2[i] != ' '; ++i); + + strncpy((*objArr)[*nObj].name, end2, i); + (*objArr)[*nObj].name[i] = '\0'; + + pDId = strtol(&end2[i], NULL, 10); + (*objArr)[*nObj].dId = pDId; + + *nObj += 1; + + }else{ + fprintf(stderr, "\t%s.readMapObjects(): Skipped invalid data in PERSONS key in map file %s.\n", __FILE__, file); + fprintf(stderr, "\t%s.readMapObjects(): The invalid line is %s.\n", __FILE__, buffer); + continue; + } + } + }while(buffer[0] != '['); + + }else if(strcmp(buffer, "[DIALOGS]\n") == 0){ + do{ + rc = getline(&buffer, &n, f); + if(rc == -1) break; + + if(buffer[0] == '%') continue; + else if(buffer[0] == 'd'){ + int i; + + for(i = 0; buffer[i] && buffer[i] != '='; ++i); + + if(strncmp(buffer, "dialog =", i) == 0){ + int dId; + char *end; + + dId = strtol(&buffer[i + 1], &end, 10); + end++; + + (*objArr)[*nObj].type = DIALOG; + (*objArr)[*nObj].id = dId; + + strcpy((*objArr)[*nObj].dialog, end); + for(i = 0; (*objArr)[*nObj].dialog[i] && (*objArr)[*nObj].dialog[i] != '\n'; ++i); + (*objArr)[*nObj].dialog[i] = '\0'; + + *nObj += 1; + + }else{ + fprintf(stderr, "\t%s.readMapObjects(): Skipped invalid data in DIALOGS key in map file %s.\n", __FILE__, file); + fprintf(stderr, "\t%s.readMapObjects(): The invalid line is %s.\n", __FILE__, buffer); + continue; + } + } + }while(buffer[0] != '['); + + }else{ + fprintf(stderr, "\t%s.readMapObjects(): Found invalid key in map file %s. Key is %s\n", __FILE__, file, buffer); + free(buffer); + return INVALID_KEY; + } + } + + fclose(f); + free(buffer); + + return NO_ERROR; +} From db89aa2843bb058fe0df57bf9fda3de9ba2d727d Mon Sep 17 00:00:00 2001 From: Miguel Angel Astor Romero Date: Thu, 6 Mar 2014 03:19:06 -0430 Subject: [PATCH 13/26] Map successfully rendered. --- src/game_state.c | 6 +- src/in_game.c | 303 +++++++++++++++++++++++++++++++---------------- src/main.c | 2 +- 3 files changed, 202 insertions(+), 109 deletions(-) diff --git a/src/game_state.c b/src/game_state.c index 43f9620..8bc192b 100644 --- a/src/game_state.c +++ b/src/game_state.c @@ -9,7 +9,7 @@ void initStateArray(gs_t ** s){ int i; - for(i = 0; i < NUM_STATES; i++){ - initInGameState(&((*s)[i])); - } + /*for(i = 0; i < NUM_STATES; i++){*/ + initInGameState(&((*s)[2])); + /*}*/ } diff --git a/src/in_game.c b/src/in_game.c index 3c63c2a..8b5de31 100644 --- a/src/in_game.c +++ b/src/in_game.c @@ -6,7 +6,6 @@ #include #include #include -#include #include "constants.h" #include "in_game.h" @@ -17,8 +16,6 @@ typedef struct PLAYER { unsigned short y; } player_t; -static const int I_SIZE = 513; -static int ** imap; static bool ** wmap; static bool w_mov = FALSE; static bool uK, dK, lK, rK; @@ -34,87 +31,46 @@ void render(int, int); void drawGui(int, int); void setPlayerStart(); void initObjects(); +void drawNeon(int, int); +void drawBar(int, int); void initInGameState( gs_t * gs) { - int n, i, j; - float ** fmap; + int i, j; gs->name = IN_GAME; gs->input = &input; gs->update = &update; gs->render = &render; - n = I_SIZE; - - srand(time(NULL)); - - fmap = ( float ** ) malloc ( sizeof ( float * ) * n); - for ( i = 0; i < n; ++i ) { - fmap[ i ] = ( float * ) calloc ( n, sizeof ( float ) ); + map = ( map_cell_t ** ) malloc ( sizeof ( map_cell_t * ) * MAX_MAP_SIZE); + for ( i = 0; i < MAX_MAP_SIZE; ++i ) { + map[ i ] = ( map_cell_t * ) calloc ( MAX_MAP_SIZE , sizeof ( map_cell_t ) ); } - imap = ( int ** ) malloc ( sizeof ( int * ) * n); - for ( i = 0; i < n; ++i ) { - imap[ i ] = ( int * ) calloc ( n, sizeof ( int ) ); - } - - wmap = ( bool ** ) malloc ( sizeof ( bool * ) * n); - for ( i = 0; i < n; ++i ) { - wmap[ i ] = ( bool * ) calloc ( n, sizeof ( bool ) ); - for(j = 0; j < n; ++j){ + wmap = ( bool ** ) malloc ( sizeof ( bool * ) * MAX_MAP_SIZE); + for ( i = 0; i < MAX_MAP_SIZE; ++i ) { + wmap[ i ] = ( bool * ) calloc ( MAX_MAP_SIZE, sizeof ( bool ) ); + for(j = 0; j < MAX_MAP_SIZE; ++j){ wmap[i][j] = rand() % 2; } } - ds ( &fmap, n ); - island ( &imap, n ); - normInt ( &imap, n ); - norm ( &fmap, n ); - mult ( &fmap, &imap, n ); - smooth( &imap, n ); - normInt ( &imap, n ); - - for ( i = 0; i < n; ++i ) { - free(fmap[ i ]); - } - free(fmap); - - setPlayerStart(); - uK = dK = lK = rK = FALSE; - - /*map = ( map_cell_t ** ) malloc ( sizeof ( map_cell_t * ) * 32); - for ( i = 0; i < 32; ++i ) { - map[ i ] = ( map_cell_t * ) calloc ( 32 , sizeof ( map_cell_t ) ); - } - initObjects(); errcode_t rc = readMapData("map_file.map", &map, &mW, &mH); - - fprintf(stderr, "\t%s: readMapData() returned %d\n", __FILE__, rc); - fprintf(stderr, "\t%s: Map size is (%d, %d).\n", __FILE__, mW, mH); + if(rc != NO_ERROR){ + fprintf(stderr, "\t%s: readMapData() returned %d\n", __FILE__, rc); + exit(rc); + } game_obj_t * objsP = objs; rc = readMapObjects("map_file.map", &objsP, &nO); - fprintf(stderr, "\t%s: readMapObjects() returned %d\n", __FILE__, rc); - fprintf(stderr, "\t%s: Number of objects is %d.\n", __FILE__, nO); - - for(i = 0; i < nO; i++){ - fprintf(stderr, "\t%s: Object %d\n", __FILE__, i); - fprintf(stderr, "\t\t Type %d\n", (int)objs[i].type); - fprintf(stderr, "\t\t x: %d -- y: %d -- eX: %d -- eY: %d -- sX: %d -- sY: %d\n", objs[i].x, objs[i].x, objs[i].eX, objs[i].eY, objs[i].sX, objs[i].sY); - fprintf(stderr, "\t\t iD: %d -- dId %d\n", objs[i].id, objs[i].dId); - fprintf(stderr, "\t\t name: %s\n", objs[i].name); - fprintf(stderr, "\t\t target: %s\n", objs[i].target); - fprintf(stderr, "\t\t dialog: %s\n", objs[i].dialog); - fprintf(stderr, "\t\t unlocked: %d\n", objs[i].unlocked); - fprintf(stderr, "\n"); + if(rc != NO_ERROR){ + fprintf(stderr, "\t%s: readMapObjects() returned %d\n", __FILE__, rc); + exit(rc); } - for ( i = 0; i < 32; ++i ) { - free(map[ i ]); - } - free(map);*/ + setPlayerStart(); } void input(){ @@ -132,23 +88,32 @@ void input(){ } gsname_t update(){ + int iX, iY; + + iX = player.x; + iY = player.y; + if(uK){ - if(terrainType( imap[player.x][player.y - 1] ) != DEEP_WATER && terrainType( imap[player.x][player.y - 1] ) != MOUNTAIN) player.y -= 1; + iY = iY - 1 < 0 ? mH - 1 : iY - 1; + if((map[iY][iX].f > WINDOW_WALL && map[iY][iX].f <= WATER) || map[iY][iX].f == SECRET_WALL) player.y = iY; uK = FALSE; } if(dK){ - if(terrainType( imap[player.x][player.y + 1]) != DEEP_WATER && terrainType( imap[player.x][player.y + 1]) != MOUNTAIN ) player.y += 1; + iY = (iY + 1) % mH; + if((map[iY][iX].f > WINDOW_WALL && map[iY][iX].f <= WATER) || map[iY][iX].f == SECRET_WALL) player.y = iY; dK = FALSE; } if(lK){ - if(terrainType( imap[player.x - 1][player.y]) != DEEP_WATER && terrainType( imap[player.x - 1][player.y]) != MOUNTAIN) player.x -= 1; + iX = iX - 1 < 0 ? mW - 1 : iX - 1; + if((map[iY][iX].f > WINDOW_WALL && map[iY][iX].f <= WATER) || map[iY][iX].f == SECRET_WALL) player.x = iX; lK = FALSE; } if(rK){ - if(terrainType( imap[player.x + 1][player.y]) != DEEP_WATER && terrainType( imap[player.x + 1][player.y]) != MOUNTAIN) player.x += 1; + iX = (iX + 1) % mW; + if((map[iY][iX].f > WINDOW_WALL && map[iY][iX].f <= WATER) || map[iY][iX].f == SECRET_WALL) player.x = iX; rK = FALSE; } @@ -179,47 +144,57 @@ void render(int w, int h){ di = i - 27 + player.x - ioff; dj = j - 1 + player.y - joff; - if( di < 0 || di >= I_SIZE){ + if( di < 0 || di >= mW || dj < 0 || dj >= mH ){ printw(" "); }else{ - switch(terrainType( imap[di][dj] )){ - case DEEP_WATER: + switch(map[dj][di].f){ + case WATER: attron(COLOR_PAIR(DW_COLOR)); if(w_mov) - wmap[di][dj] = !wmap[di][dj]; - if(wmap[di][dj]) + wmap[dj][di] = !wmap[dj][di]; + if(wmap[dj][di]) printw("\u2248"); else printw("~"); break; - case SHALLOW_WATER: - attron(COLOR_PAIR(SW_COLOR)); - if(w_mov) - wmap[di][dj] = !wmap[di][dj]; - if(wmap[di][dj]) - printw("\u2248"); - else - printw("~"); + + case VOID: + attron(COLOR_PAIR(MN_COLOR)); + printw(" "); break; - case SAND: + + case EMPTY_FLOOR: + attron(COLOR_PAIR(MN_COLOR)); + printw(" "); + break; + + case RUG: attron(COLOR_PAIR(SN_COLOR)); - printw("."); + printw("\u2592"); break; - case GRASS: - attron(COLOR_PAIR(GR_COLOR)); - printw("n"); + + case WINDOW_WALL: + attron(COLOR_PAIR(SW_COLOR)); + printw("\u2591"); break; - case FOREST: - attron(COLOR_PAIR(FR_COLOR)); - printw("\u2660"); + + case CLEAR_WALL: + attron(COLOR_PAIR(SW_COLOR)); + printw("\u2588"); break; - case HILL: - attron(COLOR_PAIR(HL_COLOR)); - printw("\u2302"); - break; - case MOUNTAIN: + + case SECRET_WALL: + case SOLID_WALL: attron(COLOR_PAIR(MN_COLOR)); - printw("\u25B2"); + printw("\u2588"); + break; + + case NEON_WALL: + drawNeon(dj, di); + break; + + case BAR: + drawBar(dj, di); break; } } @@ -234,6 +209,128 @@ void render(int w, int h){ drawGui(w, h); } +void drawNeon(int i, int j){ + bool n, s, e, w; + + attron(COLOR_PAIR(FR_COLOR)); + + n = map[i ][j - 1 < 0 ? mH - 1 : j - 1].f == NEON_WALL; + s = map[i ][(j + 1) % mH ].f == NEON_WALL; + e = map[i - 1 < 0 ? mW - 1 : i - 1][j ].f == NEON_WALL; + w = map[(i + 1) % mW ][j ].f == NEON_WALL; + + if((n && s && e) && (!w)){ + printw("\u2560"); + return; + } + + if((n || s) && (!e && !w)){ + printw("\u2550"); + return; + } + + if((e || w) && (!n && !s)){ + printw("\u2551"); + return; + } + + if((e && n) && (!s && !w)){ + printw("\u255D"); + return; + } + + if((w && n) && (!s && !e)){ + printw("\u2557"); + return; + } + + if((e && s) && (!n && !w)){ + printw("\u255A"); + return; + } + + if((w && s) && (!n && !e)){ + printw("\u2554"); + return; + } + + if((s && e && w) && (!n)){ + printw("\u2560"); + return; + } + + if((n && w && e) && (!s)){ + printw("\u2563"); + return; + } + + if(n && s && e && w){ + printw("\u256C"); + return; + } +} + +void drawBar(int i, int j){ + bool n, s, e, w; + + attron(COLOR_PAIR(SN_COLOR)); + + n = map[i ][j - 1 < 0 ? mH - 1 : j - 1].f == BAR; + s = map[i ][(j + 1) % mH ].f == BAR; + e = map[i - 1 < 0 ? mW - 1 : i - 1][j ].f == BAR; + w = map[(i + 1) % mW ][j ].f == BAR; + + if((n && s && e) && (!w)){ + printw("\u2560"); + return; + } + + if((n || s) && (!e && !w)){ + printw("\u2550"); + return; + } + + if((e || w) && (!n && !s)){ + printw("\u2551"); + return; + } + + if((e && n) && (!s && !w)){ + printw("\u255D"); + return; + } + + if((w && n) && (!s && !e)){ + printw("\u2557"); + return; + } + + if((e && s) && (!n && !w)){ + printw("\u255A"); + return; + } + + if((w && s) && (!n && !e)){ + printw("\u2554"); + return; + } + + if((s && e && w) && (!n)){ + printw("\u2560"); + return; + } + + if((n && w && e) && (!s)){ + printw("\u2563"); + return; + } + + if(n && s && e && w){ + printw("\u256C"); + return; + } +} + void drawGui(int w, int h){ int i, j; @@ -283,19 +380,15 @@ void drawGui(int w, int h){ } void setPlayerStart(){ - int x, y; - bool posFound = false; + int i; - while(!posFound){ - x = (I_SIZE / 4) + (rand() % (I_SIZE / 2)); - y = (I_SIZE / 4) + (rand() % (I_SIZE / 2)); - - if(terrainType(imap[x][y]) == GRASS){ - player.x = x; - player.y = y; - posFound = true; - } - } + for(i = 0; i < nO; i++){ + if(objs[i].type == PLAYER_START){ + player.y = objs[i].sX; + player.x = objs[i].sY; + break; + } + } } void initObjects(){ diff --git a/src/main.c b/src/main.c index 648d0b1..34a1b44 100644 --- a/src/main.c +++ b/src/main.c @@ -243,7 +243,7 @@ void set_colors(void){ init_pair(SW_COLOR, COLOR_CYAN, COLOR_BLACK); init_pair(SN_COLOR, COLOR_YELLOW, COLOR_BLACK); init_pair(GR_COLOR, COLOR_GREEN, COLOR_BLACK); - init_pair(FR_COLOR, COLOR_GREEN, COLOR_BLACK); + init_pair(FR_COLOR, COLOR_RED, COLOR_BLACK); init_pair(HL_COLOR, COLOR_WHITE, COLOR_BLACK); init_pair(MN_COLOR, COLOR_WHITE, COLOR_BLACK); } From 0a703b5f8bf843fa10ab0134d8c27f1ea2c5293b Mon Sep 17 00:00:00 2001 From: Miguel Angel Astor Romero Date: Thu, 6 Mar 2014 03:23:40 -0430 Subject: [PATCH 14/26] Removed libisland files. --- Makefile | 2 +- include/island.h | 63 ----------------------------------------------- lib/libisland.a | Bin 4796 -> 0 bytes 3 files changed, 1 insertion(+), 64 deletions(-) delete mode 100644 include/island.h delete mode 100644 lib/libisland.a diff --git a/Makefile b/Makefile index 915c81d..2fb9cbb 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ OBJECTS = obj/main.o obj/game_state.o obj/in_game.o obj/map.o TARGET = bin/cyjam CFLAGS = -Wall -I./include -std=c99 LDFLAGS = -L./lib -LDLIBS = -lm -lisland -lfov -lncursesw +LDLIBS = -lm -lfov -lncursesw all: CFLAGS += -O3 all: $(TARGET) diff --git a/include/island.h b/include/island.h deleted file mode 100644 index f4b9bd4..0000000 --- a/include/island.h +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Copyright (c) 2014, Miguel Angel Astor Romero. All rights reserved. - * See the file LICENSE for more details. - */ - -#ifndef ISLAND_H -#define ISLAND_H - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum TERRAIN_TYPE { DEEP_WATER, - SHALLOW_WATER, - SAND, - GRASS, - FOREST, - HILL, - MOUNTAIN - } terrain_t; - - /** - * Generate a diamond-square fractal map. - */ - extern void ds ( float ***, const unsigned int ); - - /** - * Generate a mask using particle deposition. - */ - extern void island ( int ***, unsigned int ); - - /** - * Normalize a float matrix between 0 and 1. - */ - extern void norm ( float ***, unsigned int ); - - /** - * Normalize an int matrix between 0 and 255. - */ - extern void normInt ( int ***, unsigned int ); - - /** - * Perform a 3x3 average blur. - */ - extern void smooth ( int ***, unsigned int ); - - /** - * Multiply the diamond square map with the island mask. - * Both matrices must have been normalized before. - */ - extern void mult ( float ***, int ***, unsigned int ); - - /** - * Given a sample from a heightmap, return the terrain - * type that correspond it. - */ - terrain_t terrainType( int ); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/lib/libisland.a b/lib/libisland.a deleted file mode 100644 index 7e247dc5b16630c1236d530d79e99e53e8dae0bb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 4796 zcmbtYeQ;FO6~AxaOB%zHjk?pW_}Xk|u9|J*x~~Mx!WP1?Dzz(RbfZk&YC;kQ+I%p{ zTNJx3n9ZWMuZ!uFqMf0(fAo*GqcaQxi2dA6K#c7;5NCAPB~)wcB%~_nlwhoGf9HK9 zp+L3moxS(mbME=N=bU@rd;9rFTVMO871cNSFKpW4@ZzOfNL%_PzdvLy%^&^#CJV(% zYc*r+Q|P-d*E{;z=Kij>o(|U2+t+OlU+K|Vcd|=o{oTF2`X;7#_Vu-G?ul>P(#dS* zV6WrTd|$Ls2$pBZrAr(A{>CLuO_ukq)!T20-6}~ET(O$OWHyH}rY^MTjV7pP3mLgT z*IMqm`>yogQ^yoew26O~%VnW(6B-9NZPD1vhXB%VOU8oVFgCMV=zNXQ#n zB*Xj5^oNq@;!&agN-PrUFNDvt%PT`x2Q9(XVw9^!l&?AQ5hOY?InQ7noP?67cu&g_ zSN;tb7}twGV~pkh=7P3n@W%76xx|!+@^xAcq}Hhg*#p;;r{auw8S?84Zvdd#a0iOY z!v$rape!mV*Ax@H3pTq7=I)E5r4;w0hpc@)Wo}4L@K)mvaw1mh;vpzSYhpVkqL$qEuk@D3my$D+I$wpjj+&jsES|3H9R5zFQ<;_2D> zDB_sauVyd&$)kSZhcuxV7q0ufqoEv~ckL18o$$_1sQsO;Cq3d%m{?2rm`8rMsO zg7WyRKFnt$`X4ey=`nKxmmGe|4I1J{)JNrVVWAtbO{cJD$F1*rD2qs0 zRGgZe!RZ<=q>rTTz3={SjARc{CR(0-edUg_c?ct$qdb0i0b}-IoPM1Mk6w+;pS}Wl zsGok_nlxN^Ok=!0GwK<XL$nW5R2xIF@oAl_(kl)j z!5fHx$|PprRIBBmIFp~K8_an!Pe9$_yIWdXrYFVo`SW#w;jD5eZ21EDY_z((9G3eZ zK=qxj8yrja*mWkR<@iAc2Yg0#IL5uHigaEQ)#)ke!Mm(YJZFJCJYQ$jWAqvE-?6MR zVAQ6EB~fddghSrxx8aIyHt<|lzqyRl755C>i&Q`#e%qc-W7`sR_>q@-Po|cZjzr98 z57~8U-FI#UQPAStuf0{QsKpMAMcP;~#Vb9}#CYXF_eK%piWxT}@Do!U4 z7jxQ}R^B*dG+O$y?p&j z4H@po!Y_DYC(=17JRAVQQn}9 z!Y{umkl;;*QVF?6!@Ea2hkGz2A!KUuYm?^?06UN1789}>l+_iox(9-4`luqSl@xT7 zR(UwQ>y0KXG)+(CKd3t~6L=L@hfjD{cm_X><0@VRYeVK7a?qHKWTBaPZaHeGE)XJE z3K`LX^V*oKKAK%C!5c1~r!8ca9}z1EbjxsA9m<^ZWV)$nQNJ+PAgdu+ZNh>$GuZ*U zb?*NUfAw!()>p(Bj}L==GA|#vjF&y2JNE-N9>(pd*9aW5$t8Fknf~L1m8d%Kl!{V- zrrdTOP!PtIhMr+47eg5kDPDz4D#CvG6LzJELKtO~JPvoGh~1X-kp$K2Bo%;pkKiPv zXFj{#qvg^wHJ+d5?B`l~=7z&4Ot!u9y%FNe-d@-zr{7<`^-T8mz5A5(``XqwwcNuq z2Pl0%$)$4@Bbe=2fguFA5^!a?yuAz!s~LM}HM?!~>Sg}=mJP`sJ$X}Xb5C1eufH+4 zG`RRiEol;$1T35}I>^+dhwfxjs!F=nttj-K6ah^&SD+DZr)*VCRmQcd#{G!As-||Q zvZ}_Lu2@|&B*{H;jTfX5tUU*&W2HgUvILrAPT?WV!467t2P#9*67@ zzIvXbq+U91Tjag2i-o~X57ym~Z^oy`S1~tRuzy>(-nM}S`}IBxZgOUQon1k_^Ff^j zJKFR%7TnO^&w_ougaq6B^+pzK@9pmH#3xm-r&sR`-nO>o#(ur6{afIIXy>N;H}YB0BMZ9A5}L*zG6lvDG9@8`}UaAzNPV?IAF2d-p{>W$RW{)mqt$g_LJlpV(FatBT9=BS=;la{!L zu~rc2?V9Y6K7`(!JFx@G20^@!CU$f5Ik*Go(-n3Wcg$S7@aviUoo|6~XV;dD%qr%D zF_X=|2Ifezx%2sWMmxhlANppTy#7A= z_k)Js?vMR1q`R%FtGAtXcXqdL*~T{Zb#`9(_XtD!nG3c28GDx<-&BHlC^gy8PkzIfRvZ4zhOgOB#Xe|#y$zqR;lBWJ_daw0 From 799f1a33c6b88dbbf6d7760a43115ac8660835c7 Mon Sep 17 00:00:00 2001 From: Miguel Angel Astor Romero Date: Thu, 6 Mar 2014 21:34:09 -0430 Subject: [PATCH 15/26] Field of view calculated with libfov. --- Makefile | 2 +- lib/libfov.a | Bin 16870 -> 17898 bytes src/in_game.c | 131 ++++++++++++++++++++++++++++++++++---------------- 3 files changed, 90 insertions(+), 43 deletions(-) diff --git a/Makefile b/Makefile index 2fb9cbb..91ee777 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ OBJECTS = obj/main.o obj/game_state.o obj/in_game.o obj/map.o TARGET = bin/cyjam CFLAGS = -Wall -I./include -std=c99 LDFLAGS = -L./lib -LDLIBS = -lm -lfov -lncursesw +LDLIBS = -lfov -lncursesw -lm all: CFLAGS += -O3 all: $(TARGET) diff --git a/lib/libfov.a b/lib/libfov.a index c66ba879dc64ab05f4d0024056ce6bc24e61d49f..088e3cf7abf2bdfb4efa0deb9e93049221da4490 100644 GIT binary patch literal 17898 zcmeHO4RloHnZA=5G-Ak|+GtseI_+LC2*d;e2At|(hJc#m2}_I-QAY?Wy;A*SDevu zZmX}qIkm90t@f4;_0_d)ZB4hQEv;Mcy}jC7@9|bQY-p+Tu5WEgttMJmH?3dSNW&Ya zVnchq99-S{_PQo{yQaRjnYznsH7ucAy~4tx1rA3+em<5i{(sS;LZmKPSTJ9#U(M9J zmz9=SEEX)Hyex`UNu(5I#$uUYC?HpvrqF^XF5hTXph_zZR%tbXCap4fQNXK}1>OvF zXypO7He>N{`*(sx1^xb*_q^U!vEI2q4lYyt{c6{J=pu0BrK1-VygmEvplu5}C=H@% z5DkOq$hW;}pw~M~36yKo2i=;@M)hZCk-x@bu^{sN{eeNXD;q-%mTEJC7Jt9j=KsS6 zdk{hcMS*ii?(N-1qkQRu4C(@7%fxtW0Vj7M8U<{L4o6<;BYC~H2Qx_&wK0@JoLh5v zI|8ACnELbpCYg)TI?%0#s&fOc1jYh~)u#t%zZ}?Ium^SXkzIJ8Ny`uOpu-*767^ZP zwq$Eo1ImlSO9@rW94-)Dd%<;WUTM!tFZ2mMByVR|@JXxeU&!8rz;Ue)gM9A%gI9l6^tyxkw zt#COHpppgvwW?g)p}Eve9yF)PL#gIMmtwwt3o4h5+#%P`A5(u&L|TP~_wP~tqv)C> z@tm*}v<%@Xv?B+is&5}KJcU#yykjUj99DfhaX%aie~2E+uynRSDBPuWQUz#2Gj@g~ z)5_C!V@MsX!JD&!#WvJ;La#Dse+sR#Vdk;3y0F7HV~qaTU3tOcOez&+ZY?M9(VSvC z25t{T<`ie)hPpr_OwAc9v-vt8L+yGhA%>(PrQCThs>~(bSx?in`mh$X0?ud@%iO0A zE_x&6_TH+1$dyorN>T!vd1xkeqNnzMtlvea$@;X*!KHRxHzzsj*h-sF+J-){)=4t- zwf4+4uCwQST4Q}u;Rm!%3@iG0oCo^2<2A+`Keue9mf-&!T8{o`FRcZoNwd|b`_-rS z%$CGn0rf2fu~!&~UBSv1S33}Ug-|=Uwj#Qe`togWy5Yv^?+zsRNEX7`NBiaPe~$D) zU50zw2@rBIK<&9eGSNwDt}k?)fkyhR%3}7R&oWY^*@P9DQft99=7J!j+I6?ix(3O* z9NM+syK(|Ht+!%27&q&vk#U<(j&avZ#yM##pd>Nawlc{&_ejk|+=^gPjC-#7-bM~{ zi_B6ow;oButt*48>_iMO%5oHolZj6*rWrd2tCZW-?_C}&A!Y4)5004{y$;|#N2ZSrw0on@t97h0Hoos&2ZUnl&W6Y`zlpzw2d>Wo_}8D}@L z?YU0`+nmzB{Zz8eNz9<39glx=s+(?*Y;&b!+Zwj7(m$v8vg732y(xTic7Sif5h2_X ze6vl+w^HzJhmmi>MvyH8-`D{&-(1AEi<9|AFXLlDp44o@lHCMWMp!#5ZB z_74WWxlWRA*H6qhiZ5N{zV!IgW$7ang)pL43uEx#1;CO;9z&n>@-HzdBzL?>F@0SY1me5q}cjjPd8mp0A{hKd%#qmlZE6O6TRP3O@0T+5-bP zE4Bp+wTN;g77K(#1wHH2!zo!i$5OHmy_b@;_E1XJ*YK{@)P44cDOp2*!eRM#J6>*x z_q8}TunoHCeV8)n%93CgK>v^@US$rta%5^cfoRzK{DpLn(~C^%BT$wp`-`WuOlf;^ z+CHGaui^GKQI6N2STnr7bof8&%UIBktZ9K9 zej{9xV;S=eSQg(neUQo(w7l&t9HxjD(1Rs%_$6Za`s~H~X5Z*s3_l-7D>RHkU>2|l zNUx^p^-d0uj>Dz{-M|^Ws2j<_p^0z%+yRVsWAHw$6C&~2@BxAkgI(HY+zdtWBwmR^ zdd-U4D%{>9Z)>PrUh!RO8WKs%Hp2(*e5;C|-#d;>;Tkz#i@o&7)P+r5ok8K~6Zb z?{IkMf#`5(?{9{~5Tp0U(!g7cuJiJU6`>ZF>3O=W75@{LHB-onzpuTu(I6MAqW0{= z0zu|T_;r#wL^3f;Imarz@DI@x2W=XLtVDkPPC};4f=CBVGqU|-DRX41e6Ktl!h5U! z(99V$SC)SudTSfjf1ZQ#c=a)VF^;vV<1o(MuFo;@1h||!Z#%u6tbs8YsYu8lxvHU$ z#xZgQ;}XXCj2AI}oAF%2ksLZ#5$&eRd`kPaZ@ggu@1cBSHr0QfNntKlX%Q0&Gl
C!Nl)1;?-xIx{$u7zXnPQx`h(0DMaH0tn&vX*3QP zsLF^3B$Ash?3~!noe6H3`45_a{|Px_X~|wdFN+|9xj&O!1nyno9mF@aXY?epp|j!zr|N-{`ahif~QL0TvDdXfg|;D5$tnf2=u zHV$MEOa>`MzpPT`-(eR zjD&%XNb^kEwSyed4)lLz+9 zdTX;`Ji;{JdnU%ZYyV-W>?GPg&!GRDv3AA=awk3$5XS4c6E`{GBsUy?k zydMt3>zGsnzM?7oQfQv=A0}T>Dd>>ovuG8JW6^g3Rv>ca`{VA;3vg&+Fd4(4WM73% z=nlaIm=|LgEk=sJOelpz_m$S+gjADiR)(PyPoQ(*PpqmxMtq+@8=gJ=q_x4FaGPT1 z4cc%9+~&C2&}v?Qo1vMDP7^BF8((^b*RD=CJPJQTh;47MBx9OWQf)C?q z!hzo>_C(hZro??XGZvbVsmBkg`mp=IQ}m&Gl!&U!1|!pG!u1Bn8=t<6n)2WuqmQ85 zzTvQM>~z)thhu2MEBGqIgtj1^C3r1C0AT?PVd=j^OGREfOHgOp`|itOzT{-Z7JVoJ z;w0Yj{Ky8hznxg@__XD&UkLLc7W)hlpB?9Z_c$;N69*^a|Lvfg&6|z3WZmbNwaoK{ z^rZQtees!@SMe~|Lo*x6)SuHxZt`;`o*NKzj~CZ%N!`ozaoryik7s5*dLQ9s^bq1& zqu*jb5UonY^GqD_O*^7xIGRdVe-XZZnwq~OdKR9M^nB8XV?BSwcE?vu=mFN3obA;oI{DT2cw*R&~7|AKSIbE{VV<*&wO4?((ioXZZMyXd&iga z1_Fv`p?P1zA4X>)9M29O<8}vcw8t1pc zVCm}$J)6Y%XX5yieWH2%N8z}{_^$zlF#bvPclMrf``Za;Bl>#?E8dr8{@XKS4usK&+kgI9Vz2_1i3hAP%g)3D?WvE zW{BHje6B#+g+F{cUCQ#};w6sUYu9XO@ou=dbbU*0d#j@`Z&BWYc?BCp=EB)BttfPE zN|)u1zf&w7nU-&6*=+Y9V9iAy*ULV35WodS%KVxZjR*!XQw!Pc7G&{#PWm$Ho#ri#Kb`G)zQ1&V+4K76| zvi&`1mJdHtIbr*&#%=!^+V^EDO5=p>SC891ljewL(2WzeziHg|E6~0Z#~dd*ep>T) z&N}h+dkyW|&N=b%XJ#nMM}Ko->z9wETY>g9=PAmQxTpQ^$tcOr>b90-+kLiW*^Z3+ zv+dY)YznxC@i>0HcA27Ng10msq7cF` z1vFGHw*QlW{N>e?$=HNs1k5!NMjrs>g#6|sSd{03A(dRq(P(7+ommSJQGW3he z=!2iy3e@v2)s>Jls19AL@u7RDjJTYr*P#yN zx#CuNu1HbV(hXm_T%$}X(k{hZFbLws*YTnLXirF{VK_=57T||^Cnz)AB9*v|`8MU_ zSfYgbGnP`?D1p*81&_?)BHxgK`lS93{MuPkU`%zW7adYn`{Y#arFhEPn~k z$>uisi*LQOExEMWRGO4*PVTBLxpFhQs-|DD^Dn~dYMYu`>y+mD<~kBWzZY+oS)NAXY;VjUoaZ=Z>6%lL+(oC7;xL9FrjjE5P=7*7KS zsr(3I1&jry*D|&+KEwDKkotWXG@*JnI03>E#&X6rjH^L@Du0UcdB#^6r^3)tc?FRA z&47`jbUWiV#_f!I7@wU z=Mm0eoW*z(<2E4mTXU|gx0~@CIDcxVG0tba2oDOBe;4B>#`_ufGR{JLNd3MAyG45a zG2<2lAJl$3<32{WL*|z=ZeiTUnEx$VzKGGyIPKdqe*>eR@moqWLWOQjV zznSrOj2|#AMQ}soUC!9g_$niP?~2N+XGsh*R$VC5YZ%)Y_c0!1Y|fSS4ly>(mg#oJ zPR3EjBaF9QB`F}5-8V?4;%JXh8WGnUVj>D7#ljK5{v%UGHx>uqJ+&gi&U z=Fei>%=i%F7RLU3SueLhVjm;6SINkLJ~M7&+{Kthc96;$H!<#F%tDzcXY6FWkMW-v VpJ&|7_&y`qQEERI_LI=f_`k8H2%`W1 literal 16870 zcmeHO4RloHnZA>mXv8shq*-JYWN-%zGK>?6G+>m3gn%@qC>Z=N%2H5erXT@`BC86rQTrE`h0$||POcJ_I{@4Yj3 zei9O(o;};%lbPp!|3B~hyzhIzo0(Z$(^lJX!=$U7$ydSrh4U8_6kJ<0-|6&Oqa-so47a!^$5Yp7|hOV6%tX=|=) zt8T5UyDPo0rM2enO?A~Zt*wpsW-P7U=)bqxU+42z*KcaB^>1uxPOm0fS2u3_Rs&6M zl#2Cjb#ijG8{29dcWF<*N2J}>sLGefZR}}Yih_6?DgA%A8vAl zFsN3fT{`q&_p>z1oxjPVE-<$o%*Un`a~GnKW=nK9^lA@{*KK<=hlZjyrcw;I)8D3r z3u5XseduhO_9?35YrC{z?WFol|D2b#w+i-Q1ShgxhZ|kaNN;3hF#4T_gONzP%cDM5 z?(*!g*Q16z(&%y@Zbywqmj}~zYPJ^w{g#EF`?hN*u(W(Ee_DU}BeY^g`#P^LWb47U z1qc2Rixu?hZvf=_XubN6kvtfVOmk_Kt~|L#xEbo~-mKiRwraK37x-XZh}Kj{{ly7=}hgO8MS{sFF{L;-Rt%R^E z!?URUp^x=hGM~g3Ds@m-5i}j=1Y@Tg3=q&}1CKGUl{vu}R ziBOVqSBd^ZwC4T-udKUcef3}W2^t9s#TAWJY^ay^FTp2LY=U{WDA#V-hSXuu%PYP%#8Ix8k6nL}8W!}=@Kn`=HD48QKLWG768XUPXwAw)m4rW+Jun{@= znUR8b_%Ji>!07LL&v9X}0`h?FyDg#l`t3p=Nr98Gpa}60{&*6iTj*n-{-6Eibkw@xl#WoHX&mJz-w#m>@5Nr|o_T(n;Zm zm-yjL_A_4LXS{0H0Q8L6;nntz!VfqP>uN_5M~D>UZOD_ShenD-=;XigI`wxo8yyPy7c+6|^BUIp(egsT8Y+?#UWMuoHSpGu;!kdJA z_PKtS*KjE}*7x@;BzicA@%F!~#U!;}(RBcBfX3}=7 zCS&|10!*@g8R9RmjK8LliN?AOUv&oY*ElBlrN&>xn|%gvu)*F5`2@fTc% zH7N$m5PKCFyqO_+lNNh@_K`XEx>0iGjAE~gBxf?lUgyN0oPGS2=1&B{ll{q`eEb#n zCuDdg%!{8-kQW)_uQPbw7rw>kAlE{H*`WcrmBO=o;$LHM=Q_!qj8FW}eQ4%SO@coY z^Er6ppC$Q|_Qb#OkKu3r{Jj6A`Wt%Q-*56a6Mx=+c!Io2@;B!&UPG{E_1Vu&y!PGW zUv9i6&Hp($FZ(|cukjO5{JiYX@tQoi&U9XO*74ey=K(umyKz!RX8~|N#(4lguKfM>}!jq4o16tArn zhhtSZJKM5&b-}5?2M(r>{FbxzT&{)xOg821-JE=(EAXjzr-%VA%MP+Cth3im*mORR07ek`^78i z9`SGv^`WiGk^RNf_LQ_EIqm2(&iT2$O_byH7WNEp4xPbM{E%)lks3ZLh}f{Q4{80xHA;OzRJP z;3kg4M$k0qeVQFu1f*Aw#lSpZ32-W~95}5Tb)$J;Q{WYMA7KrTKxCzsPzkrU;>YTowGJ;S@m4R|h38wThV-t>ODFn3C%yA}=Tt0)dq*UjHZ1&ZVyvU8d8`9_adJl8 z8~tDe>L2GJ(3mZYqkT|NE;I6sF`kEpo5s)+?;1AWNpI!UuB!C0XjN&0*<6^U68-Jb z#8@&*425MyUpy(t8k!{EuO1BJJw`TZK{!6{VV%Ye&zpu^IsUQS3~M#5)L2pU-+z-B znO81WhMhb*6pIb5qVa}S)b|Kn!nla>8pf*_uVB2Ca43(?mqfcsGN00cR~qiELj$1t`| zNC?|>*~dv^#Dy}bZ@xncW9P(_VFdyJL-A6SVKLql(0Yclg*?*rKw@g^WFstl&bk4Ast^ush?? z7dVi_G?Mh?8*n#bDrv@JdL}}p^Vu*Sk4NKU7~6|}g@L+`3C#v7lfESJKj2j7VdK#N|B>=@oJP-n< z&EIKw1ES^T^^% ze)Mo+y!eXAQQD%{yaO4}Lzm1?s~UVMgJ?fL?<_>SKH;7Oe@vqNN5i(KiN7xhCKdRuuP+l=?TG&%Xluz~(W3iycM8Xtn_BIsOG)CMb!V|BN$}y6V zPzE3DG<@*aGI=Da8b_e{G{(?*@_8dueC(%aGwE4r1MOex8qK0Ig1Ul)GcxIhh<6@` zGty_GYY`vQf12q}eIfoIi`9KVwU9%f53Al(gXU%i0zRcM;!ga+h$3|ou8BJ^%A~y=0BjyHFCJpU{tHDR09Z>H+Ma(1+8_H*qeJHecqL{uned zKHt;y_iw*8OGB6*^ef!+5!NW(iQVP?%q~O!Hll{{j$_?7>NvN;r-*$%oY+6!=Pn~I zN!iaQ4FAUUt~d0L)6YRE=(aU2gdblK| z{2$DEKzeM%&nfHs9r6*qD~s{jflncz44);qFTo!^TS}B=Wo3(;`L}G?)a>7Mb>+t9 znzj~ap=W_-{=9-sBJfc#?eN(YX;_k0Py<<*r&D z$gT)xRdm`ayR7$2%C)`PzpHO4o>PiZyd0m$P_GgmPASdJ31*e%+Pkc!xsFa-X>ML1 zdueW~^$P2x+&pCUp==i_^_QZP(hI5m{rG$Yi<>uA`{P-ow%?8RjvUN+toA2IZ=Zv? zduc6WwVyot{FkGBD-HwBbpEvGJr|$({_RHlBM|19&OawhQJi=%Jd^o*vG>c-zT`4R zc?$O=|E{cxTzjXrBG(bHEzNai{V>-7p+oRF5WKBlp;O;>wD|~a_@_G}uLpTvC?1^^ z(?#{RQQs+f&m(VDO5W?pyAyd3qqwN;5#+U+>d{<3LEaYRHBv1xS4^#wbTwcr!(2C{ z%#}Ej554#ZZAz$3S+2J|*CzD71o__Sit_hgK|cBlWR*eDTcBt;SZ81Ph1T5`y6?-i zExXWq+XZ}IA?E1u-P`1^*`RoQ{x*pX#$8)oqsL!&k6-b8v&LVecsBTail?oG5}sP0 zzfkeiwlp=>HKRgvi@(mZY~?NUeEyo+yHE>F>l&)-+iIHXXtv|JW}p^SNWoLNxJvN- z8f_L|w3l>2T=X-x`1SrGoKu6hv>s}YTLm;!W^tP6M3=olqVY}j=$eZU)jwT5nhNzl z86Uc+Kc~2pU(_FcuE&S!8B=$o9*tpKR7M~C3{RkuzcyulREMtH@u7RDjJR$^y>?@= z$T8MYg?sb9ybcTfF!E?$Xnj#VAewWgYcz9)Z#}1rMa+BHxgOQT_s{$8b;f zpVBU*4SP=M`A8e~nbJ#;Hta2>Z$jFzpOn56X~P~;x&>*&zES!29PA`$K8- zWmWLFV!EvH*~?6;kW8Y26)d11Eg2W>^J7K=Na-h1(!%a>9+huTDSrWJ!`4m4{9Z%a zuyd3?inL+lC`|$}>>H)0V@ZZ>qjWjahFzm{6VirFqxAQYHtZFpA3)l$Qgczeo{he?8jn}}-m|6FU(@WbZf%mk66Iu5tNb;nQQDeZ+LTh7lx#}wsx`TC6S}IV zU%2wGMQdvs8(V6Xrn;tD8iamJ+9b1lcenZLlYf)?|LW(lN-JcZ1#*+_WWnj|Bm}Vz z6Hbx5&bmZVK7;ryczZ+slW-qnnDH3n9&nM$FNd)pq&Jv^9>&`l_XDZla?pgzf5CW) z@e9UDa1K;{l5qiy0Huo=D;V1tPXMXk1{gl7cZiWrB`NJ@T*P<7Q^&iDXh z8;DNj&oaKqxQp>5V>66C^{WG^elwgH;meG>8TT{(5;{QTxzGW^JjTlzS1|4ZQoqZf zBUJB6M$#2Z=P*uT9AR9EHdMZbaXsS$jOQT^q<+5*qZ)I#}e24KU zJivIvTv@Mz@u!SWGUmEv`4q-{Mr^l|m4#S=aVz8NjCR;JQO>xP@pVQ!+KO_ #include #include +#include #include "constants.h" #include "in_game.h" @@ -16,6 +17,7 @@ typedef struct PLAYER { unsigned short y; } player_t; +static bool **vis; static bool ** wmap; static bool w_mov = FALSE; static bool uK, dK, lK, rK; @@ -24,6 +26,7 @@ static player_t player; static map_cell_t ** map; game_obj_t objs[MAX_OBJECTS]; static int mW, mH, nO; +fov_settings_type fov_settings; void input(); gsname_t update(); @@ -33,6 +36,8 @@ void setPlayerStart(); void initObjects(); void drawNeon(int, int); void drawBar(int, int); +void apply(void *, int, int, int, int, void *); +bool opaque(void *, int, int); void initInGameState( gs_t * gs) { int i, j; @@ -55,6 +60,14 @@ void initInGameState( gs_t * gs) { } } + vis = ( bool ** ) malloc ( sizeof ( bool * ) * MAX_MAP_SIZE); + for ( i = 0; i < MAX_MAP_SIZE; ++i ) { + vis[ i ] = ( bool * ) calloc ( MAX_MAP_SIZE, sizeof ( bool ) ); + for(j = 0; j < MAX_MAP_SIZE; ++j){ + vis[i][j] = TRUE; + } + } + initObjects(); errcode_t rc = readMapData("map_file.map", &map, &mW, &mH); @@ -71,6 +84,10 @@ void initInGameState( gs_t * gs) { } setPlayerStart(); + + fov_settings_init(&fov_settings); + fov_settings_set_opacity_test_function(&fov_settings, opaque); + fov_settings_set_apply_lighting_function(&fov_settings, apply); } void input(){ @@ -137,6 +154,8 @@ void render(int w, int h){ ioff = (w - 28) / 2; joff = (h - 2) / 2; + fov_circle(&fov_settings, &map, NULL, player.x, player.y, (MAX_MAP_SIZE / 2) - 1); + for(i = 27; i < w - 1; i++){ for(j = 1; j < h - 1; j++){ move(j, i); @@ -147,56 +166,61 @@ void render(int w, int h){ if( di < 0 || di >= mW || dj < 0 || dj >= mH ){ printw(" "); }else{ - switch(map[dj][di].f){ - case WATER: - attron(COLOR_PAIR(DW_COLOR)); - if(w_mov) - wmap[dj][di] = !wmap[dj][di]; - if(wmap[dj][di]) - printw("\u2248"); - else - printw("~"); - break; + if(vis[dj][di]){ + switch(map[dj][di].f){ + case WATER: + attron(COLOR_PAIR(DW_COLOR)); + if(w_mov) + wmap[dj][di] = !wmap[dj][di]; + if(wmap[dj][di]) + printw("\u2248"); + else + printw("~"); + break; - case VOID: - attron(COLOR_PAIR(MN_COLOR)); - printw(" "); - break; + case VOID: + attron(COLOR_PAIR(MN_COLOR)); + printw(" "); + break; - case EMPTY_FLOOR: - attron(COLOR_PAIR(MN_COLOR)); - printw(" "); - break; + case EMPTY_FLOOR: + attron(COLOR_PAIR(MN_COLOR)); + printw(" "); + break; - case RUG: - attron(COLOR_PAIR(SN_COLOR)); - printw("\u2592"); - break; + case RUG: + attron(COLOR_PAIR(SN_COLOR)); + printw("\u2592"); + break; - case WINDOW_WALL: - attron(COLOR_PAIR(SW_COLOR)); - printw("\u2591"); - break; + case WINDOW_WALL: + attron(COLOR_PAIR(SW_COLOR)); + printw("\u2591"); + break; - case CLEAR_WALL: - attron(COLOR_PAIR(SW_COLOR)); - printw("\u2588"); - break; + case CLEAR_WALL: + attron(COLOR_PAIR(SW_COLOR)); + printw("\u2588"); + break; - case SECRET_WALL: - case SOLID_WALL: - attron(COLOR_PAIR(MN_COLOR)); - printw("\u2588"); - break; + case SECRET_WALL: + case SOLID_WALL: + attron(COLOR_PAIR(MN_COLOR)); + printw("\u2588"); + break; - case NEON_WALL: - drawNeon(dj, di); - break; + case NEON_WALL: + drawNeon(dj, di); + break; - case BAR: - drawBar(dj, di); - break; - } + case BAR: + drawBar(dj, di); + break; + } + }else{ + attron(COLOR_PAIR(MN_COLOR)); + printw(" "); + } } } } @@ -207,6 +231,12 @@ void render(int w, int h){ printw(/*"\u263A"*/ "@"); drawGui(w, h); + + for ( i = 0; i < MAX_MAP_SIZE; ++i ) { + for(j = 0; j < MAX_MAP_SIZE; ++j){ + vis[i][j] = FALSE; + } + } } void drawNeon(int i, int j){ @@ -410,3 +440,20 @@ void initObjects(){ objs[i].unlocked = 0; } } + +void apply(void *map, int x, int y, int dx, int dy, void *src){ + if(x < 0 || x >= MAX_MAP_SIZE) return; + if(y < 0 || y >= MAX_MAP_SIZE) return; + vis[y][x] = TRUE; +} + +bool opaque(void *m, int x, int y){ + if(x < 0 || x >= MAX_MAP_SIZE) return FALSE; + if(y < 0 || y >= MAX_MAP_SIZE) return FALSE; + + if(map[y][x].f == SOLID_WALL || map[y][x].f == SECRET_WALL){ + return TRUE; + }else{ + return FALSE; + } +} From 2aacbd98b949ebbd9b9b3df9266a98cb31b58a24 Mon Sep 17 00:00:00 2001 From: Miguel Angel Astor Romero Date: Thu, 6 Mar 2014 22:01:18 -0430 Subject: [PATCH 16/26] Added seen areas. --- src/in_game.c | 117 +++++++++++++++++--------------------------------- 1 file changed, 40 insertions(+), 77 deletions(-) diff --git a/src/in_game.c b/src/in_game.c index ecb91fe..b246739 100644 --- a/src/in_game.c +++ b/src/in_game.c @@ -18,6 +18,7 @@ typedef struct PLAYER { } player_t; static bool **vis; +static bool **seen; static bool ** wmap; static bool w_mov = FALSE; static bool uK, dK, lK, rK; @@ -34,8 +35,7 @@ void render(int, int); void drawGui(int, int); void setPlayerStart(); void initObjects(); -void drawNeon(int, int); -void drawBar(int, int); +void drawNeon(int, int, floor_t); void apply(void *, int, int, int, int, void *); bool opaque(void *, int, int); @@ -61,10 +61,13 @@ void initInGameState( gs_t * gs) { } vis = ( bool ** ) malloc ( sizeof ( bool * ) * MAX_MAP_SIZE); + seen = ( bool ** ) malloc ( sizeof ( bool * ) * MAX_MAP_SIZE); for ( i = 0; i < MAX_MAP_SIZE; ++i ) { vis[ i ] = ( bool * ) calloc ( MAX_MAP_SIZE, sizeof ( bool ) ); + seen[ i ] = ( bool * ) calloc ( MAX_MAP_SIZE, sizeof ( bool ) ); for(j = 0; j < MAX_MAP_SIZE; ++j){ vis[i][j] = TRUE; + seen[i][j] = FALSE; } } @@ -166,7 +169,7 @@ void render(int w, int h){ if( di < 0 || di >= mW || dj < 0 || dj >= mH ){ printw(" "); }else{ - if(vis[dj][di]){ + if(vis[dj][di] || seen[dj][di]){ switch(map[dj][di].f){ case WATER: attron(COLOR_PAIR(DW_COLOR)); @@ -179,42 +182,48 @@ void render(int w, int h){ break; case VOID: - attron(COLOR_PAIR(MN_COLOR)); + if(!vis[dj][di]) attron(COLOR_PAIR(DW_COLOR)); + else attron(COLOR_PAIR(MN_COLOR)); printw(" "); break; case EMPTY_FLOOR: - attron(COLOR_PAIR(MN_COLOR)); + if(!vis[dj][di]) attron(COLOR_PAIR(DW_COLOR)); + else attron(COLOR_PAIR(MN_COLOR)); printw(" "); break; case RUG: - attron(COLOR_PAIR(SN_COLOR)); + if(!vis[dj][di]) attron(COLOR_PAIR(DW_COLOR)); + else attron(COLOR_PAIR(SN_COLOR)); printw("\u2592"); break; case WINDOW_WALL: - attron(COLOR_PAIR(SW_COLOR)); + if(!vis[dj][di]) attron(COLOR_PAIR(DW_COLOR)); + else attron(COLOR_PAIR(SW_COLOR)); printw("\u2591"); break; case CLEAR_WALL: - attron(COLOR_PAIR(SW_COLOR)); + if(!vis[dj][di]) attron(COLOR_PAIR(DW_COLOR)); + else attron(COLOR_PAIR(SW_COLOR)); printw("\u2588"); break; case SECRET_WALL: case SOLID_WALL: - attron(COLOR_PAIR(MN_COLOR)); + if(!vis[dj][di]) attron(COLOR_PAIR(DW_COLOR)); + else attron(COLOR_PAIR(MN_COLOR)); printw("\u2588"); break; case NEON_WALL: - drawNeon(dj, di); + drawNeon(dj, di, NEON_WALL); break; case BAR: - drawBar(dj, di); + drawNeon(dj, di, BAR); break; } }else{ @@ -239,76 +248,28 @@ void render(int w, int h){ } } -void drawNeon(int i, int j){ +void drawNeon(int i, int j, floor_t floor){ + int r; bool n, s, e, w; - attron(COLOR_PAIR(FR_COLOR)); - - n = map[i ][j - 1 < 0 ? mH - 1 : j - 1].f == NEON_WALL; - s = map[i ][(j + 1) % mH ].f == NEON_WALL; - e = map[i - 1 < 0 ? mW - 1 : i - 1][j ].f == NEON_WALL; - w = map[(i + 1) % mW ][j ].f == NEON_WALL; - - if((n && s && e) && (!w)){ - printw("\u2560"); - return; + if(floor == NEON_WALL){ + if(!vis[i][j]) attron(COLOR_PAIR(DW_COLOR)); + else{ + r = rand() % 1000; + if(r < 998) + attron(COLOR_PAIR(FR_COLOR)); + else + attron(COLOR_PAIR(MN_COLOR)); + } + }else if(floor == BAR){ + if(!vis[i][j]) attron(COLOR_PAIR(DW_COLOR)); + else attron(COLOR_PAIR(SN_COLOR)); } - if((n || s) && (!e && !w)){ - printw("\u2550"); - return; - } - - if((e || w) && (!n && !s)){ - printw("\u2551"); - return; - } - - if((e && n) && (!s && !w)){ - printw("\u255D"); - return; - } - - if((w && n) && (!s && !e)){ - printw("\u2557"); - return; - } - - if((e && s) && (!n && !w)){ - printw("\u255A"); - return; - } - - if((w && s) && (!n && !e)){ - printw("\u2554"); - return; - } - - if((s && e && w) && (!n)){ - printw("\u2560"); - return; - } - - if((n && w && e) && (!s)){ - printw("\u2563"); - return; - } - - if(n && s && e && w){ - printw("\u256C"); - return; - } -} - -void drawBar(int i, int j){ - bool n, s, e, w; - - attron(COLOR_PAIR(SN_COLOR)); - - n = map[i ][j - 1 < 0 ? mH - 1 : j - 1].f == BAR; - s = map[i ][(j + 1) % mH ].f == BAR; - e = map[i - 1 < 0 ? mW - 1 : i - 1][j ].f == BAR; - w = map[(i + 1) % mW ][j ].f == BAR; + n = map[i ][j - 1 < 0 ? mH - 1 : j - 1].f == floor; + s = map[i ][(j + 1) % mH ].f == floor; + e = map[i - 1 < 0 ? mW - 1 : i - 1][j ].f == floor; + w = map[(i + 1) % mW ][j ].f == floor; if((n && s && e) && (!w)){ printw("\u2560"); @@ -444,7 +405,9 @@ void initObjects(){ void apply(void *map, int x, int y, int dx, int dy, void *src){ if(x < 0 || x >= MAX_MAP_SIZE) return; if(y < 0 || y >= MAX_MAP_SIZE) return; + vis[y][x] = TRUE; + seen[y][x] = TRUE; } bool opaque(void *m, int x, int y){ From 4f04317f0038bb2413fc0987c64020579921ef69 Mon Sep 17 00:00:00 2001 From: Miguel Angel Astor Romero Date: Sat, 8 Mar 2014 18:09:39 -0430 Subject: [PATCH 17/26] Map objects rendered and correctly used. --- include/constants.h | 6 - include/map.h | 70 ++--- src/in_game.c | 612 ++++++++++++++++++++++++++++---------------- src/main.c | 32 +-- src/map.c | 586 +++++++++++++++++++++--------------------- 5 files changed, 737 insertions(+), 569 deletions(-) diff --git a/include/constants.h b/include/constants.h index 00ec5bb..8c63b00 100644 --- a/include/constants.h +++ b/include/constants.h @@ -6,13 +6,7 @@ #ifndef STATE_CONSTS_H #define STATE_CONSTS_H -#if defined(_WIN32) || defined(_WIN64) || defined(__MINGW32__) -#define F_SEP "\\" -#elif defined(__linux__) || defined(__GNUC__) #define F_SEP "/" -#else -#error "Unrecognized system." -#endif enum COLORS { BAR_COLOR = 1, diff --git a/include/map.h b/include/map.h index d4223d0..268a01f 100644 --- a/include/map.h +++ b/include/map.h @@ -11,50 +11,50 @@ #define MAX_STR 128 typedef enum FLOOR_TYPES { - VOID = 0, - SOLID_WALL, - SECRET_WALL, - CLEAR_WALL, - NEON_WALL, - WINDOW_WALL, - EMPTY_FLOOR, - RUG, - WATER, - BAR - } floor_t; + VOID = 0, + SOLID_WALL, + SECRET_WALL, + CLEAR_WALL, + NEON_WALL, + WINDOW_WALL, + EMPTY_FLOOR, + RUG, + WATER, + BAR + } floor_t; typedef enum OBJECT_TYPES { - DOOR = 0, - KEY, - PERSON, - PLAYER_START, - EXIT, - DIALOG, - NONE = 9989 - } obj_t; + DOOR = 0, + KEY, + PERSON, + PLAYER_START, + EXIT, + DIALOG, + NONE = 9989 + } obj_t; typedef enum ERROR_CODES { - NO_ERROR = 0, - FILE_NOT_FOUND, - OUT_OF_MEMORY, - PREMATURE_EOF, - MAP_TOO_LARGE, - INVALID_KEY - } errcode_t; + NO_ERROR = 0, + FILE_NOT_FOUND, + OUT_OF_MEMORY, + PREMATURE_EOF, + MAP_TOO_LARGE, + INVALID_KEY + } errcode_t; typedef struct MAP_CELL{ - floor_t f; + floor_t f; } map_cell_t; typedef struct OBJECT { - obj_t type; - short x, y, eX, eY, sX, sY; - short id; - short dId; - char name[MAX_STR]; - char target[MAX_STR]; - char dialog[MAX_STR]; - unsigned char unlocked; + obj_t type; + short x, y, eX, eY, sX, sY; + short id; + short dId; + char name[MAX_STR]; + char target[MAX_STR]; + char dialog[MAX_STR]; + unsigned char unlocked; } game_obj_t; extern errcode_t readMapData(const char *, map_cell_t ***, int *, int *); diff --git a/src/in_game.c b/src/in_game.c index b246739..8feb08b 100644 --- a/src/in_game.c +++ b/src/in_game.c @@ -12,6 +12,13 @@ #include "in_game.h" #include "map.h" +#define MAX_KEYS 15 + +static const char *keyMsg = "You picked up a key."; +static const char *saysMsg = " says: "; +static const char *openDoor = "The door opens."; +static const char *doorLock = "This door is locked."; + typedef struct PLAYER { unsigned short x; unsigned short y; @@ -22,12 +29,16 @@ static bool **seen; static bool ** wmap; static bool w_mov = FALSE; static bool uK, dK, lK, rK; -static clock_t then; +static clock_t then, msgThen; static player_t player; static map_cell_t ** map; -game_obj_t objs[MAX_OBJECTS]; +static game_obj_t objs[MAX_OBJECTS]; static int mW, mH, nO; -fov_settings_type fov_settings; +static fov_settings_type fov_settings; +static int keys[MAX_KEYS]; +static int freeKey; +static char msg[128]; +static bool newMsg = FALSE; void input(); gsname_t update(); @@ -35,9 +46,12 @@ void render(int, int); void drawGui(int, int); void setPlayerStart(); void initObjects(); +void initKeys(); void drawNeon(int, int, floor_t); void apply(void *, int, int, int, int, void *); bool opaque(void *, int, int); +void loadMap(const char *); +bool canMoveTo(int, int); void initInGameState( gs_t * gs) { int i, j; @@ -47,12 +61,12 @@ void initInGameState( gs_t * gs) { gs->update = &update; gs->render = &render; - map = ( map_cell_t ** ) malloc ( sizeof ( map_cell_t * ) * MAX_MAP_SIZE); + map = ( map_cell_t ** ) malloc ( sizeof ( map_cell_t * ) * MAX_MAP_SIZE); for ( i = 0; i < MAX_MAP_SIZE; ++i ) { map[ i ] = ( map_cell_t * ) calloc ( MAX_MAP_SIZE , sizeof ( map_cell_t ) ); } - wmap = ( bool ** ) malloc ( sizeof ( bool * ) * MAX_MAP_SIZE); + wmap = ( bool ** ) malloc ( sizeof ( bool * ) * MAX_MAP_SIZE); for ( i = 0; i < MAX_MAP_SIZE; ++i ) { wmap[ i ] = ( bool * ) calloc ( MAX_MAP_SIZE, sizeof ( bool ) ); for(j = 0; j < MAX_MAP_SIZE; ++j){ @@ -60,37 +74,23 @@ void initInGameState( gs_t * gs) { } } - vis = ( bool ** ) malloc ( sizeof ( bool * ) * MAX_MAP_SIZE); - seen = ( bool ** ) malloc ( sizeof ( bool * ) * MAX_MAP_SIZE); + vis = ( bool ** ) malloc ( sizeof ( bool * ) * MAX_MAP_SIZE); + seen = ( bool ** ) malloc ( sizeof ( bool * ) * MAX_MAP_SIZE); for ( i = 0; i < MAX_MAP_SIZE; ++i ) { vis[ i ] = ( bool * ) calloc ( MAX_MAP_SIZE, sizeof ( bool ) ); - seen[ i ] = ( bool * ) calloc ( MAX_MAP_SIZE, sizeof ( bool ) ); + seen[ i ] = ( bool * ) calloc ( MAX_MAP_SIZE, sizeof ( bool ) ); for(j = 0; j < MAX_MAP_SIZE; ++j){ vis[i][j] = TRUE; - seen[i][j] = FALSE; + seen[i][j] = FALSE; } } - initObjects(); + initObjects(); + loadMap("map_file.map"); - errcode_t rc = readMapData("map_file.map", &map, &mW, &mH); - if(rc != NO_ERROR){ - fprintf(stderr, "\t%s: readMapData() returned %d\n", __FILE__, rc); - exit(rc); - } - - game_obj_t * objsP = objs; - rc = readMapObjects("map_file.map", &objsP, &nO); - if(rc != NO_ERROR){ - fprintf(stderr, "\t%s: readMapObjects() returned %d\n", __FILE__, rc); - exit(rc); - } - - setPlayerStart(); - - fov_settings_init(&fov_settings); - fov_settings_set_opacity_test_function(&fov_settings, opaque); - fov_settings_set_apply_lighting_function(&fov_settings, apply); + fov_settings_init(&fov_settings); + fov_settings_set_opacity_test_function(&fov_settings, opaque); + fov_settings_set_apply_lighting_function(&fov_settings, apply); } void input(){ @@ -99,7 +99,6 @@ void input(){ key = getch(); if(key != ERR){ - fprintf(stderr, "\t%s: Caught keycode %d\n", __FILE__, key); if(key == KEY_UP) uK = TRUE; if(key == KEY_DOWN) dK = TRUE; if(key == KEY_LEFT) lK = TRUE; @@ -108,32 +107,133 @@ void input(){ } gsname_t update(){ - int iX, iY; + clock_t msgNow, delta; + int i, j, k, d, iX, iY, nX, nY; - iX = player.x; - iY = player.y; + iX = player.x; + iY = player.y; + nX = iX; + nY = iY; + if(uK) nY = iY - 1 < 0 ? mH - 1 : iY - 1; + + if(dK) nY = (iY + 1) % mH; + + if(lK) nX = iX - 1 < 0 ? mW - 1 : iX - 1; + + if(rK) nX = (iX + 1) % mW; + + /* Find if the player is standing on an exit, then load the next map. */ + for(i = 0; i < nO; i++){ + if(objs[i].type == EXIT){ + if(objs[i].x == iY && objs[i].y == iX){ + player.x = objs[i].eX; + player.y = objs[i].eY; + loadMap(objs[i].target); + return IN_GAME; + } + } + } + + /* TODO: use keys.*/ + for(i = 0; i < nO; i++){ + if(objs[i].type == KEY){ + if(objs[i].x == iY && objs[i].y == iX){ + keys[freeKey] = objs[i].id; + objs[i].type = NONE; + for(j = 0; keyMsg[j] && j < 128; j++){ + msg[j] = keyMsg[j]; + } + newMsg = TRUE; + msgThen = clock(); + } + } + } + + /* Listen to a person. */ + for(i = 0; i < nO; i++){ + if(objs[i].type == PERSON){ + if(objs[i].x == nY && objs[i].y == nX){ + for(k = 0; k < nO; k++) + if(objs[k].type == DIALOG && objs[k].id == objs[i].dId) break; + + for(j = 0; objs[i].name[j] && j < 128; j++) + msg[j] = objs[i].name[j]; + + for(d = 0; saysMsg[d] && j < 128; j++, d++) + msg[j] = saysMsg[d]; + + for(d = 0; objs[k].dialog[d] && j < 128; j++, d++) + msg[j] = objs[k].dialog[d]; + + newMsg = TRUE; + msgThen = clock(); + } + } + } + + for(i = 0; i < nO; i++){ + if(objs[i].type == DOOR){ + if(objs[i].x == nY && objs[i].y == nX){ + if(!objs[i].unlocked){ + for(j = 0; j < MAX_KEYS; j++){ + if(keys[j] == objs[i].id){ + objs[i].unlocked = 1; + break; + } + } + + if(objs[i].unlocked){ + for(j = 0; openDoor[j] && j < 128; j++){ + msg[j] = openDoor[j]; + } + }else{ + for(j = 0; doorLock[j] && j < 128; j++){ + msg[j] = doorLock[j]; + } + } + + newMsg = TRUE; + msgThen = clock(); + } + } + } + } + + if(newMsg){ + msgNow = clock(); + delta = msgNow - msgThen; + if((int)delta / (int)CLOCKS_PER_SEC >= 4){ + msgThen = msgNow; + for(j = 0; j < 128; j++){ + msg[j] = '\0'; + } + newMsg = FALSE; + } + } + + /* Move the player. */ if(uK){ - iY = iY - 1 < 0 ? mH - 1 : iY - 1; - if((map[iY][iX].f > WINDOW_WALL && map[iY][iX].f <= WATER) || map[iY][iX].f == SECRET_WALL) player.y = iY; + iY = iY - 1 < 0 ? mH - 1 : iY - 1; + if(canMoveTo(iY, iX)) player.y = iY; uK = FALSE; } if(dK){ - iY = (iY + 1) % mH; - if((map[iY][iX].f > WINDOW_WALL && map[iY][iX].f <= WATER) || map[iY][iX].f == SECRET_WALL) player.y = iY; + iY = (iY + 1) % mH; + if(canMoveTo(iY, iX)) player.y = iY; dK = FALSE; } if(lK){ - iX = iX - 1 < 0 ? mW - 1 : iX - 1; - if((map[iY][iX].f > WINDOW_WALL && map[iY][iX].f <= WATER) || map[iY][iX].f == SECRET_WALL) player.x = iX; + iX = iX - 1 < 0 ? mW - 1 : iX - 1; + if(canMoveTo(iY, iX)) player.x = iX; lK = FALSE; } if(rK){ - iX = (iX + 1) % mW; - if((map[iY][iX].f > WINDOW_WALL && map[iY][iX].f <= WATER) || map[iY][iX].f == SECRET_WALL) player.x = iX; + iX = (iX + 1) % mW; + if(canMoveTo(iY, iX)) player.x = iX; rK = FALSE; } @@ -142,7 +242,7 @@ gsname_t update(){ void render(int w, int h){ clock_t now, delta; - int i, j, pi, pj, ioff, joff, di, dj; + int i, j, k, pi, pj, ioff, joff, di, dj; now = clock(); delta = now - then; @@ -151,16 +251,16 @@ void render(int w, int h){ w_mov = TRUE; } - pi = (((w - 1) - 27) / 2) + 27; - pj = (h - 2) / 2 + 1; + pi = (((w - 1) - 1) / 2) + 1; + pj = (h - 3) / 2 + 1; - ioff = (w - 28) / 2; - joff = (h - 2) / 2; + ioff = (w - 28 - 27) / 2; + joff = (h - 3) / 2; - fov_circle(&fov_settings, &map, NULL, player.x, player.y, (MAX_MAP_SIZE / 2) - 1); + fov_circle(&fov_settings, &map, NULL, player.x, player.y, (MAX_MAP_SIZE / 2) - 1); - for(i = 27; i < w - 1; i++){ - for(j = 1; j < h - 1; j++){ + for(i = 1; i < w - 1; i++){ + for(j = 1; j < h - 3; j++){ move(j, i); di = i - 27 + player.x - ioff; @@ -169,67 +269,84 @@ void render(int w, int h){ if( di < 0 || di >= mW || dj < 0 || dj >= mH ){ printw(" "); }else{ - if(vis[dj][di] || seen[dj][di]){ - switch(map[dj][di].f){ - case WATER: - attron(COLOR_PAIR(DW_COLOR)); - if(w_mov) - wmap[dj][di] = !wmap[dj][di]; - if(wmap[dj][di]) - printw("\u2248"); - else - printw("~"); - break; + if(vis[dj][di] || seen[dj][di]){ + switch(map[dj][di].f){ + case WATER: + attron(COLOR_PAIR(DW_COLOR)); + if(w_mov) + wmap[dj][di] = !wmap[dj][di]; + if(wmap[dj][di]) + printw("\u2248"); + else + printw("~"); + break; - case VOID: - if(!vis[dj][di]) attron(COLOR_PAIR(DW_COLOR)); - else attron(COLOR_PAIR(MN_COLOR)); - printw(" "); - break; + case VOID: + if(!vis[dj][di]) attron(COLOR_PAIR(DW_COLOR)); + else attron(COLOR_PAIR(MN_COLOR)); + printw(" "); + break; - case EMPTY_FLOOR: - if(!vis[dj][di]) attron(COLOR_PAIR(DW_COLOR)); - else attron(COLOR_PAIR(MN_COLOR)); - printw(" "); - break; + case EMPTY_FLOOR: + if(!vis[dj][di]) attron(COLOR_PAIR(DW_COLOR)); + else attron(COLOR_PAIR(MN_COLOR)); + printw(" "); + break; - case RUG: - if(!vis[dj][di]) attron(COLOR_PAIR(DW_COLOR)); - else attron(COLOR_PAIR(SN_COLOR)); - printw("\u2592"); - break; + case RUG: + if(!vis[dj][di]) attron(COLOR_PAIR(DW_COLOR)); + else attron(COLOR_PAIR(SN_COLOR)); + printw("\u2592"); + break; - case WINDOW_WALL: - if(!vis[dj][di]) attron(COLOR_PAIR(DW_COLOR)); - else attron(COLOR_PAIR(SW_COLOR)); - printw("\u2591"); - break; + case WINDOW_WALL: + if(!vis[dj][di]) attron(COLOR_PAIR(DW_COLOR)); + else attron(COLOR_PAIR(SW_COLOR)); + printw("\u2591"); + break; - case CLEAR_WALL: - if(!vis[dj][di]) attron(COLOR_PAIR(DW_COLOR)); - else attron(COLOR_PAIR(SW_COLOR)); - printw("\u2588"); - break; + case CLEAR_WALL: + if(!vis[dj][di]) attron(COLOR_PAIR(DW_COLOR)); + else attron(COLOR_PAIR(SW_COLOR)); + printw("\u2588"); + break; - case SECRET_WALL: - case SOLID_WALL: - if(!vis[dj][di]) attron(COLOR_PAIR(DW_COLOR)); - else attron(COLOR_PAIR(MN_COLOR)); - printw("\u2588"); - break; + case SECRET_WALL: + case SOLID_WALL: + if(!vis[dj][di]) attron(COLOR_PAIR(DW_COLOR)); + else attron(COLOR_PAIR(MN_COLOR)); + printw("\u2588"); + break; - case NEON_WALL: - drawNeon(dj, di, NEON_WALL); - break; + case NEON_WALL: + drawNeon(dj, di, NEON_WALL); + break; - case BAR: - drawNeon(dj, di, BAR); - break; - } - }else{ - attron(COLOR_PAIR(MN_COLOR)); - printw(" "); - } + case BAR: + drawNeon(dj, di, BAR); + break; + } + + move(j, i); + for(k = 0; k < nO; k++){ + if(objs[k].x == dj && objs[k].y == di){ + if(!vis[dj][di]) attron(COLOR_PAIR(DW_COLOR)); + else attron(COLOR_PAIR(MN_COLOR)); + + if(objs[k].type == DOOR){ + printw("\u25D9"); + }else if(objs[k].type == KEY){ + printw("k"); + }else if(objs[k].type == PERSON){ + printw("\u263A"); + } + } + } + + }else{ + attron(COLOR_PAIR(MN_COLOR)); + printw(" "); + } } } } @@ -241,7 +358,7 @@ void render(int w, int h){ drawGui(w, h); - for ( i = 0; i < MAX_MAP_SIZE; ++i ) { + for ( i = 0; i < MAX_MAP_SIZE; ++i ) { for(j = 0; j < MAX_MAP_SIZE; ++j){ vis[i][j] = FALSE; } @@ -249,174 +366,241 @@ void render(int w, int h){ } void drawNeon(int i, int j, floor_t floor){ - int r; - bool n, s, e, w; + int r; + bool n, s, e, w; - if(floor == NEON_WALL){ - if(!vis[i][j]) attron(COLOR_PAIR(DW_COLOR)); - else{ - r = rand() % 1000; - if(r < 998) - attron(COLOR_PAIR(FR_COLOR)); - else - attron(COLOR_PAIR(MN_COLOR)); - } - }else if(floor == BAR){ - if(!vis[i][j]) attron(COLOR_PAIR(DW_COLOR)); - else attron(COLOR_PAIR(SN_COLOR)); - } + if(floor == NEON_WALL){ + if(!vis[i][j]) attron(COLOR_PAIR(DW_COLOR)); + else{ + r = rand() % 1000; + if(r < 998) + attron(COLOR_PAIR(FR_COLOR)); + else + attron(COLOR_PAIR(MN_COLOR)); + } + }else if(floor == BAR){ + if(!vis[i][j]) attron(COLOR_PAIR(DW_COLOR)); + else attron(COLOR_PAIR(SN_COLOR)); + } - n = map[i ][j - 1 < 0 ? mH - 1 : j - 1].f == floor; - s = map[i ][(j + 1) % mH ].f == floor; - e = map[i - 1 < 0 ? mW - 1 : i - 1][j ].f == floor; - w = map[(i + 1) % mW ][j ].f == floor; + n = map[i ][j - 1 < 0 ? mH - 1 : j - 1].f == floor; + s = map[i ][(j + 1) % mH ].f == floor; + e = map[i - 1 < 0 ? mW - 1 : i - 1][j ].f == floor; + w = map[(i + 1) % mW ][j ].f == floor; - if((n && s && e) && (!w)){ - printw("\u2560"); - return; - } + if((n && s && e) && (!w)){ + printw("\u2560"); + return; + } - if((n || s) && (!e && !w)){ - printw("\u2550"); - return; - } + if((n || s) && (!e && !w)){ + printw("\u2550"); + return; + } - if((e || w) && (!n && !s)){ - printw("\u2551"); - return; - } + if((e || w) && (!n && !s)){ + printw("\u2551"); + return; + } - if((e && n) && (!s && !w)){ - printw("\u255D"); - return; - } + if((e && n) && (!s && !w)){ + printw("\u255D"); + return; + } - if((w && n) && (!s && !e)){ - printw("\u2557"); - return; - } + if((w && n) && (!s && !e)){ + printw("\u2557"); + return; + } - if((e && s) && (!n && !w)){ - printw("\u255A"); - return; - } + if((e && s) && (!n && !w)){ + printw("\u255A"); + return; + } - if((w && s) && (!n && !e)){ - printw("\u2554"); - return; - } + if((w && s) && (!n && !e)){ + printw("\u2554"); + return; + } - if((s && e && w) && (!n)){ - printw("\u2560"); - return; - } + if((s && e && w) && (!n)){ + printw("\u2560"); + return; + } - if((n && w && e) && (!s)){ - printw("\u2563"); - return; - } + if((n && w && e) && (!s)){ + printw("\u2563"); + return; + } - if(n && s && e && w){ - printw("\u256C"); - return; - } + if(n && s && e && w){ + printw("\u256C"); + return; + } } void drawGui(int w, int h){ - int i, j; + int i; attron(COLOR_PAIR(BSC_COLOR)); /* Clear the gui space. */ - for(i = 1; i < 26; i++){ - for(j = 1; j < h - 1; j++){ - move(j, i); - printw(" "); - } + for(i = 1; i < w - 1; i++){ + move(h - 2, i); + printw(" "); } /* Upper horizontal bar. */ move(0, 0); printw("\u2554"); for(i = 0; i < w - 2; i++){ - if(i != 25){ - printw("\u2550"); - }else{ - printw("\u2566"); - } + printw("\u2550"); } printw("\u2557"); - /* Lower horizontal bar. */ + /* Lower horizontal bars. */ + move(h - 3, 0); + printw("\u255A"); + for(i = 0; i < w - 2; i++){ + printw("\u2550"); + } + printw("\u255D"); + move(h - 1, 0); printw("\u255A"); for(i = 0; i < w - 2; i++){ - if(i != 25){ - printw("\u2550"); - }else{ - printw("\u2569"); - } + printw("\u2550"); } printw("\u255D"); /* Vertical bars. */ for(i = 1; i < h - 1; i++){ move(i, 0); - printw("\u2551"); - move(i, 26); - printw("\u2551"); + if(i != h - 3) printw("\u2551"); + else printw("\u2560"); move(i, w-1); - printw("\u2551"); + if(i != h - 3) printw("\u2551"); + else printw("\u2563"); + } + + move(h - 2, 1); + for(i = 0; msg[i] && i < w - 2; i++){ + printw("%c", msg[i]); } } void setPlayerStart(){ int i; - for(i = 0; i < nO; i++){ - if(objs[i].type == PLAYER_START){ - player.y = objs[i].sX; - player.x = objs[i].sY; - break; - } - } + for(i = 0; i < nO; i++){ + if(objs[i].type == PLAYER_START){ + player.y = objs[i].sX; + player.x = objs[i].sY; + break; + } + } } void initObjects(){ - int i; + int i; - for(i = 0; i < MAX_OBJECTS; ++i){ - objs[i].type = NONE; - objs[i].x = 0; - objs[i].y = 0; - objs[i].eX = 0; - objs[i].eY = 0; - objs[i].sX = 0; - objs[i].sY = 0; - objs[i].id = 0; - objs[i].dId = 0; - objs[i].name[0] = '\0'; - objs[i].target[0] = '\0'; - objs[i].dialog[0] = '\0'; - objs[i].unlocked = 0; - } + for(i = 0; i < MAX_OBJECTS; ++i){ + objs[i].type = NONE; + objs[i].x = 0; + objs[i].y = 0; + objs[i].eX = 0; + objs[i].eY = 0; + objs[i].sX = 0; + objs[i].sY = 0; + objs[i].id = 0; + objs[i].dId = 0; + objs[i].name[0] = '\0'; + objs[i].target[0] = '\0'; + objs[i].dialog[0] = '\0'; + objs[i].unlocked = 0; + } +} + +void initKeys(){ + int i; + + freeKey = 0; + for(i = 0; i < MAX_KEYS; ++i){ + keys[i] = -1; + } } void apply(void *map, int x, int y, int dx, int dy, void *src){ - if(x < 0 || x >= MAX_MAP_SIZE) return; - if(y < 0 || y >= MAX_MAP_SIZE) return; + if(x < 0 || x >= MAX_MAP_SIZE) return; + if(y < 0 || y >= MAX_MAP_SIZE) return; vis[y][x] = TRUE; - seen[y][x] = TRUE; + seen[y][x] = TRUE; } bool opaque(void *m, int x, int y){ - if(x < 0 || x >= MAX_MAP_SIZE) return FALSE; - if(y < 0 || y >= MAX_MAP_SIZE) return FALSE; + int k; + if(x < 0 || x >= MAX_MAP_SIZE) return FALSE; + if(y < 0 || y >= MAX_MAP_SIZE) return FALSE; if(map[y][x].f == SOLID_WALL || map[y][x].f == SECRET_WALL){ - return TRUE; - }else{ - return FALSE; - } + return TRUE; + }else{ + for(k = 0; k < nO; k++){ + if(objs[k].type == DOOR){ + if(objs[k].x == y && objs[k].y == x){ + return TRUE; + } + } + } + + return FALSE; + } +} + +void loadMap(const char * file){ + int i, j; + + errcode_t rc = readMapData(file, &map, &mW, &mH); + if(rc != NO_ERROR){ + fprintf(stderr, "\t%s.loadMap(): readMapData() returned %d\n", __FILE__, rc); + exit(rc); + } + + game_obj_t * objsP = objs; + rc = readMapObjects(file, &objsP, &nO); + if(rc != NO_ERROR){ + fprintf(stderr, "\t%s.loadMap(): readMapObjects() returned %d\n", __FILE__, rc); + exit(rc); + } + + setPlayerStart(); + initKeys(); + + for ( i = 0; i < MAX_MAP_SIZE; ++i ) { + for(j = 0; j < MAX_MAP_SIZE; ++j){ + vis[i][j] = FALSE; + seen[i][j] = FALSE; + } + } +} + +bool canMoveTo(int iY, int iX){ + int k; + + for(k = 0; k < nO; k++){ + if(objs[k].x == iY && objs[k].y == iX){ + if(objs[k].type == DOOR){ + if(objs[k].unlocked) return TRUE; + else return FALSE; + }else if(objs[k].type == PERSON){ + return FALSE; + } + } + } + + if((map[iY][iX].f > WINDOW_WALL && map[iY][iX].f <= WATER) || map[iY][iX].f == SECRET_WALL) + return TRUE; + else + return FALSE; } diff --git a/src/main.c b/src/main.c index 34a1b44..5578155 100644 --- a/src/main.c +++ b/src/main.c @@ -28,22 +28,16 @@ static bool resize = FALSE; int main() { bool finished = FALSE; -#if defined(_WIN32) || defined(_WIN64) || defined(__MINGW32__) - char * home_dir = getenv("APPDATA"); -#elif defined(__linux__) || defined(__GNUC__) - char * home_dir = getenv("HOME"); -#else -#error "Unrecognized system." -#endif - FILE * f; /* To avoid a warning. */ - clock_t then, now, delta; - unsigned int fps = 0, pfps = 0; - char * data_dir; - char * log_file; - time_t raw_date; - struct tm * current_date; - gs_t * states; - int c_state; + char * home_dir = getenv("HOME"); + FILE * f; /* To avoid a warning. */ + clock_t then, now, delta; + unsigned int fps = 0, pfps = 0; + char * data_dir; + char * log_file; + time_t raw_date; + struct tm * current_date; + gs_t * states; + int c_state; atexit(leave); signal(SIGINT, manage_signal); @@ -70,15 +64,11 @@ int main() { fprintf(stderr, "%s", asctime(current_date)); /* Try to create the data directory with permissions 775. */ - if(mkdir(data_dir, S_IRWXU | S_IWGRP | S_IRGRP| S_IROTH | S_IXOTH) == 0){ - /* The data directory was sucessfully created. */ - }else{ + if(mkdir(data_dir, S_IRWXU | S_IWGRP | S_IRGRP| S_IROTH | S_IXOTH) != 0){ if(errno != EEXIST){ /* The directory does not exists and could not be created. */ perror("\t" __FILE__); fprintf(stderr, "\tdata_dir is: %s\n", data_dir); - }else{ - /* The directory already exits. */ } } }else{ diff --git a/src/map.c b/src/map.c index df52593..494b0f4 100644 --- a/src/map.c +++ b/src/map.c @@ -11,360 +11,360 @@ #include "map.h" errcode_t readMapData(const char * file, map_cell_t *** map, int * w, int * h){ - size_t n = 2048; - char *buffer; - FILE * f; + size_t n = 2048; + char *buffer; + FILE * f; - f = fopen(file, "r"); - if(f == NULL) return FILE_NOT_FOUND; + f = fopen(file, "r"); + if(f == NULL) return FILE_NOT_FOUND; - buffer = (char*)calloc(n + 1, sizeof(char)); - if(buffer == NULL) return OUT_OF_MEMORY; + buffer = (char*)calloc(n + 1, sizeof(char)); + if(buffer == NULL) return OUT_OF_MEMORY; - while(getline(&buffer, &n, f) != -1){ - if(strcmp(buffer, "[MAP]\n") == 0){ - int rc, i, j; - char *end; + while(getline(&buffer, &n, f) != -1){ + if(strcmp(buffer, "[MAP]\n") == 0){ + int rc, i, j; + char *end; - fprintf(stderr, "\t%s.readMapData() : found a map.\n", __FILE__); + fprintf(stderr, "\t%s.readMapData() : found a map.\n", __FILE__); - rc = getline(&buffer, &n, f); - if(rc == -1){ - free(buffer); - return PREMATURE_EOF; - } + rc = getline(&buffer, &n, f); + if(rc == -1){ + free(buffer); + return PREMATURE_EOF; + } - *w = strtol(buffer, &end, 10); - *h = strtol(end, NULL, 10); + *w = strtol(buffer, &end, 10); + *h = strtol(end, NULL, 10); - if((*w <= 0 || *w > MAX_MAP_SIZE) || (*h <= 0 || *h > MAX_MAP_SIZE)){ - *w = -1; - *h = -1; - free(buffer); - return MAP_TOO_LARGE; - } + if((*w <= 0 || *w > MAX_MAP_SIZE) || (*h <= 0 || *h > MAX_MAP_SIZE)){ + *w = -1; + *h = -1; + free(buffer); + return MAP_TOO_LARGE; + } - for(i = 0; i < *w; i++){ - rc = getline(&buffer, &n, f); - if(rc == -1){ - free(buffer); - return PREMATURE_EOF; - } + for(i = 0; i < *w; i++){ + rc = getline(&buffer, &n, f); + if(rc == -1){ + free(buffer); + return PREMATURE_EOF; + } - /* Skip commentaries. */ - if(buffer[0] == '%'){ - i--; - continue; - } + /* Skip commentaries. */ + if(buffer[0] == '%'){ + i--; + continue; + } - for(j = 0; buffer[j] && j < *h; j++){ - if(buffer[j] >= '0' && buffer[j] <= '9'){ - switch(buffer[j]){ - case '0': (*map)[i][j].f = VOID; break; - case '1': (*map)[i][j].f = SOLID_WALL; break; - case '2': (*map)[i][j].f = SECRET_WALL; break; - case '3': (*map)[i][j].f = CLEAR_WALL; break; - case '4': (*map)[i][j].f = NEON_WALL; break; - case '5': (*map)[i][j].f = WINDOW_WALL; break; - case '6': (*map)[i][j].f = EMPTY_FLOOR; break; - case '7': (*map)[i][j].f = RUG; break; - case '8': (*map)[i][j].f = WATER; break; - case '9': (*map)[i][j].f = BAR; break; - default: - fprintf(stderr, "\t%s.readMapData() : Invalid character %c in map file %s\n", __FILE__, buffer[j], file); - (*map)[i][j].f = VOID; - break; - } - }else{ - fprintf(stderr, "\t%s.readMapData() : Invalid character %c in map file %s\n", __FILE__, buffer[j], file); - (*map)[i][j].f = VOID; - } - } - } - /* Skip the rest of the file. */ - break; - } - } + for(j = 0; buffer[j] && j < *h; j++){ + if(buffer[j] >= '0' && buffer[j] <= '9'){ + switch(buffer[j]){ + case '0': (*map)[i][j].f = VOID; break; + case '1': (*map)[i][j].f = SOLID_WALL; break; + case '2': (*map)[i][j].f = SECRET_WALL; break; + case '3': (*map)[i][j].f = CLEAR_WALL; break; + case '4': (*map)[i][j].f = NEON_WALL; break; + case '5': (*map)[i][j].f = WINDOW_WALL; break; + case '6': (*map)[i][j].f = EMPTY_FLOOR; break; + case '7': (*map)[i][j].f = RUG; break; + case '8': (*map)[i][j].f = WATER; break; + case '9': (*map)[i][j].f = BAR; break; + default: + fprintf(stderr, "\t%s.readMapData() : Invalid character %c in map file %s\n", __FILE__, buffer[j], file); + (*map)[i][j].f = VOID; + break; + } + }else{ + fprintf(stderr, "\t%s.readMapData() : Invalid character %c in map file %s\n", __FILE__, buffer[j], file); + (*map)[i][j].f = VOID; + } + } + } + /* Skip the rest of the file. */ + break; + } + } - fclose(f); - free(buffer); + fclose(f); + free(buffer); - return NO_ERROR; + return NO_ERROR; } errcode_t readMapObjects(const char * file, game_obj_t ** objArr, int *nObj){ - size_t n = 2048; - int rc; - char *buffer; - FILE * f; + size_t n = 2048; + int rc; + char *buffer; + FILE * f; - *nObj = 0; + *nObj = 0; - f = fopen(file, "r"); - if(f == NULL) return FILE_NOT_FOUND; + f = fopen(file, "r"); + if(f == NULL) return FILE_NOT_FOUND; - buffer = (char*)calloc(n + 1, sizeof(char)); - if(buffer == NULL) return OUT_OF_MEMORY; + buffer = (char*)calloc(n + 1, sizeof(char)); + if(buffer == NULL) return OUT_OF_MEMORY; - rc = getline(&buffer, &n, f); - if(rc == -1){ - free(buffer); - return PREMATURE_EOF; - } + rc = getline(&buffer, &n, f); + if(rc == -1){ + free(buffer); + return PREMATURE_EOF; + } - while(*nObj < MAX_OBJECTS && rc != -1){ - if(buffer[0] == '%') continue; + while(*nObj < MAX_OBJECTS && rc != -1){ + if(buffer[0] == '%') continue; - if(strcmp(buffer, "[MAP]\n") == 0){ - int i, w; + if(strcmp(buffer, "[MAP]\n") == 0){ + int i, w; - rc = getline(&buffer, &n, f); - if(rc == -1){ - free(buffer); - return PREMATURE_EOF; - } + rc = getline(&buffer, &n, f); + if(rc == -1){ + free(buffer); + return PREMATURE_EOF; + } - w = strtol(buffer, NULL, 10); + w = strtol(buffer, NULL, 10); - for(i = 0; i <= w; ++i){ - rc = getline(&buffer, &n, f); - if(rc == -1){ - free(buffer); - return PREMATURE_EOF; - } - } + for(i = 0; i <= w; ++i){ + rc = getline(&buffer, &n, f); + if(rc == -1){ + free(buffer); + return PREMATURE_EOF; + } + } - }else if(strcmp(buffer, "[PLAYER]\n") == 0){ - do{ - rc = getline(&buffer, &n, f); - if(rc == -1) break; + }else if(strcmp(buffer, "[PLAYER]\n") == 0){ + do{ + rc = getline(&buffer, &n, f); + if(rc == -1) break; - if(buffer[0] == '%') continue; - else if(buffer[0] == 'p'){ - int i; + if(buffer[0] == '%') continue; + else if(buffer[0] == 'p'){ + int i; - for(i = 0; buffer[i] && buffer[i] != '='; ++i); - - if(strncmp(buffer, "player =", i) == 0){ - int sX, sY; - char *end; - - sX = strtol(&buffer[i + 1], &end, 10); - sY = strtol(end, NULL, 10); + for(i = 0; buffer[i] && buffer[i] != '='; ++i); + + if(strncmp(buffer, "player =", i) == 0){ + int sX, sY; + char *end; + + sX = strtol(&buffer[i + 1], &end, 10); + sY = strtol(end, NULL, 10); - (*objArr)[*nObj].type = PLAYER_START; - (*objArr)[*nObj].sX = sX; - (*objArr)[*nObj].sY = sY; + (*objArr)[*nObj].type = PLAYER_START; + (*objArr)[*nObj].sX = sX; + (*objArr)[*nObj].sY = sY; - *nObj += 1; + *nObj += 1; - }else{ - fprintf(stderr, "\t%s.readMapObjects(): Skipped invalid data in PLAYER key in map file %s.\n", __FILE__, file); - fprintf(stderr, "\t%s.readMapObjects(): The invalid line is %s.\n", __FILE__, buffer); - continue; - } - } - }while(buffer[0] != '['); + }else{ + fprintf(stderr, "\t%s.readMapObjects(): Skipped invalid data in PLAYER key in map file %s.\n", __FILE__, file); + fprintf(stderr, "\t%s.readMapObjects(): The invalid line is %s.\n", __FILE__, buffer); + continue; + } + } + }while(buffer[0] != '['); - }else if(strcmp(buffer, "[EXITS]\n") == 0){ - do{ - rc = getline(&buffer, &n, f); - if(rc == -1) break; + }else if(strcmp(buffer, "[EXITS]\n") == 0){ + do{ + rc = getline(&buffer, &n, f); + if(rc == -1) break; - if(buffer[0] == '%') continue; - else if(buffer[0] == 'e'){ - int i; + if(buffer[0] == '%') continue; + else if(buffer[0] == 'e'){ + int i; - for(i = 0; buffer[i] && buffer[i] != '='; ++i); - - if(strncmp(buffer, "exit =", i) == 0){ - int x, y, eX, eY; - char *end, *end2, *end3; - - x = strtol(&buffer[i + 1], &end, 10); - y = strtol(end, &end2, 10); - end2++; - - (*objArr)[*nObj].type = EXIT; - (*objArr)[*nObj].x = x; - (*objArr)[*nObj].y = y; - - for(i = 0; end2[i] && end2[i] != ' '; ++i); + for(i = 0; buffer[i] && buffer[i] != '='; ++i); + + if(strncmp(buffer, "exit =", i) == 0){ + int x, y, eX, eY; + char *end, *end2, *end3; + + x = strtol(&buffer[i + 1], &end, 10); + y = strtol(end, &end2, 10); + end2++; + + (*objArr)[*nObj].type = EXIT; + (*objArr)[*nObj].x = x; + (*objArr)[*nObj].y = y; + + for(i = 0; end2[i] && end2[i] != ' '; ++i); - strncpy((*objArr)[*nObj].target, end2, i); - (*objArr)[*nObj].target[i] = '\0'; - - eX = strtol(&end2[i], &end3, 10); - eY = strtol(end3, NULL, 10); + strncpy((*objArr)[*nObj].target, end2, i); + (*objArr)[*nObj].target[i] = '\0'; + + eX = strtol(&end2[i], &end3, 10); + eY = strtol(end3, NULL, 10); - (*objArr)[*nObj].eX = eX; - (*objArr)[*nObj].eY = eY; + (*objArr)[*nObj].eX = eX; + (*objArr)[*nObj].eY = eY; - *nObj += 1; - - }else{ - fprintf(stderr, "\t%s.readMapObjects(): Skipped invalid data in EXITS key in map file %s.\n", __FILE__, file); - fprintf(stderr, "\t%s.readMapObjects(): The invalid line is %s.\n", __FILE__, buffer); - continue; - } - } - }while(buffer[0] != '['); + *nObj += 1; + + }else{ + fprintf(stderr, "\t%s.readMapObjects(): Skipped invalid data in EXITS key in map file %s.\n", __FILE__, file); + fprintf(stderr, "\t%s.readMapObjects(): The invalid line is %s.\n", __FILE__, buffer); + continue; + } + } + }while(buffer[0] != '['); - }else if(strcmp(buffer, "[DOORS]\n") == 0){ - do{ - rc = getline(&buffer, &n, f); - if(rc == -1) break; + }else if(strcmp(buffer, "[DOORS]\n") == 0){ + do{ + rc = getline(&buffer, &n, f); + if(rc == -1) break; - if(buffer[0] == '%') continue; - else if(buffer[0] == 'd'){ - int i; - - for(i = 0; buffer[i] && buffer[i] != '='; ++i); + if(buffer[0] == '%') continue; + else if(buffer[0] == 'd'){ + int i; + + for(i = 0; buffer[i] && buffer[i] != '='; ++i); - if(strncmp(buffer, "door =", i) == 0){ - int dX, dY, dId, un; - char *end, *end2, *end3; - - dX = strtol(&buffer[i + 1], &end, 10); - dY = strtol(end, &end2, 10); - dId = strtol(end2, &end3, 10); - un = strtol(end3, NULL, 10); + if(strncmp(buffer, "door =", i) == 0){ + int dX, dY, dId, un; + char *end, *end2, *end3; + + dX = strtol(&buffer[i + 1], &end, 10); + dY = strtol(end, &end2, 10); + dId = strtol(end2, &end3, 10); + un = strtol(end3, NULL, 10); - (*objArr)[*nObj].type = DOOR; - (*objArr)[*nObj].x = dX; - (*objArr)[*nObj].y = dY; - (*objArr)[*nObj].id = dId; - (*objArr)[*nObj].unlocked = un; + (*objArr)[*nObj].type = DOOR; + (*objArr)[*nObj].x = dX; + (*objArr)[*nObj].y = dY; + (*objArr)[*nObj].id = dId; + (*objArr)[*nObj].unlocked = un; - *nObj += 1; + *nObj += 1; - }else{ - fprintf(stderr, "\t%s.readMapObjects(): Skipped invalid data in DOORS key in map file %s.\n", __FILE__, file); - fprintf(stderr, "\t%s.readMapObjects(): The invalid line is %s.\n", __FILE__, buffer); - continue; - } - } - }while(buffer[0] != '['); + }else{ + fprintf(stderr, "\t%s.readMapObjects(): Skipped invalid data in DOORS key in map file %s.\n", __FILE__, file); + fprintf(stderr, "\t%s.readMapObjects(): The invalid line is %s.\n", __FILE__, buffer); + continue; + } + } + }while(buffer[0] != '['); - }else if(strcmp(buffer, "[KEYS]\n") == 0){ - do{ - rc = getline(&buffer, &n, f); - if(rc == -1) break; + }else if(strcmp(buffer, "[KEYS]\n") == 0){ + do{ + rc = getline(&buffer, &n, f); + if(rc == -1) break; - if(buffer[0] == '%') continue; - else if(buffer[0] == 'k'){ - int i; + if(buffer[0] == '%') continue; + else if(buffer[0] == 'k'){ + int i; - for(i = 0; buffer[i] && buffer[i] != '='; ++i); + for(i = 0; buffer[i] && buffer[i] != '='; ++i); - if(strncmp(buffer, "key =", i) == 0){ - int kX, kY, kId; - char *end, *end2; - - kX = strtol(&buffer[i + 1], &end, 10); - kY = strtol(end, &end2, 10); - kId = strtol(end2, NULL, 10); + if(strncmp(buffer, "key =", i) == 0){ + int kX, kY, kId; + char *end, *end2; + + kX = strtol(&buffer[i + 1], &end, 10); + kY = strtol(end, &end2, 10); + kId = strtol(end2, NULL, 10); - (*objArr)[*nObj].type = KEY; - (*objArr)[*nObj].x = kX; - (*objArr)[*nObj].y = kY; - (*objArr)[*nObj].id = kId; + (*objArr)[*nObj].type = KEY; + (*objArr)[*nObj].x = kX; + (*objArr)[*nObj].y = kY; + (*objArr)[*nObj].id = kId; - *nObj += 1; + *nObj += 1; - }else{ - fprintf(stderr, "\t%s.readMapObjects(): Skipped invalid data in KEYS key in map file %s.\n", __FILE__, file); - fprintf(stderr, "\t%s.readMapObjects(): The invalid line is %s.\n", __FILE__, buffer); - continue; - } - } - }while(buffer[0] != '['); + }else{ + fprintf(stderr, "\t%s.readMapObjects(): Skipped invalid data in KEYS key in map file %s.\n", __FILE__, file); + fprintf(stderr, "\t%s.readMapObjects(): The invalid line is %s.\n", __FILE__, buffer); + continue; + } + } + }while(buffer[0] != '['); - }else if(strcmp(buffer, "[PERSONS]\n") == 0){ - do{ - rc = getline(&buffer, &n, f); - if(rc == -1) break; + }else if(strcmp(buffer, "[PERSONS]\n") == 0){ + do{ + rc = getline(&buffer, &n, f); + if(rc == -1) break; - if(buffer[0] == '%') continue; - else if(buffer[0] == 'p'){ - int i; + if(buffer[0] == '%') continue; + else if(buffer[0] == 'p'){ + int i; - for(i = 0; buffer[i] && buffer[i] != '='; ++i); + for(i = 0; buffer[i] && buffer[i] != '='; ++i); - if(strncmp(buffer, "person =", i) == 0){ - int pX, pY, pDId; - char *end, *end2; - - pX = strtol(&buffer[i + 1], &end, 10); - pY = strtol(end, &end2, 10); - end2++; - - (*objArr)[*nObj].type = PERSON; - (*objArr)[*nObj].x = pX; - (*objArr)[*nObj].y = pY; - - for(i = 0; end2[i] && end2[i] != ' '; ++i); - - strncpy((*objArr)[*nObj].name, end2, i); - (*objArr)[*nObj].name[i] = '\0'; - - pDId = strtol(&end2[i], NULL, 10); - (*objArr)[*nObj].dId = pDId; - - *nObj += 1; + if(strncmp(buffer, "person =", i) == 0){ + int pX, pY, pDId; + char *end, *end2; + + pX = strtol(&buffer[i + 1], &end, 10); + pY = strtol(end, &end2, 10); + end2++; + + (*objArr)[*nObj].type = PERSON; + (*objArr)[*nObj].x = pX; + (*objArr)[*nObj].y = pY; + + for(i = 0; end2[i] && end2[i] != ' '; ++i); + + strncpy((*objArr)[*nObj].name, end2, i); + (*objArr)[*nObj].name[i] = '\0'; + + pDId = strtol(&end2[i], NULL, 10); + (*objArr)[*nObj].dId = pDId; + + *nObj += 1; - }else{ - fprintf(stderr, "\t%s.readMapObjects(): Skipped invalid data in PERSONS key in map file %s.\n", __FILE__, file); - fprintf(stderr, "\t%s.readMapObjects(): The invalid line is %s.\n", __FILE__, buffer); - continue; - } - } - }while(buffer[0] != '['); + }else{ + fprintf(stderr, "\t%s.readMapObjects(): Skipped invalid data in PERSONS key in map file %s.\n", __FILE__, file); + fprintf(stderr, "\t%s.readMapObjects(): The invalid line is %s.\n", __FILE__, buffer); + continue; + } + } + }while(buffer[0] != '['); - }else if(strcmp(buffer, "[DIALOGS]\n") == 0){ - do{ - rc = getline(&buffer, &n, f); - if(rc == -1) break; - - if(buffer[0] == '%') continue; - else if(buffer[0] == 'd'){ - int i; + }else if(strcmp(buffer, "[DIALOGS]\n") == 0){ + do{ + rc = getline(&buffer, &n, f); + if(rc == -1) break; + + if(buffer[0] == '%') continue; + else if(buffer[0] == 'd'){ + int i; - for(i = 0; buffer[i] && buffer[i] != '='; ++i); - - if(strncmp(buffer, "dialog =", i) == 0){ - int dId; - char *end; + for(i = 0; buffer[i] && buffer[i] != '='; ++i); + + if(strncmp(buffer, "dialog =", i) == 0){ + int dId; + char *end; - dId = strtol(&buffer[i + 1], &end, 10); - end++; - - (*objArr)[*nObj].type = DIALOG; - (*objArr)[*nObj].id = dId; + dId = strtol(&buffer[i + 1], &end, 10); + end++; + + (*objArr)[*nObj].type = DIALOG; + (*objArr)[*nObj].id = dId; - strcpy((*objArr)[*nObj].dialog, end); - for(i = 0; (*objArr)[*nObj].dialog[i] && (*objArr)[*nObj].dialog[i] != '\n'; ++i); - (*objArr)[*nObj].dialog[i] = '\0'; + strcpy((*objArr)[*nObj].dialog, end); + for(i = 0; (*objArr)[*nObj].dialog[i] && (*objArr)[*nObj].dialog[i] != '\n'; ++i); + (*objArr)[*nObj].dialog[i] = '\0'; - *nObj += 1; + *nObj += 1; - }else{ - fprintf(stderr, "\t%s.readMapObjects(): Skipped invalid data in DIALOGS key in map file %s.\n", __FILE__, file); - fprintf(stderr, "\t%s.readMapObjects(): The invalid line is %s.\n", __FILE__, buffer); - continue; - } - } - }while(buffer[0] != '['); + }else{ + fprintf(stderr, "\t%s.readMapObjects(): Skipped invalid data in DIALOGS key in map file %s.\n", __FILE__, file); + fprintf(stderr, "\t%s.readMapObjects(): The invalid line is %s.\n", __FILE__, buffer); + continue; + } + } + }while(buffer[0] != '['); - }else{ - fprintf(stderr, "\t%s.readMapObjects(): Found invalid key in map file %s. Key is %s\n", __FILE__, file, buffer); - free(buffer); - return INVALID_KEY; - } - } + }else{ + fprintf(stderr, "\t%s.readMapObjects(): Found invalid key in map file %s. Key is %s\n", __FILE__, file, buffer); + free(buffer); + return INVALID_KEY; + } + } - fclose(f); - free(buffer); + fclose(f); + free(buffer); - return NO_ERROR; + return NO_ERROR; } From 87a90c816a29b1b447b4ce5413472f290ce41930 Mon Sep 17 00:00:00 2001 From: Miguel Angel Astor Romero Date: Sat, 8 Mar 2014 18:12:14 -0430 Subject: [PATCH 18/26] Hidden map objects are no longer rendered. --- src/in_game.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/in_game.c b/src/in_game.c index 8feb08b..60229da 100644 --- a/src/in_game.c +++ b/src/in_game.c @@ -335,11 +335,15 @@ void render(int w, int h){ if(objs[k].type == DOOR){ printw("\u25D9"); - }else if(objs[k].type == KEY){ - printw("k"); - }else if(objs[k].type == PERSON){ - printw("\u263A"); - } + }else{ + if(vis[dj][di]){ + if(objs[k].type == KEY){ + printw("k"); + }else if(objs[k].type == PERSON){ + printw("\u263A"); + } + } + } } } From 8551458965e19f806536b333293b5781c132cf7a Mon Sep 17 00:00:00 2001 From: Miguel Angel Astor Romero Date: Sat, 8 Mar 2014 18:26:53 -0430 Subject: [PATCH 19/26] Added test map file. --- maps/start.map | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++ src/in_game.c | 31 +++++++++++++++---------- 2 files changed, 80 insertions(+), 12 deletions(-) create mode 100644 maps/start.map diff --git a/maps/start.map b/maps/start.map new file mode 100644 index 0000000..c47a355 --- /dev/null +++ b/maps/start.map @@ -0,0 +1,61 @@ +[MAP] +32 32 +00000000000000000000000000000000 +00000000000044444440000000000000 +00000000000441111144000000000000 +00000000004411666114400000000000 +44444000044116777611440000000000 +41514400441167777761144000000000 +41771440411677737776114444444000 +41777144416777383777614115114000 +41997711116773888377611166614000 +41797726626738888837666666654000 +41997711116773888377611166614000 +41777144416777383777614115114000 +41771440411677737776114444444000 +41514400441167777761144000000000 +44444000044116777611440000000000 +00000000004411666114400000000000 +00000000000441161144000000000000 +00000000000044565440000000000000 +00000000000004161400000000000000 +00000000000004565400000000000000 +00000000444444161444444000000000 +00000000411551161155114000000000 +00000000416666666666614000000000 +00000000456666666666654000000000 +00000000456677777776654000000000 +00000000416677777776614000000000 +00000000416677777776614000000000 +00000000456677777776654000000000 +00000000456666666666654000000000 +00000000416666666666614000000000 +00000000411551151155114000000000 +00000000444444444444444000000000 +[PLAYER] +%player = X Y +player = 27 15 +[EXITS] +%exit = X Y MAP_NAME MAP_X MAP_Y +exit = 8 25 maps/start.map 0 0 +exit = 9 25 maps/start.map 0 0 +exit = 10 24 maps/start.map 0 0 +exit = 10 25 maps/start.map 0 0 +[DOORS] +%door = X Y ID UNLOCKED +door = 9 22 0 0 +[KEYS] +%key = X Y ID +key = 7 2 0 +[PERSONS] +%person = X Y NAME DIALOG_ID +person = 8 24 Hugo 0 +person = 9 2 Paco 1 +person = 23 11 Luis 2 +person = 23 19 Donald 3 +[DIALOGS] +%dialog = ID TEXT +dialog = 0 Step into the elevator to retry. +dialog = 1 I'm unreachable! +dialog = 2 Welcome to Cyjam! +dialog = 3 Have fun. diff --git a/src/in_game.c b/src/in_game.c index 60229da..00ed4cd 100644 --- a/src/in_game.c +++ b/src/in_game.c @@ -28,7 +28,7 @@ static bool **vis; static bool **seen; static bool ** wmap; static bool w_mov = FALSE; -static bool uK, dK, lK, rK; +static bool uK, dK, lK, rK, esc; static clock_t then, msgThen; static player_t player; static map_cell_t ** map; @@ -56,6 +56,8 @@ bool canMoveTo(int, int); void initInGameState( gs_t * gs) { int i, j; + uK = dK = lK = rK = esc = FALSE; + gs->name = IN_GAME; gs->input = &input; gs->update = &update; @@ -86,7 +88,7 @@ void initInGameState( gs_t * gs) { } initObjects(); - loadMap("map_file.map"); + loadMap("maps/start.map"); fov_settings_init(&fov_settings); fov_settings_set_opacity_test_function(&fov_settings, opaque); @@ -103,6 +105,7 @@ void input(){ if(key == KEY_DOWN) dK = TRUE; if(key == KEY_LEFT) lK = TRUE; if(key == KEY_RIGHT) rK = TRUE; + if(key == 27) esc = TRUE; } } @@ -123,6 +126,8 @@ gsname_t update(){ if(rK) nX = (iX + 1) % mW; + if(esc) return IN_GAME; + /* Find if the player is standing on an exit, then load the next map. */ for(i = 0; i < nO; i++){ if(objs[i].type == EXIT){ @@ -135,7 +140,7 @@ gsname_t update(){ } } - /* TODO: use keys.*/ + /* If the player is standing on a key, pick it up. */ for(i = 0; i < nO; i++){ if(objs[i].type == KEY){ if(objs[i].x == iY && objs[i].y == iX){ @@ -150,7 +155,7 @@ gsname_t update(){ } } - /* Listen to a person. */ + /* If the player bumps into a person, listen to what they have to say. */ for(i = 0; i < nO; i++){ if(objs[i].type == PERSON){ if(objs[i].x == nY && objs[i].y == nX){ @@ -172,6 +177,7 @@ gsname_t update(){ } } + /* If the player bumps into a door, open it if the key is available. */ for(i = 0; i < nO; i++){ if(objs[i].type == DOOR){ if(objs[i].x == nY && objs[i].y == nX){ @@ -200,6 +206,7 @@ gsname_t update(){ } } + /* Clear the message buffer after a timeout. */ if(newMsg){ msgNow = clock(); delta = msgNow - msgThen; @@ -336,14 +343,14 @@ void render(int w, int h){ if(objs[k].type == DOOR){ printw("\u25D9"); }else{ - if(vis[dj][di]){ - if(objs[k].type == KEY){ - printw("k"); - }else if(objs[k].type == PERSON){ - printw("\u263A"); - } - } - } + if(vis[dj][di]){ + if(objs[k].type == KEY){ + printw("k"); + }else if(objs[k].type == PERSON){ + printw("\u263A"); + } + } + } } } From 1f2560e7e31d2d506ecbe0e00d1096563fddb4ee Mon Sep 17 00:00:00 2001 From: Miguel Angel Astor Romero Date: Sat, 8 Mar 2014 19:15:31 -0430 Subject: [PATCH 20/26] Main menu functional. --- Makefile | 6 +- include/main_menu.h | 13 ++++ src/game_state.c | 8 +-- src/in_game.c | 8 ++- src/main.c | 19 ++---- src/main_menu.c | 159 ++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 190 insertions(+), 23 deletions(-) create mode 100644 include/main_menu.h create mode 100644 src/main_menu.c diff --git a/Makefile b/Makefile index 91ee777..236a63e 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,5 @@ CC = gcc -SOURCES = src/main.c src/game_state.c src/in_game.c src/map.c -OBJECTS = obj/main.o obj/game_state.o obj/in_game.o obj/map.o +OBJECTS = obj/main.o obj/game_state.o obj/in_game.o obj/main_menu.o obj/map.o TARGET = bin/cyjam CFLAGS = -Wall -I./include -std=c99 LDFLAGS = -L./lib @@ -24,6 +23,9 @@ obj/game_state.o: src/game_state.c include/game_state.h include/in_game.h obj/in_game.o: src/in_game.c include/in_game.h include/game_state.h include/map.h $(CC) -c -o $@ $< $(CFLAGS) +obj/main_menu.o: src/main_menu.c include/main_menu.h include/game_state.h + $(CC) -c -o $@ $< $(CFLAGS) + obj/map.o: src/map.c include/map.h $(CC) -c -o $@ $< $(CFLAGS) diff --git a/include/main_menu.h b/include/main_menu.h new file mode 100644 index 0000000..9185a05 --- /dev/null +++ b/include/main_menu.h @@ -0,0 +1,13 @@ +/** + * Copyright (c) 2014, Miguel Angel Astor Romero. All rights reserved. + * See the file LICENSE for more details. + */ + +#ifndef MAIN_MENU_H +#define MAIN_MENU_H + +#include "game_state.h" + +extern void initMMState(gs_t *); + +#endif diff --git a/src/game_state.c b/src/game_state.c index 8bc192b..b35b26b 100644 --- a/src/game_state.c +++ b/src/game_state.c @@ -4,12 +4,10 @@ */ #include "game_state.h" +#include "main_menu.h" #include "in_game.h" void initStateArray(gs_t ** s){ - int i; - - /*for(i = 0; i < NUM_STATES; i++){*/ - initInGameState(&((*s)[2])); - /*}*/ + initMMState(&((*s)[MENU])); + initInGameState(&((*s)[IN_GAME])); } diff --git a/src/in_game.c b/src/in_game.c index 00ed4cd..ca27ea6 100644 --- a/src/in_game.c +++ b/src/in_game.c @@ -126,7 +126,13 @@ gsname_t update(){ if(rK) nX = (iX + 1) % mW; - if(esc) return IN_GAME; + if(esc){ + /* Reset the game and go to the main menu. */ + esc = FALSE; + initObjects(); + loadMap("maps/start.map"); + return MENU; + } /* Find if the player is standing on an exit, then load the next map. */ for(i = 0; i < nO; i++){ diff --git a/src/main.c b/src/main.c index 5578155..46f1911 100644 --- a/src/main.c +++ b/src/main.c @@ -20,7 +20,6 @@ void leave(void); void manage_signal(int signal); int start_ncurses(void); void set_colors(void); -void clear_screen(void); void on_resize(int); static int w = 0, h = 0; @@ -85,7 +84,7 @@ int main() { set_colors(); /* Create the state data structures. */ - c_state = 2; + c_state = MENU; states = (gs_t *)malloc(sizeof(gs_t) * NUM_STATES); initStateArray(&states); @@ -110,7 +109,9 @@ int main() { if(c_state == -1) finished = TRUE; - states[c_state].render(w, h); + if(c_state >= INTRO && c_state <= GAME_OVER){ + states[c_state].render(w, h); + } fps++; @@ -242,15 +243,3 @@ void set_colors(void){ exit(EXIT_FAILURE); } } - -void clear_screen(void){ - int i, j; - move(0,0); - attron(COLOR_PAIR(BSC_COLOR)); - for(i = 0; i < w; i++){ - for(j = 0; j < h; j++){ - move(j, i); - printw(" "); - } - } -} diff --git a/src/main_menu.c b/src/main_menu.c new file mode 100644 index 0000000..ed6be07 --- /dev/null +++ b/src/main_menu.c @@ -0,0 +1,159 @@ +/** + * Copyright (c) 2014, Miguel Angel Astor Romero. All rights reserved. + * See the file LICENSE for more details. + */ + +#include +#include +#include + +#include "constants.h" +#include "main_menu.h" + +static char * title = "TITLE PENDING"; +static char * subtitle = "A game for the Cyberpunk Jam 2014"; +static char * opt1 = "New game"; +static char * opt2 = "Replay intro"; +static char * opt3 = "Quit"; +static char * creds = "Designed and programmed by Miky"; +static char * info = "Press enter to select an option. Scroll with the arrow keys."; +static char * info2 = "Press escape while in game to return to the main menu."; + +static int selOpt = 0; +static bool uK, dK, esc, enter; + +void mmInput(); +gsname_t mmUpdate(); +void mmRender(int, int); +void clear_screen(int, int); + +void initMMState(gs_t * gs){ + gs->name = MENU; + gs->input = &mmInput; + gs->update = &mmUpdate; + gs->render = &mmRender; +} + +void mmInput(){ + int key = 0; + + key = getch(); + + if(key != ERR){ + if(key == KEY_UP) uK = TRUE; + if(key == KEY_DOWN) dK = TRUE; + if(key == 27) esc = TRUE; + if(key == KEY_ENTER || key == '\n') enter = TRUE; + } +} + +gsname_t mmUpdate(){ + if(uK){ + selOpt = selOpt - 1 < 0 ? 2 : selOpt - 1; + uK = FALSE; + } + + if(dK){ + selOpt = (selOpt + 1) % 3; + dK = FALSE; + } + + if(esc) return -1; + + if(enter){ + enter = FALSE; + if(selOpt == 0) return IN_GAME; + else if(selOpt == 1) return MENU; + else return -1; + } + + return MENU; +} + +void mmRender(int w, int h){ + int sW; + + clear_screen(w, h); + + /* Print the title. */ + sW = strlen(title); + sW /= 2; + + attron(A_BOLD); + + move(1, (w / 2) - sW); + attron(COLOR_PAIR(SN_COLOR)); + printw(title); + + /* Print the subtitle. */ + sW = strlen(subtitle); + sW /= 2; + + move(2, (w / 2) - sW); + attron(COLOR_PAIR(SW_COLOR)); + printw(subtitle); + + attroff(A_BOLD); + + /* Print the menu options. */ + sW = strlen(opt1); + sW /= 2; + + move((h / 2) - 2, (w / 2) - sW); + if(selOpt == 0) attron(COLOR_PAIR(GR_COLOR)); + else attron(COLOR_PAIR(DW_COLOR)); + printw(opt1); + + sW = strlen(opt2); + sW /= 2; + + move((h / 2) - 1, (w / 2) - sW); + if(selOpt == 1) attron(COLOR_PAIR(GR_COLOR)); + else attron(COLOR_PAIR(DW_COLOR)); + printw(opt2); + + sW = strlen(opt3); + sW /= 2; + + move((h / 2), (w / 2) - sW); + if(selOpt == 2) attron(COLOR_PAIR(GR_COLOR)); + else attron(COLOR_PAIR(DW_COLOR)); + printw(opt3); + + /* Print help. */ + sW = strlen(info); + sW /= 2; + + move(h - 5, (w / 2) - sW); + attron(COLOR_PAIR(MN_COLOR)); + printw(info); + + sW = strlen(info2); + sW /= 2; + + move(h - 4, (w / 2) - sW); + attron(COLOR_PAIR(MN_COLOR)); + printw(info2); + + /* Print credits. */ + sW = strlen(creds); + sW /= 2; + + attron(A_BOLD); + move(h - 2, (w / 2) - sW); + attron(COLOR_PAIR(SW_COLOR)); + printw(creds); + attroff(A_BOLD); +} + +void clear_screen(int w, int h){ + int i, j; + move(0,0); + attron(COLOR_PAIR(BSC_COLOR)); + for(i = 0; i < w; i++){ + for(j = 0; j < h; j++){ + move(j, i); + printw(" "); + } + } +} From fa9e0e6760d4331f2169b14dfd0a55501d049a72 Mon Sep 17 00:00:00 2001 From: Miguel Angel Astor Romero Date: Sat, 8 Mar 2014 21:19:02 -0430 Subject: [PATCH 21/26] Intro ready. --- Makefile | 5 +- include/constants.h | 5 +- include/game_state.h | 1 + include/intro.h | 13 ++++ include/intro_img.h | 92 ++++++++++++++++++++++ src/game_state.c | 21 ++++- src/in_game.c | 26 +++---- src/intro.c | 89 +++++++++++++++++++++ src/main.c | 58 +++++++------- src/main_menu.c | 181 ++++++++++++++++++++----------------------- 10 files changed, 350 insertions(+), 141 deletions(-) create mode 100644 include/intro.h create mode 100644 include/intro_img.h create mode 100644 src/intro.c diff --git a/Makefile b/Makefile index 236a63e..8a8d31b 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ CC = gcc -OBJECTS = obj/main.o obj/game_state.o obj/in_game.o obj/main_menu.o obj/map.o +OBJECTS = obj/main.o obj/game_state.o obj/in_game.o obj/main_menu.o obj/map.o obj/intro.o TARGET = bin/cyjam CFLAGS = -Wall -I./include -std=c99 LDFLAGS = -L./lib @@ -26,6 +26,9 @@ obj/in_game.o: src/in_game.c include/in_game.h include/game_state.h include/map. obj/main_menu.o: src/main_menu.c include/main_menu.h include/game_state.h $(CC) -c -o $@ $< $(CFLAGS) +obj/intro.o: src/intro.c include/intro.h include/intro_img.h include/game_state.h + $(CC) -c -o $@ $< $(CFLAGS) + obj/map.o: src/map.c include/map.h $(CC) -c -o $@ $< $(CFLAGS) diff --git a/include/constants.h b/include/constants.h index 8c63b00..101dbd3 100644 --- a/include/constants.h +++ b/include/constants.h @@ -6,6 +6,7 @@ #ifndef STATE_CONSTS_H #define STATE_CONSTS_H +static const int DEBUG = 1; #define F_SEP "/" enum COLORS { @@ -23,7 +24,9 @@ enum COLORS { GR_COLOR, FR_COLOR, HL_COLOR, - MN_COLOR + MN_COLOR, + VOID_COLOR, + IND_COLOR }; #endif diff --git a/include/game_state.h b/include/game_state.h index 34be94d..f20eb04 100644 --- a/include/game_state.h +++ b/include/game_state.h @@ -18,5 +18,6 @@ typedef struct GAME_STATE { } gs_t; extern void initStateArray(gs_t **); +void clear_screen(int, int); #endif diff --git a/include/intro.h b/include/intro.h new file mode 100644 index 0000000..48851b4 --- /dev/null +++ b/include/intro.h @@ -0,0 +1,13 @@ +/** + * Copyright (c) 2014, Miguel Angel Astor Romero. All rights reserved. + * See the file LICENSE for more details. + */ + +#ifndef INTRO_H +#define INTRO_H + +#include "game_state.h" + +void initIntroState(gs_t *); + +#endif diff --git a/include/intro_img.h b/include/intro_img.h new file mode 100644 index 0000000..d7d155a --- /dev/null +++ b/include/intro_img.h @@ -0,0 +1,92 @@ +/** + * Copyright (c) 2014, Miguel Angel Astor Romero. All rights reserved. + * See the file LICENSE for more details. + */ + +#ifndef INTRO_IMG_H +#define INTRO_IMG_H + +static int INTRO_IMG[80][80] = { + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, DW_COLOR, SW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, GR_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, GR_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, GR_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, GR_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, GR_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, DW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, DW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, DW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, DW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, SW_COLOR, DW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, DW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, DW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, DW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, DW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, DW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, DW_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, DW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SN_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, VOID_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, GR_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, VOID_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, SN_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, SN_COLOR, GR_COLOR, SN_COLOR, GR_COLOR, SN_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, SN_COLOR, SN_COLOR, SN_COLOR, SN_COLOR, SN_COLOR, SN_COLOR, SN_COLOR, GR_COLOR, SN_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, GR_COLOR, SN_COLOR, GR_COLOR, SN_COLOR, GR_COLOR, SN_COLOR, GR_COLOR, SN_COLOR, SN_COLOR, SN_COLOR, SN_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, DW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, SN_COLOR, GR_COLOR, SN_COLOR, GR_COLOR, SN_COLOR, GR_COLOR, SN_COLOR, GR_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, SN_COLOR, SN_COLOR, GR_COLOR, SN_COLOR, GR_COLOR, SN_COLOR, GR_COLOR, SN_COLOR, SN_COLOR, GR_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, SN_COLOR, SN_COLOR, SN_COLOR, SN_COLOR, SN_COLOR, SN_COLOR, SN_COLOR, GR_COLOR, GR_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, VOID_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, VOID_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, DW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SN_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, DW_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, SW_COLOR, DW_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SN_COLOR, DW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, DW_COLOR, SN_COLOR, GR_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, DW_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, DW_COLOR, SN_COLOR, SN_COLOR, DW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, VOID_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SN_COLOR, DW_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, VOID_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, GR_COLOR, SN_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, VOID_COLOR, DW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, SW_COLOR, DW_COLOR, SN_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, DW_COLOR, DW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, SW_COLOR, DW_COLOR, VOID_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, DW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, SN_COLOR, SN_COLOR, GR_COLOR, SN_COLOR, GR_COLOR, SN_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, SW_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, GR_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, SN_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, DW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, SN_COLOR, GR_COLOR, SN_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SN_COLOR, GR_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, DW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, VOID_COLOR, DW_COLOR, DW_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, GR_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, DW_COLOR, VOID_COLOR, SW_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, DW_COLOR, DW_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, DW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, DW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, GR_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, GR_COLOR, SW_COLOR, GR_COLOR, SW_COLOR, SW_COLOR, SW_COLOR, SN_COLOR, SW_COLOR, DW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, SW_COLOR, SW_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR}, + {VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR, VOID_COLOR} +}; + +#endif diff --git a/src/game_state.c b/src/game_state.c index b35b26b..e952eae 100644 --- a/src/game_state.c +++ b/src/game_state.c @@ -3,11 +3,28 @@ * See the file LICENSE for more details. */ +#include + +#include "constants.h" #include "game_state.h" +#include "intro.h" #include "main_menu.h" #include "in_game.h" void initStateArray(gs_t ** s){ - initMMState(&((*s)[MENU])); - initInGameState(&((*s)[IN_GAME])); + initIntroState(&((*s)[INTRO])); + initMMState(&((*s)[MENU])); + initInGameState(&((*s)[IN_GAME])); +} + +void clear_screen(int w, int h){ + int i, j; + move(0,0); + attron(COLOR_PAIR(BSC_COLOR)); + for(i = 0; i < w; i++){ + for(j = 0; j < h; j++){ + move(j, i); + printw(" "); + } + } } diff --git a/src/in_game.c b/src/in_game.c index ca27ea6..420bae4 100644 --- a/src/in_game.c +++ b/src/in_game.c @@ -56,7 +56,7 @@ bool canMoveTo(int, int); void initInGameState( gs_t * gs) { int i, j; - uK = dK = lK = rK = esc = FALSE; + uK = dK = lK = rK = esc = FALSE; gs->name = IN_GAME; gs->input = &input; @@ -105,7 +105,7 @@ void input(){ if(key == KEY_DOWN) dK = TRUE; if(key == KEY_LEFT) lK = TRUE; if(key == KEY_RIGHT) rK = TRUE; - if(key == 27) esc = TRUE; + if(key == 27) esc = TRUE; } } @@ -126,13 +126,13 @@ gsname_t update(){ if(rK) nX = (iX + 1) % mW; - if(esc){ - /* Reset the game and go to the main menu. */ - esc = FALSE; - initObjects(); - loadMap("maps/start.map"); - return MENU; - } + if(esc){ + /* Reset the game and go to the main menu. */ + esc = FALSE; + initObjects(); + loadMap("maps/start.map"); + return MENU; + } /* Find if the player is standing on an exit, then load the next map. */ for(i = 0; i < nO; i++){ @@ -146,7 +146,7 @@ gsname_t update(){ } } - /* If the player is standing on a key, pick it up. */ + /* If the player is standing on a key, pick it up. */ for(i = 0; i < nO; i++){ if(objs[i].type == KEY){ if(objs[i].x == iY && objs[i].y == iX){ @@ -183,7 +183,7 @@ gsname_t update(){ } } - /* If the player bumps into a door, open it if the key is available. */ + /* If the player bumps into a door, open it if the key is available. */ for(i = 0; i < nO; i++){ if(objs[i].type == DOOR){ if(objs[i].x == nY && objs[i].y == nX){ @@ -212,7 +212,7 @@ gsname_t update(){ } } - /* Clear the message buffer after a timeout. */ + /* Clear the message buffer after a timeout. */ if(newMsg){ msgNow = clock(); delta = msgNow - msgThen; @@ -264,7 +264,7 @@ void render(int w, int h){ w_mov = TRUE; } - pi = (((w - 1) - 1) / 2) + 1; + pi = (((w - 2) - 1) / 2) + 1; pj = (h - 3) / 2 + 1; ioff = (w - 28 - 27) / 2; diff --git a/src/intro.c b/src/intro.c new file mode 100644 index 0000000..cc12980 --- /dev/null +++ b/src/intro.c @@ -0,0 +1,89 @@ +/** + * Copyright (c) 2014, Miguel Angel Astor Romero. All rights reserved. + * See the file LICENSE for more details. + */ + +#include +#include +#include +#include + +#include "constants.h" +#include "intro.h" +#include "intro_img.h" + +void inInput(); +gsname_t inUpdate(); +void inRender(int, int); + +static bool anyKey; +static clock_t then = 0, nThen = 0; +static int mRows = 0, mH = 0; + +void initIntroState(gs_t * gs){ + gs->name = INTRO; + gs->input = &inInput; + gs->update = &inUpdate; + gs->render = &inRender; +} + +void inInput(){ + int key = 0; + + key = getch(); + + if(key != ERR && key != KEY_RESIZE){ + anyKey = TRUE; + } +} + +gsname_t inUpdate(){ + clock_t now, delta; + + if(anyKey){ + anyKey = FALSE; + mRows = 0; + then = 0; + nThen = 0; + return MENU; + } + + now = clock(); + delta = now - then; + if((float)delta / (float)CLOCKS_PER_SEC >= 0.15f){ + then = now; + mRows = mRows + 1 <= mH ? mRows + 1 : mH; + } + + if(mRows >= mH){ + now = clock(); + delta = now - nThen; + if((int)delta / (int)CLOCKS_PER_SEC >= 3){ + nThen = 0; + mRows = 0; + then = 0; + return MENU; + } + }else{ + nThen = clock(); + } + + return INTRO; +} + +void inRender(int w, int h){ + int i, j, jOff; + + mH = h < 30 ? h : 30; + jOff = mH < h ? (mH / 4) : 0; + + clear_screen(w, h); + + for(i = 0; i < w && i < 80; i++){ + for(j = 21; j < h + 21 && j < mRows + 21 && j < 80; j++){ + move((j - 21) + jOff, (w / 2) - 40 + i); + attron(COLOR_PAIR(INTRO_IMG[i][j])); + printw("\u2588"); + } + } +} diff --git a/src/main.c b/src/main.c index 46f1911..96e9534 100644 --- a/src/main.c +++ b/src/main.c @@ -27,16 +27,16 @@ static bool resize = FALSE; int main() { bool finished = FALSE; - char * home_dir = getenv("HOME"); - FILE * f; /* To avoid a warning. */ - clock_t then, now, delta; - unsigned int fps = 0, pfps = 0; - char * data_dir; - char * log_file; - time_t raw_date; - struct tm * current_date; - gs_t * states; - int c_state; + char * home_dir = getenv("HOME"); + FILE * f; /* To avoid a warning. */ + clock_t then, now, delta; + unsigned int fps = 0, pfps = 0; + char * data_dir; + char * log_file; + time_t raw_date; + struct tm * current_date; + gs_t * states; + int c_state; atexit(leave); signal(SIGINT, manage_signal); @@ -84,7 +84,7 @@ int main() { set_colors(); /* Create the state data structures. */ - c_state = MENU; + c_state = INTRO; states = (gs_t *)malloc(sizeof(gs_t) * NUM_STATES); initStateArray(&states); @@ -109,23 +109,25 @@ int main() { if(c_state == -1) finished = TRUE; - if(c_state >= INTRO && c_state <= GAME_OVER){ - states[c_state].render(w, h); - } - - fps++; - - now = clock(); - delta = now - then; - if((int)delta / (int)CLOCKS_PER_SEC == 1){ - then = now; - pfps = fps; - fps = 0; + if(c_state >= INTRO && c_state <= GAME_OVER){ + states[c_state].render(w, h); } - move(1, 1); - attron(COLOR_PAIR(BSC_COLOR)); - printw("FPS: %u", pfps); + if(DEBUG){ + fps++; + + now = clock(); + delta = now - then; + if((int)delta / (int)CLOCKS_PER_SEC == 1){ + then = now; + pfps = fps; + fps = 0; + } + + move(1, 1); + attron(COLOR_PAIR(BSC_COLOR)); + printw("FPS: %u", pfps); + } refresh(); }while(!finished); @@ -219,7 +221,6 @@ void set_colors(void){ ret_code = start_color(); if(ret_code == OK){ if(has_colors() == TRUE){ - init_color(COLOR_MAGENTA, 0, 0, 500); init_pair(BAR_COLOR, COLOR_WHITE, COLOR_RED); /* The color for the top and bottom bars. */ init_pair(BSC_COLOR, COLOR_WHITE, COLOR_BLACK); /* Basic text color. */ @@ -237,6 +238,9 @@ void set_colors(void){ init_pair(FR_COLOR, COLOR_RED, COLOR_BLACK); init_pair(HL_COLOR, COLOR_WHITE, COLOR_BLACK); init_pair(MN_COLOR, COLOR_WHITE, COLOR_BLACK); + + init_pair(VOID_COLOR, COLOR_BLACK, COLOR_BLACK); /* Pure black. */ + init_pair(IND_COLOR, COLOR_MAGENTA, COLOR_BLACK); /* Intro shadow. */ } }else{ fprintf(stderr, "\t%s: Colors not supported.\n", __FILE__); diff --git a/src/main_menu.c b/src/main_menu.c index ed6be07..224ada5 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -10,150 +10,137 @@ #include "constants.h" #include "main_menu.h" -static char * title = "TITLE PENDING"; -static char * subtitle = "A game for the Cyberpunk Jam 2014"; -static char * opt1 = "New game"; -static char * opt2 = "Replay intro"; -static char * opt3 = "Quit"; -static char * creds = "Designed and programmed by Miky"; -static char * info = "Press enter to select an option. Scroll with the arrow keys."; -static char * info2 = "Press escape while in game to return to the main menu."; +static char * title = "TITLE PENDING"; +static char * subtitle = "A game for the Cyberpunk Jam 2014"; +static char * opt1 = "New game"; +static char * opt2 = "Replay intro"; +static char * opt3 = "Quit"; +static char * creds = "Designed and programmed by Miky"; +static char * info = "Press enter to select an option. Scroll with the arrow keys."; +static char * info2 = "Press escape while in game to return to the main menu."; -static int selOpt = 0; -static bool uK, dK, esc, enter; +static int selOpt = 0; +static bool uK, dK, esc, enter; void mmInput(); gsname_t mmUpdate(); void mmRender(int, int); -void clear_screen(int, int); void initMMState(gs_t * gs){ - gs->name = MENU; + gs->name = MENU; gs->input = &mmInput; gs->update = &mmUpdate; gs->render = &mmRender; } void mmInput(){ - int key = 0; + int key = 0; key = getch(); if(key != ERR){ if(key == KEY_UP) uK = TRUE; if(key == KEY_DOWN) dK = TRUE; - if(key == 27) esc = TRUE; - if(key == KEY_ENTER || key == '\n') enter = TRUE; + if(key == 27) esc = TRUE; + if(key == KEY_ENTER || key == '\n') enter = TRUE; } } gsname_t mmUpdate(){ - if(uK){ - selOpt = selOpt - 1 < 0 ? 2 : selOpt - 1; - uK = FALSE; - } + if(uK){ + selOpt = selOpt - 1 < 0 ? 2 : selOpt - 1; + uK = FALSE; + } - if(dK){ - selOpt = (selOpt + 1) % 3; - dK = FALSE; - } + if(dK){ + selOpt = (selOpt + 1) % 3; + dK = FALSE; + } - if(esc) return -1; + if(esc) return -1; - if(enter){ - enter = FALSE; - if(selOpt == 0) return IN_GAME; - else if(selOpt == 1) return MENU; - else return -1; - } + if(enter){ + enter = FALSE; + if(selOpt == 0) return IN_GAME; + else if(selOpt == 1) return INTRO; + else return -1; + } - return MENU; + return MENU; } void mmRender(int w, int h){ - int sW; + int sW; - clear_screen(w, h); + clear_screen(w, h); - /* Print the title. */ - sW = strlen(title); - sW /= 2; + /* Print the title. */ + sW = strlen(title); + sW /= 2; - attron(A_BOLD); + attron(A_BOLD); - move(1, (w / 2) - sW); - attron(COLOR_PAIR(SN_COLOR)); - printw(title); + move(1, (w / 2) - sW); + attron(COLOR_PAIR(SN_COLOR)); + printw(title); - /* Print the subtitle. */ - sW = strlen(subtitle); - sW /= 2; + /* Print the subtitle. */ + sW = strlen(subtitle); + sW /= 2; - move(2, (w / 2) - sW); - attron(COLOR_PAIR(SW_COLOR)); - printw(subtitle); + move(2, (w / 2) - sW); + attron(COLOR_PAIR(SW_COLOR)); + printw(subtitle); - attroff(A_BOLD); + attroff(A_BOLD); - /* Print the menu options. */ - sW = strlen(opt1); - sW /= 2; + /* Print the menu options. */ + sW = strlen(opt1); + sW /= 2; - move((h / 2) - 2, (w / 2) - sW); - if(selOpt == 0) attron(COLOR_PAIR(GR_COLOR)); - else attron(COLOR_PAIR(DW_COLOR)); - printw(opt1); + move((h / 2) - 2, (w / 2) - sW); + if(selOpt == 0) attron(COLOR_PAIR(GR_COLOR)); + else attron(COLOR_PAIR(DW_COLOR)); + printw(opt1); - sW = strlen(opt2); - sW /= 2; + sW = strlen(opt2); + sW /= 2; - move((h / 2) - 1, (w / 2) - sW); - if(selOpt == 1) attron(COLOR_PAIR(GR_COLOR)); - else attron(COLOR_PAIR(DW_COLOR)); - printw(opt2); + move((h / 2) - 1, (w / 2) - sW); + if(selOpt == 1) attron(COLOR_PAIR(GR_COLOR)); + else attron(COLOR_PAIR(DW_COLOR)); + printw(opt2); - sW = strlen(opt3); - sW /= 2; + sW = strlen(opt3); + sW /= 2; - move((h / 2), (w / 2) - sW); - if(selOpt == 2) attron(COLOR_PAIR(GR_COLOR)); - else attron(COLOR_PAIR(DW_COLOR)); - printw(opt3); + move((h / 2), (w / 2) - sW); + if(selOpt == 2) attron(COLOR_PAIR(GR_COLOR)); + else attron(COLOR_PAIR(DW_COLOR)); + printw(opt3); - /* Print help. */ - sW = strlen(info); - sW /= 2; + /* Print help. */ + sW = strlen(info); + sW /= 2; - move(h - 5, (w / 2) - sW); - attron(COLOR_PAIR(MN_COLOR)); - printw(info); + move(h - 5, (w / 2) - sW); + attron(COLOR_PAIR(MN_COLOR)); + printw(info); - sW = strlen(info2); - sW /= 2; + sW = strlen(info2); + sW /= 2; - move(h - 4, (w / 2) - sW); - attron(COLOR_PAIR(MN_COLOR)); - printw(info2); + move(h - 4, (w / 2) - sW); + attron(COLOR_PAIR(MN_COLOR)); + printw(info2); - /* Print credits. */ - sW = strlen(creds); - sW /= 2; + /* Print credits. */ + sW = strlen(creds); + sW /= 2; - attron(A_BOLD); - move(h - 2, (w / 2) - sW); - attron(COLOR_PAIR(SW_COLOR)); - printw(creds); - attroff(A_BOLD); -} - -void clear_screen(int w, int h){ - int i, j; - move(0,0); - attron(COLOR_PAIR(BSC_COLOR)); - for(i = 0; i < w; i++){ - for(j = 0; j < h; j++){ - move(j, i); - printw(" "); - } - } + attron(A_BOLD); + move(h - 2, (w / 2) - sW); + attron(COLOR_PAIR(SW_COLOR)); + printw(creds); + attroff(A_BOLD); } From 8f09cabf66448c6ca7dba6f5a06cf7406c755c33 Mon Sep 17 00:00:00 2001 From: Miguel Angel Astor Romero Date: Sat, 8 Mar 2014 21:51:12 -0430 Subject: [PATCH 22/26] Engine ready. --- Makefile | 5 ++- include/constants.h | 2 +- include/game_over.h | 13 ++++++ maps/start.map | 2 +- src/game_over.c | 99 +++++++++++++++++++++++++++++++++++++++++++++ src/game_state.c | 2 + src/in_game.c | 21 +++++++--- src/main_menu.c | 16 ++++---- src/map.c | 2 - 9 files changed, 143 insertions(+), 19 deletions(-) create mode 100644 include/game_over.h create mode 100644 src/game_over.c diff --git a/Makefile b/Makefile index 8a8d31b..f5ef482 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ CC = gcc -OBJECTS = obj/main.o obj/game_state.o obj/in_game.o obj/main_menu.o obj/map.o obj/intro.o +OBJECTS = obj/main.o obj/game_state.o obj/in_game.o obj/main_menu.o obj/map.o obj/intro.o obj/game_over.o TARGET = bin/cyjam CFLAGS = -Wall -I./include -std=c99 LDFLAGS = -L./lib @@ -29,6 +29,9 @@ obj/main_menu.o: src/main_menu.c include/main_menu.h include/game_state.h obj/intro.o: src/intro.c include/intro.h include/intro_img.h include/game_state.h $(CC) -c -o $@ $< $(CFLAGS) +obj/game_over.o: src/game_over.c include/game_over.h include/game_state.h + $(CC) -c -o $@ $< $(CFLAGS) + obj/map.o: src/map.c include/map.h $(CC) -c -o $@ $< $(CFLAGS) diff --git a/include/constants.h b/include/constants.h index 101dbd3..9d469ea 100644 --- a/include/constants.h +++ b/include/constants.h @@ -6,7 +6,7 @@ #ifndef STATE_CONSTS_H #define STATE_CONSTS_H -static const int DEBUG = 1; +static const int DEBUG = 0; #define F_SEP "/" enum COLORS { diff --git a/include/game_over.h b/include/game_over.h new file mode 100644 index 0000000..7da303e --- /dev/null +++ b/include/game_over.h @@ -0,0 +1,13 @@ +/** + * Copyright (c) 2014, Miguel Angel Astor Romero. All rights reserved. + * See the file LICENSE for more details. + */ + +#ifndef GAME_OVER_H +#define GAME_OVER_H + +#include "game_state.h" + +void initGOState(gs_t *); + +#endif diff --git a/maps/start.map b/maps/start.map index c47a355..56ee246 100644 --- a/maps/start.map +++ b/maps/start.map @@ -39,7 +39,7 @@ player = 27 15 %exit = X Y MAP_NAME MAP_X MAP_Y exit = 8 25 maps/start.map 0 0 exit = 9 25 maps/start.map 0 0 -exit = 10 24 maps/start.map 0 0 +exit = 10 24 END 0 0 exit = 10 25 maps/start.map 0 0 [DOORS] %door = X Y ID UNLOCKED diff --git a/src/game_over.c b/src/game_over.c new file mode 100644 index 0000000..cecd1b2 --- /dev/null +++ b/src/game_over.c @@ -0,0 +1,99 @@ +/** + * Copyright (c) 2014, Miguel Angel Astor Romero. All rights reserved. + * See the file LICENSE for more details. + */ + +#include +#include +#include + +#include "constants.h" +#include "game_over.h" + +static const char * title = "TITLE PENDING"; +static const char * subtitle = "A game for the Cyberpunk Jam 2014"; +static const char * aWinnerIsYou = "You have completed the scenario!"; +static const char * thanks = "Thank you for playing."; +static const char * goInfo = "Press enter to return to the main menu."; + +static bool enter; + +void goInput(); +gsname_t goUpdate(); +void goRender(int, int); + +void initGOState(gs_t * gs){ + gs->name = GAME_OVER; + gs->input = &goInput; + gs->update = &goUpdate; + gs->render = &goRender; +} + +void goInput(){ + int key = 0; + + key = getch(); + + if(key != ERR){ + if(key == KEY_ENTER || key == '\n') enter = TRUE; + } +} + +gsname_t goUpdate(){ + if(enter){ + enter = FALSE; + return MENU; + } + + return GAME_OVER; +} + +void goRender(int w, int h){ + int sW; + + clear_screen(w, h); + + /* Print the title. */ + sW = strlen(title); + sW /= 2; + + attron(A_BOLD); + + move(1, (w / 2) - sW); + attron(COLOR_PAIR(SN_COLOR)); + printw(title); + + /* Print the subtitle. */ + sW = strlen(subtitle); + sW /= 2; + + move(2, (w / 2) - sW); + attron(COLOR_PAIR(SW_COLOR)); + printw(subtitle); + + attroff(A_BOLD); + + /* Print the game over message. */ + sW = strlen(aWinnerIsYou); + sW /= 2; + + move((h / 2) - 2, (w / 2) - sW); + attron(COLOR_PAIR(GR_COLOR)); + printw(aWinnerIsYou); + + sW = strlen(thanks); + sW /= 2; + + move((h / 2) - 1, (w / 2) - sW); + attron(COLOR_PAIR(GR_COLOR)); + printw(thanks); + + /* Print help. */ + sW = strlen(goInfo); + sW /= 2; + + move(h - 5, (w / 2) - sW); + attron(COLOR_PAIR(MN_COLOR)); + printw(goInfo); +} + diff --git a/src/game_state.c b/src/game_state.c index e952eae..9ddb253 100644 --- a/src/game_state.c +++ b/src/game_state.c @@ -10,11 +10,13 @@ #include "intro.h" #include "main_menu.h" #include "in_game.h" +#include "game_over.h" void initStateArray(gs_t ** s){ initIntroState(&((*s)[INTRO])); initMMState(&((*s)[MENU])); initInGameState(&((*s)[IN_GAME])); + initGOState(&((*s)[GAME_OVER])); } void clear_screen(int w, int h){ diff --git a/src/in_game.c b/src/in_game.c index 420bae4..59d1bc0 100644 --- a/src/in_game.c +++ b/src/in_game.c @@ -5,6 +5,7 @@ #include #include +#include #include #include @@ -140,8 +141,14 @@ gsname_t update(){ if(objs[i].x == iY && objs[i].y == iX){ player.x = objs[i].eX; player.y = objs[i].eY; - loadMap(objs[i].target); - return IN_GAME; + if(strcmp(objs[i].target, "END") != 0){ + loadMap(objs[i].target); + return IN_GAME; + }else{ + initObjects(); + loadMap("maps/start.map"); + return GAME_OVER; + } } } } @@ -519,7 +526,7 @@ void setPlayerStart(){ } void initObjects(){ - int i; + int i, j; for(i = 0; i < MAX_OBJECTS; ++i){ objs[i].type = NONE; @@ -531,9 +538,11 @@ void initObjects(){ objs[i].sY = 0; objs[i].id = 0; objs[i].dId = 0; - objs[i].name[0] = '\0'; - objs[i].target[0] = '\0'; - objs[i].dialog[0] = '\0'; + for(j = 0; j < MAX_STR; j++){ + objs[i].name[j] = '\0'; + objs[i].target[j] = '\0'; + objs[i].dialog[j] = '\0'; + } objs[i].unlocked = 0; } } diff --git a/src/main_menu.c b/src/main_menu.c index 224ada5..2434dee 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -10,14 +10,14 @@ #include "constants.h" #include "main_menu.h" -static char * title = "TITLE PENDING"; -static char * subtitle = "A game for the Cyberpunk Jam 2014"; -static char * opt1 = "New game"; -static char * opt2 = "Replay intro"; -static char * opt3 = "Quit"; -static char * creds = "Designed and programmed by Miky"; -static char * info = "Press enter to select an option. Scroll with the arrow keys."; -static char * info2 = "Press escape while in game to return to the main menu."; +static const char * title = "TITLE PENDING"; +static const char * subtitle = "A game for the Cyberpunk Jam 2014"; +static const char * opt1 = "New game"; +static const char * opt2 = "Replay intro"; +static const char * opt3 = "Quit"; +static const char * creds = "Designed and programmed by Miky"; +static const char * info = "Press enter to select an option. Scroll with the arrow keys."; +static const char * info2 = "Press escape while in game to return to the main menu."; static int selOpt = 0; static bool uK, dK, esc, enter; diff --git a/src/map.c b/src/map.c index 494b0f4..904242d 100644 --- a/src/map.c +++ b/src/map.c @@ -26,8 +26,6 @@ errcode_t readMapData(const char * file, map_cell_t *** map, int * w, int * h){ int rc, i, j; char *end; - fprintf(stderr, "\t%s.readMapData() : found a map.\n", __FILE__); - rc = getline(&buffer, &n, f); if(rc == -1){ free(buffer); From 96c7e316a9638136e2cc5cc3cf18e1f29ce24a7b Mon Sep 17 00:00:00 2001 From: Miguel Angel Astor Romero Date: Sat, 8 Mar 2014 22:05:01 -0430 Subject: [PATCH 23/26] Code formatting. --- src/game_over.c | 6 +++--- src/in_game.c | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/game_over.c b/src/game_over.c index cecd1b2..1c4698c 100644 --- a/src/game_over.c +++ b/src/game_over.c @@ -12,8 +12,8 @@ static const char * title = "TITLE PENDING"; static const char * subtitle = "A game for the Cyberpunk Jam 2014"; -static const char * aWinnerIsYou = "You have completed the scenario!"; -static const char * thanks = "Thank you for playing."; +static const char * aWinnerIsYou = "You have completed the scenario!"; +static const char * thanks = "Thank you for playing."; static const char * goInfo = "Press enter to return to the main menu."; static bool enter; @@ -45,7 +45,7 @@ gsname_t goUpdate(){ return MENU; } - return GAME_OVER; + return GAME_OVER; } void goRender(int w, int h){ diff --git a/src/in_game.c b/src/in_game.c index 59d1bc0..5c2680e 100644 --- a/src/in_game.c +++ b/src/in_game.c @@ -141,14 +141,14 @@ gsname_t update(){ if(objs[i].x == iY && objs[i].y == iX){ player.x = objs[i].eX; player.y = objs[i].eY; - if(strcmp(objs[i].target, "END") != 0){ - loadMap(objs[i].target); - return IN_GAME; - }else{ - initObjects(); - loadMap("maps/start.map"); - return GAME_OVER; - } + if(strcmp(objs[i].target, "END") != 0){ + loadMap(objs[i].target); + return IN_GAME; + }else{ + initObjects(); + loadMap("maps/start.map"); + return GAME_OVER; + } } } } @@ -539,10 +539,10 @@ void initObjects(){ objs[i].id = 0; objs[i].dId = 0; for(j = 0; j < MAX_STR; j++){ - objs[i].name[j] = '\0'; - objs[i].target[j] = '\0'; - objs[i].dialog[j] = '\0'; - } + objs[i].name[j] = '\0'; + objs[i].target[j] = '\0'; + objs[i].dialog[j] = '\0'; + } objs[i].unlocked = 0; } } From 05d69148615ec0fabda6bdd5ab4a285ec7204d34 Mon Sep 17 00:00:00 2001 From: Miguel Angel Astor Romero Date: Sat, 8 Mar 2014 23:23:18 -0430 Subject: [PATCH 24/26] Fixed a bug when showing messages in game. --- src/in_game.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/in_game.c b/src/in_game.c index 5c2680e..cc7d2b6 100644 --- a/src/in_game.c +++ b/src/in_game.c @@ -159,6 +159,9 @@ gsname_t update(){ if(objs[i].x == iY && objs[i].y == iX){ keys[freeKey] = objs[i].id; objs[i].type = NONE; + for(j = 0; j < 128; j++){ + msg[j] = '\0'; + } for(j = 0; keyMsg[j] && j < 128; j++){ msg[j] = keyMsg[j]; } @@ -175,6 +178,10 @@ gsname_t update(){ for(k = 0; k < nO; k++) if(objs[k].type == DIALOG && objs[k].id == objs[i].dId) break; + for(j = 0; j < 128; j++){ + msg[j] = '\0'; + } + for(j = 0; objs[i].name[j] && j < 128; j++) msg[j] = objs[i].name[j]; @@ -202,6 +209,10 @@ gsname_t update(){ } } + for(j = 0; j < 128; j++){ + msg[j] = '\0'; + } + if(objs[i].unlocked){ for(j = 0; openDoor[j] && j < 128; j++){ msg[j] = openDoor[j]; From 83cdd38c4191fa91552970cdec5a6a291c204642 Mon Sep 17 00:00:00 2001 From: Miguel Angel Astor Romero Date: Sun, 9 Mar 2014 16:00:13 -0430 Subject: [PATCH 25/26] Assorted bug fixes. Demo scenario complete. --- editor/editor.py | 8 +- maps/aquarium.map | 80 ++++++++++++++++++ maps/maze.map | 96 +++++++++++++++++++++ maps/start.map | 208 +++++++++++++++++++++++++++++++++++----------- maps/test.map | 61 ++++++++++++++ src/game_over.c | 10 +-- src/in_game.c | 80 +++++++++--------- src/intro.c | 6 +- src/main.c | 26 +++--- src/main_menu.c | 14 ++-- 10 files changed, 474 insertions(+), 115 deletions(-) create mode 100644 maps/aquarium.map create mode 100644 maps/maze.map create mode 100644 maps/test.map diff --git a/editor/editor.py b/editor/editor.py index 6d691df..c1433e8 100755 --- a/editor/editor.py +++ b/editor/editor.py @@ -30,7 +30,7 @@ CELL_SIZE = 10 MAP_SIZE = (64, 64) SCREEN_SIZE = ((MAP_SIZE[1] * CELL_SIZE) + 1, (MAP_SIZE[0] * CELL_SIZE) + 1) SCREEN_FLAGS = pygame.HWSURFACE | pygame.DOUBLEBUF -TITLE = "Cyberpunk Jam 2014 - Level editor" +TITLE = "CyJam :: " FPS = 60 # Cell types @@ -278,6 +278,7 @@ def main(): obj_str = "" fl_str = "" mouse_pos = (0, 0) + mouse_cell = (0, 0) mouse_r_click = False mouse_l_click = False @@ -298,7 +299,7 @@ def main(): # Set title bar. obj_str = get_object_type_name(curr_obj) fl_str = get_floor_type_name(curr_fl) - title = TITLE + " :: FPS: " + str(int(fps)) + title = TITLE + str(mouse_cell) + " :: FPS: " + str(int(fps)) title += " :: " + obj_str + " :: " + fl_str pygame.display.set_caption(title) @@ -315,6 +316,9 @@ def main(): mouse_l_click = True if event.type == pygame.MOUSEMOTION: + i = mouse_pos[1] // CELL_SIZE + j = mouse_pos[0] // CELL_SIZE + mouse_cell = (i, j) if mouse_r_click: mouse_pos = event.pos diff --git a/maps/aquarium.map b/maps/aquarium.map new file mode 100644 index 0000000..6094c96 --- /dev/null +++ b/maps/aquarium.map @@ -0,0 +1,80 @@ +[MAP] +32 32 +00000000000000166100000000000000 +01155111551101166110111111111110 +01666666666111777711166666666610 +05666666666261777716266666666650 +05664444466111777711166444446650 +01664818466101777710166481846610 +01664888466111122111166488846610 +05664181466266666666266418146650 +05664181466111155111166418146650 +01664181466105777750166418146610 +01664888466105777750166488846610 +05664818466111177111166481846650 +05664444466266277266266444446650 +01666666666111177111166666666610 +01166666666111999911166666666110 +00116666666116666661166666661100 +00011666666666666666666666611000 +00001166666666666666666666110000 +00000155155116666661155155100000 +00000000000016666661000000000000 +00000000000011666611000000000000 +00000000000001666610000000000000 +00000000000001166110000000000000 +00000000000000166100000000000000 +11555111555111166111155511155511 +13333614464417766771446441699991 +18883614666417666671466641667791 +18883666666666666666666666697791 +18883666666666666666666666697791 +18883614666417666671466641697791 +13333614464417766771446441699991 +11555111555111166111155511155511 +[PLAYER] +%player = X Y +player = 30 16 +[EXITS] +%exit = X Y MAP_NAME MAP_X MAP_Y +exit = 0 15 END 0 0 +exit = 0 16 END 0 0 +[DOORS] +%door = X Y ID UNLOCKED +door = 1 15 1 0 +door = 1 16 1 0 +door = 24 15 0 1 +door = 24 16 0 1 +door = 27 6 0 1 +door = 27 12 0 1 +door = 27 19 0 1 +door = 27 25 0 1 +door = 28 6 0 1 +door = 28 12 0 1 +door = 28 19 0 1 +door = 28 25 0 1 +door = 31 15 2 0 +door = 31 16 2 0 +[KEYS] +%key = X Y ID +key = 3 12 1 +[PERSONS] +%person = X Y NAME DIALOG_ID +person = 3 19 Cyd 0 +person = 9 6 Godot 1 +person = 9 15 Juan 2 +person = 9 16 Salvo 3 +person = 15 5 Jade 4 +person = 15 26 Wilco 5 +person = 26 5 Mildagrad 6 +person = 28 28 Bartender 7 +[DIALOGS] +%dialog = ID TEXT +dialog = 0 Hello! +dialog = 1 How did you get in here?! +dialog = 2 Bonjour! I cannot give you the key. I misplaced it. +dialog = 3 Bonjour. +dialog = 4 I think there is someone in that aquarium over there. +dialog = 5 I heard some noises coming from inside the wall! +dialog = 6 This aquarium would be better with some fish in it! +dialog = 7 Welcome to the bar. Would you like something to drink? diff --git a/maps/maze.map b/maps/maze.map new file mode 100644 index 0000000..986d593 --- /dev/null +++ b/maps/maze.map @@ -0,0 +1,96 @@ +[MAP] +64 64 +1111111111111111111111111111111111111111111111111111111111111110 +1727172727272717272727172717172717272717271727172727271727272710 +1212121212121211121212121212121212111112111212121211111211111210 +1717172727172727271717172727271727271727172717171717271727172710 +1212111112121112111112121212121111121211111212111212121112111210 +1727271717172717271717272717172717272727272717272717172717271710 +1211121212111112111222111111111211121112111111111112111211111210 +1727172727172727172717272727172717271717272717172727172717272710 +1212121211121211121111111212121111121211121112121111111212111210 +1717172717271717271727171717272727272727171727271727171727171710 +1212111111121111121211121212121111121211121112121212121112121110 +1727272727271727271717272717171727171717271727171717272717272710 +1211111112111211111211121212121211121112111112111112111211121110 +1727271727172727272727171717171727271717272727271727172717271710 +1112111212111212111111121212121111111211111111111112111212111210 +1717172717271727171727271717172727171717171717171727172727272710 +1212121111121112121212121212121112121212121212121211111111121110 +1727171727272727271717272717171717271727272727272717272717271710 +1211121211121211121211111111121211121211121211121112111212111210 +1727271727171717172717171727272717272717271727172727172727271710 +1111111112111212121112121212121111111112121112121111111211111210 +1717272727172717171727272717171717171727171727171727272717172710 +1212121111121112121111121112111212121211121111121212111112121110 +1727171727171727271727271717172717272717272727271717272727171710 +1111121211121112111211111212121212121112111111121211121112121210 +1727271727172717272717272727171727171727172727271727171727272710 +1212121211111212111211121111111211121112111112111211121111111210 +1717172717272717271717271727171717271727271727272727172727271710 +1212121211111211121211121112121611111111121112121111111211121210 +1717171717271727271727171727276667172727171727171727272727171710 +1212111212121111111112121112111611121211121111121112111111121110 +1717271727172727172717271727172717171727172777171727172727272710 +1111111111121211121211111112111212121211111112121212121111111210 +1727172727171717271727272727271727271727272727271717171727272710 +1112111212121211121212111112111211111111111112111212121111121210 +1727271717271727271717171717172717172717272727272717172717271710 +1111121212121211111112121211121212121212111111111112111211121110 +1727172717172727171717271727272717271717172727172727272727271710 +1112112112111112121211121211111111121212121112111111121212111210 +1727172727172717272717271727171727271727171717272727171717272710 +1112121111121211111112111112121211121211121211121112111211111210 +1727271727271717172727171727272717272717171727172717271727172710 +1211111111111212121111121211121211111112121211111211121212121210 +1727272727272717271727171727171727271717272727271717171717171710 +1111111112111212111212121112111111121212111211121212121212121110 +1727272717171717172717271717272727172717171717171717271717272710 +1211111212121112121211111212111211111212121212121112111111121210 +1727271727172727271727271727171717271727171717172727271727271710 +1112111111121111111212111211121212121111121212111211121211111210 +1727172727271717271717171717271717172717172727172717271717172710 +1111121112111212121211121211121111121211111111111212111212121210 +1727171727172727171727272717272727171717272717171717271727271710 +1212111212111211121112111111111112121112111212121211121112121110 +1717271717271727171717172727272727172727171717272717172727272710 +1211121212121111121212111211111211111111121211121212121111111210 +1717171717172717271717272717271717272727271727272717271717272710 +1112121112111212111211121112121211111211121112121111111211121210 +1727272717271717272717171717171727271717272727171727272717271710 +1112111211111212111212111212121111121112121211111211111212111210 +1727171717272717272727272727171727172727171717172717171717172710 +1112121212111112111212111212121212121111121212121212121112121210 +1727172727272727172717172717172717271727271727271717272727271710 +1111111111111111111111111111111111111111111111111111111111111110 +0000000000000000000000000000000000000000000000000000000000000000 +[PLAYER] +%player = X Y +player = 1 1 +[EXITS] +%exit = X Y MAP_NAME MAP_X MAP_Y +exit = 29 31 END 0 0 +[DOORS] +%door = X Y ID UNLOCKED +door = 28 31 1 0 +door = 29 30 2 0 +door = 29 32 3 0 +door = 30 31 4 0 +[KEYS] +%key = X Y ID +key = 17 37 4 +key = 31 43 3 +key = 53 23 2 +key = 57 57 1 +[PERSONS] +%person = X Y NAME DIALOG_ID +person = 1 3 Steven 0 +person = 1 61 Amethyst 1 +person = 61 1 Pearl 2 +person = 61 61 Garnet 3 +[DIALOGS] +%dialog = ID TEXT +dialog = 0 You need any of the four keys to exit this maze. +dialog = 1 GET ME OUT OF HERE! +dialog = 2 Now where is Steven? I told him this place was dangerous! +dialog = 3 Each key works on one door only. diff --git a/maps/start.map b/maps/start.map index 56ee246..19011a3 100644 --- a/maps/start.map +++ b/maps/start.map @@ -1,61 +1,173 @@ [MAP] -32 32 -00000000000000000000000000000000 -00000000000044444440000000000000 -00000000000441111144000000000000 -00000000004411666114400000000000 -44444000044116777611440000000000 -41514400441167777761144000000000 -41771440411677737776114444444000 -41777144416777383777614115114000 -41997711116773888377611166614000 -41797726626738888837666666654000 -41997711116773888377611166614000 -41777144416777383777614115114000 -41771440411677737776114444444000 -41514400441167777761144000000000 -44444000044116777611440000000000 -00000000004411666114400000000000 -00000000000441161144000000000000 -00000000000044565440000000000000 -00000000000004161400000000000000 -00000000000004565400000000000000 -00000000444444161444444000000000 -00000000411551161155114000000000 -00000000416666666666614000000000 -00000000456666666666654000000000 -00000000456677777776654000000000 -00000000416677777776614000000000 -00000000416677777776614000000000 -00000000456677777776654000000000 -00000000456666666666654000000000 -00000000416666666666614000000000 -00000000411551151155114000000000 -00000000444444444444444000000000 +64 64 +0000000000000000000000000000017710000000000000000000000000000000 +0111111111111100000000000000117711000011111111111111111111111110 +0161626162616110000000000001137731100014441666666666666666666610 +0161616161626611000000000011837738110014771699999999999999999610 +0121112111112111100000000018837738810014776666666666666666669610 +0162616262626161110000000013337733310014991696999999999999999910 +0111212121211121610000000013337733310014991696666666666666666910 +0162616161616261610000000018837738810014776699999999999999996910 +0111211121212111611111111111837738110014771696666666666666696910 +0162616261626261626666666661137731100014441111111111111111116110 +0121112121211121611111111161626611000011111000166666666666666610 +0162626161626162610000000161616610000000000000166666666666666610 +0111111111111111111115511121116611111111111111166633333333336610 +0000040000004000001777777166666666661666666666666638888888836610 +4444444444444444441797777667777777766666666133166638888888836610 +0000040000004000005797777167777777761666666388366638888888836610 +0011111115111111105797777167777777761666666388366638888888836610 +0018166177716618101797777667777777766666666133166633333333336610 +0016166177716616101777777167777777761666666666666666666666666610 +0016161199911616101115511166666666661111111111166666666666666610 +0016666166616666100000000111116611111000000000111111111111111110 +0056666166616666500000440000016610000044000000000000000000000000 +0056666666666666500000440000016610000044000000000000000000000001 +0016666166616666100000440000016610000044000000000000000000000011 +0011111166611111100000440000016610000044000000000000000000000111 +0018177166616618104444444444036630444444444400000000000000000181 +0016177166616616104444444444036630444444444400000000000000000181 +0016161166611616100000440000016610000044000000000000000000100181 +0017777166616666100000440000016610000044000000000000000001100181 +0057777166616776504000440000016610000044000000000000000011100181 +0059977666666776504000440000016610000044000000000000000118100161 +0017977166616666104000000000116611000000000000000000000188100161 +0011111166611111104000000001166661100000000000000000000188100161 +0018166166616618104000000011667766110000000000000000100188100161 +0016166166616616100000000116677776611000000000000001100188100181 +0016161166611616104000001166777777661100000000000011100133100181 +0016666166616666104000001667777777766100000000000118100166100181 +0056666166616666504000011677777777776110000000000188100166100181 +0056666666666666504000116677777777776611000000000188100166100181 +0016666166616666104001166777777777777661100000100188100166100181 +0011111166111111100011667777777777777766110001100133100166100161 +0000000166100000000011677777777777777776110011100166100166100161 +0000000166100000000011677777777777777776110118100166100166100161 +0000000166101111110011677777777777777776110188100166100166100161 +0000000166101388310011667777777777777766110188100166100166100161 +0115151166101888810001166777777777777661100133100166100166100181 +0166666666101888811111226677777777776611000166100166100166100161 +0166666666101388826666611667777777766110000166100166100166100161 +0566111111101111111111111696777777696100000166100166100166100181 +0566100000000000000000001696777777696100000166100166100166100181 +0566111111111111111111111996777777699111111166111166111166111121 +0166666666666666666666666666777777666666666666666666666666662661 +0166666666666666666666666666666666666666666666666666666666662661 +0115511551111551155116611311661166113116611551155111155115511111 +0000000000000000000017777777741147777777710000000000000000000000 +0044444444444444444057777777741147777777750444444444444444440000 +0040004000400040004017799999741147999997710400040004000400040000 +0044444444444444444057777777741147777777750444444444444444440000 +0040004000400040004017799999741147999997710400040004000400040000 +0044444444444444444011777777711117777777110444444444444444440000 +0040004000400040004001177777110011777771100400040004000400040000 +0044444444444444444000111111100001111111000444444444444444440000 +0000000000000000000000000000000000000000000000000000000000000000 +0000000000000000000000000000000000000000000000000000000000000000 [PLAYER] %player = X Y -player = 27 15 +player = 26 30 [EXITS] %exit = X Y MAP_NAME MAP_X MAP_Y -exit = 8 25 maps/start.map 0 0 -exit = 9 25 maps/start.map 0 0 -exit = 10 24 END 0 0 -exit = 10 25 maps/start.map 0 0 +exit = 2 30 maps/aquarium.map 0 0 +exit = 2 31 maps/aquarium.map 0 0 +exit = 11 28 maps/maze.map 0 0 [DOORS] %door = X Y ID UNLOCKED -door = 9 22 0 0 +door = 4 42 0 1 +door = 7 42 0 1 +door = 9 60 0 1 +door = 10 28 1 0 +door = 10 30 2 0 +door = 10 31 2 0 +door = 13 43 0 1 +door = 13 46 0 1 +door = 14 25 0 1 +door = 17 25 0 1 +door = 18 43 0 1 +door = 18 46 0 1 +door = 19 3 0 1 +door = 19 5 0 1 +door = 19 13 0 1 +door = 19 15 0 1 +door = 22 7 0 1 +door = 22 11 0 1 +door = 27 3 5 0 +door = 27 5 0 1 +door = 27 13 0 1 +door = 27 15 0 1 +door = 30 7 4 0 +door = 30 11 0 1 +door = 31 30 3 0 +door = 31 31 3 0 +door = 35 3 0 1 +door = 35 5 0 1 +door = 35 13 0 1 +door = 35 15 0 1 +door = 38 7 0 1 +door = 38 11 0 1 [KEYS] %key = X Y ID -key = 7 2 0 +key = 2 8 5 +key = 7 40 3 +key = 25 3 1 +key = 51 62 2 +key = 40 62 4 [PERSONS] %person = X Y NAME DIALOG_ID -person = 8 24 Hugo 0 -person = 9 2 Paco 1 -person = 23 11 Luis 2 -person = 23 19 Donald 3 +person = 3 4 Stan 0 +person = 3 8 Dora 1 +person = 3 40 Bill 2 +person = 4 61 Jenny 3 +person = 5 14 Cilia 4 +person = 7 2 Herdier 5 +person = 8 31 Doorman 6 +person = 8 40 Soos 7 +person = 15 19 Barman 8 +person = 15 24 Haddock 9 +person = 16 39 Dipper 10 +person = 16 40 Mabel 11 +person = 17 12 Itan 12 +person = 17 22 Astro 13 +person = 19 61 Ittle 14 +person = 22 4 Malon 15 +person = 25 62 Error 16 +person = 30 15 Walter 17 +person = 34 6 Rosa 18 +person = 34 15 Calvin 19 +person = 39 3 Nate 20 +person = 40 27 Deckard 21 +person = 40 35 Lester 22 +person = 45 14 Misty 23 +person = 45 31 Hobbes 24 +person = 49 25 Juniper 25 +person = 49 36 Tipsie 26 [DIALOGS] %dialog = ID TEXT -dialog = 0 Step into the elevator to retry. -dialog = 1 I'm unreachable! -dialog = 2 Welcome to Cyjam! -dialog = 3 Have fun. +dialog = 0 Finally, I have them all! +dialog = 1 I wonder what this key is for. +dialog = 2 I'll be watching you... +dialog = 3 Hi, how you doin'? +dialog = 4 Who designs buildings like this? I'm lost! +dialog = 5 Woof! +dialog = 6 Enjoyed your stay? +dialog = 7 Now you can go to the apartment building. +dialog = 8 Want a tip? Go to the very end of the largest hallway. +dialog = 9 They serve the best drinks in here! +dialog = 10 Have you seen our uncle? +dialog = 11 Stan! Where are you? +dialog = 12 ZZZZzzzzzz... +dialog = 13 That man sure drinks a lot! +dialog = 14 Keep an eye out for secret places! +dialog = 15 What are you doing in my house?! +dialog = 16 You never saw me here, OK? +dialog = 17 Like the rug? It really ties the room together! +dialog = 18 ZZZZzzzzzz... +dialog = 19 Hey! Knock first! +dialog = 20 Have you seen dog? It's name is Herdier and it ran away! +dialog = 21 This is one fancy building, all right. +dialog = 22 There seems to be an electrical storm coming this way. +dialog = 23 I love swimming? Do you swim? +dialog = 24 Why won't he hurry?! We are already late as it is! +dialog = 25 May I help you? +dialog = 26 May I help you? diff --git a/maps/test.map b/maps/test.map new file mode 100644 index 0000000..56ee246 --- /dev/null +++ b/maps/test.map @@ -0,0 +1,61 @@ +[MAP] +32 32 +00000000000000000000000000000000 +00000000000044444440000000000000 +00000000000441111144000000000000 +00000000004411666114400000000000 +44444000044116777611440000000000 +41514400441167777761144000000000 +41771440411677737776114444444000 +41777144416777383777614115114000 +41997711116773888377611166614000 +41797726626738888837666666654000 +41997711116773888377611166614000 +41777144416777383777614115114000 +41771440411677737776114444444000 +41514400441167777761144000000000 +44444000044116777611440000000000 +00000000004411666114400000000000 +00000000000441161144000000000000 +00000000000044565440000000000000 +00000000000004161400000000000000 +00000000000004565400000000000000 +00000000444444161444444000000000 +00000000411551161155114000000000 +00000000416666666666614000000000 +00000000456666666666654000000000 +00000000456677777776654000000000 +00000000416677777776614000000000 +00000000416677777776614000000000 +00000000456677777776654000000000 +00000000456666666666654000000000 +00000000416666666666614000000000 +00000000411551151155114000000000 +00000000444444444444444000000000 +[PLAYER] +%player = X Y +player = 27 15 +[EXITS] +%exit = X Y MAP_NAME MAP_X MAP_Y +exit = 8 25 maps/start.map 0 0 +exit = 9 25 maps/start.map 0 0 +exit = 10 24 END 0 0 +exit = 10 25 maps/start.map 0 0 +[DOORS] +%door = X Y ID UNLOCKED +door = 9 22 0 0 +[KEYS] +%key = X Y ID +key = 7 2 0 +[PERSONS] +%person = X Y NAME DIALOG_ID +person = 8 24 Hugo 0 +person = 9 2 Paco 1 +person = 23 11 Luis 2 +person = 23 19 Donald 3 +[DIALOGS] +%dialog = ID TEXT +dialog = 0 Step into the elevator to retry. +dialog = 1 I'm unreachable! +dialog = 2 Welcome to Cyjam! +dialog = 3 Have fun. diff --git a/src/game_over.c b/src/game_over.c index 1c4698c..f57b2c5 100644 --- a/src/game_over.c +++ b/src/game_over.c @@ -10,11 +10,11 @@ #include "constants.h" #include "game_over.h" -static const char * title = "TITLE PENDING"; -static const char * subtitle = "A game for the Cyberpunk Jam 2014"; -static const char * aWinnerIsYou = "You have completed the scenario!"; -static const char * thanks = "Thank you for playing."; -static const char * goInfo = "Press enter to return to the main menu."; +static const char * title = "TITLE PENDING"; +static const char * subtitle = "A game for the Cyberpunk Jam 2014"; +static const char * aWinnerIsYou = "You have completed the scenario!"; +static const char * thanks = "Thank you for playing."; +static const char * goInfo = "Press enter to return to the main menu."; static bool enter; diff --git a/src/in_game.c b/src/in_game.c index cc7d2b6..1baf3a2 100644 --- a/src/in_game.c +++ b/src/in_game.c @@ -25,34 +25,34 @@ typedef struct PLAYER { unsigned short y; } player_t; -static bool **vis; -static bool **seen; -static bool ** wmap; -static bool w_mov = FALSE; -static bool uK, dK, lK, rK, esc; -static clock_t then, msgThen; -static player_t player; -static map_cell_t ** map; -static game_obj_t objs[MAX_OBJECTS]; -static int mW, mH, nO; -static fov_settings_type fov_settings; -static int keys[MAX_KEYS]; -static int freeKey; -static char msg[128]; -static bool newMsg = FALSE; +static bool ** vis; +static bool ** seen; +static bool ** wmap; +static bool w_mov = FALSE; +static bool uK, dK, lK, rK, esc; +static clock_t then, msgThen; +static player_t player; +static map_cell_t ** map; +static game_obj_t objs[MAX_OBJECTS]; +static int mW, mH, nO; +static fov_settings_type fov_settings; +static int keys[MAX_KEYS]; +static int freeKey; +static char msg[128]; +static bool newMsg = FALSE; -void input(); +void input(); gsname_t update(); -void render(int, int); -void drawGui(int, int); -void setPlayerStart(); -void initObjects(); -void initKeys(); -void drawNeon(int, int, floor_t); -void apply(void *, int, int, int, int, void *); -bool opaque(void *, int, int); -void loadMap(const char *); -bool canMoveTo(int, int); +void render(int, int); +void drawGui(int, int); +void setPlayerStart(); +void initObjects(); +void initKeys(); +void drawNeon(int, int, floor_t); +void apply(void *, int, int, int, int, void *); +bool opaque(void *, int, int); +void loadMap(const char *); +bool canMoveTo(int, int); void initInGameState( gs_t * gs) { int i, j; @@ -167,6 +167,7 @@ gsname_t update(){ } newMsg = TRUE; msgThen = clock(); + freeKey++; } } } @@ -418,28 +419,33 @@ void drawNeon(int i, int j, floor_t floor){ else attron(COLOR_PAIR(SN_COLOR)); } - n = map[i ][j - 1 < 0 ? mH - 1 : j - 1].f == floor; - s = map[i ][(j + 1) % mH ].f == floor; - e = map[i - 1 < 0 ? mW - 1 : i - 1][j ].f == floor; - w = map[(i + 1) % mW ][j ].f == floor; + w = map[i ][j - 1 < 0 ? mH - 1 : j - 1].f == floor; + e = map[i ][(j + 1) % mH ].f == floor; + s = map[i - 1 < 0 ? mW - 1 : i - 1][j ].f == floor; + n = map[(i + 1) % mW ][j ].f == floor; if((n && s && e) && (!w)){ printw("\u2560"); return; } - if((n || s) && (!e && !w)){ - printw("\u2550"); + if((n && s && w) && (!e)){ + printw("\u2563"); return; } - if((e || w) && (!n && !s)){ + if((n || s) && (!e && !w)){ printw("\u2551"); return; } + if((e || w) && (!n && !s)){ + printw("\u2550"); + return; + } + if((e && n) && (!s && !w)){ - printw("\u255D"); + printw("\u2554"); return; } @@ -454,17 +460,17 @@ void drawNeon(int i, int j, floor_t floor){ } if((w && s) && (!n && !e)){ - printw("\u2554"); + printw("\u255D"); return; } if((s && e && w) && (!n)){ - printw("\u2560"); + printw("\u2569"); return; } if((n && w && e) && (!s)){ - printw("\u2563"); + printw("\u2566"); return; } diff --git a/src/intro.c b/src/intro.c index cc12980..ce21e76 100644 --- a/src/intro.c +++ b/src/intro.c @@ -16,9 +16,9 @@ void inInput(); gsname_t inUpdate(); void inRender(int, int); -static bool anyKey; -static clock_t then = 0, nThen = 0; -static int mRows = 0, mH = 0; +static bool anyKey; +static clock_t then = 0, nThen = 0; +static int mRows = 0, mH = 0; void initIntroState(gs_t * gs){ gs->name = INTRO; diff --git a/src/main.c b/src/main.c index 96e9534..095fbcc 100644 --- a/src/main.c +++ b/src/main.c @@ -18,25 +18,25 @@ void leave(void); void manage_signal(int signal); -int start_ncurses(void); +int start_ncurses(void); void set_colors(void); void on_resize(int); -static int w = 0, h = 0; +static int w = 0, h = 0; static bool resize = FALSE; int main() { - bool finished = FALSE; - char * home_dir = getenv("HOME"); - FILE * f; /* To avoid a warning. */ - clock_t then, now, delta; - unsigned int fps = 0, pfps = 0; - char * data_dir; - char * log_file; - time_t raw_date; - struct tm * current_date; - gs_t * states; - int c_state; + bool finished = FALSE; + char * home_dir = getenv("HOME"); + FILE * f; /* To avoid a warning. */ + clock_t then, now, delta; + unsigned int fps = 0, pfps = 0; + char * data_dir; + char * log_file; + time_t raw_date; + struct tm * current_date; + gs_t * states; + int c_state; atexit(leave); signal(SIGINT, manage_signal); diff --git a/src/main_menu.c b/src/main_menu.c index 2434dee..a1c4ddc 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -10,14 +10,14 @@ #include "constants.h" #include "main_menu.h" -static const char * title = "TITLE PENDING"; +static const char * title = "TITLE PENDING"; static const char * subtitle = "A game for the Cyberpunk Jam 2014"; -static const char * opt1 = "New game"; -static const char * opt2 = "Replay intro"; -static const char * opt3 = "Quit"; -static const char * creds = "Designed and programmed by Miky"; -static const char * info = "Press enter to select an option. Scroll with the arrow keys."; -static const char * info2 = "Press escape while in game to return to the main menu."; +static const char * opt1 = "New game"; +static const char * opt2 = "Replay intro"; +static const char * opt3 = "Quit"; +static const char * creds = "Designed and programmed by Miky"; +static const char * info = "Press enter to select an option. Scroll with the arrow keys."; +static const char * info2 = "Press escape while in game to return to the main menu."; static int selOpt = 0; static bool uK, dK, esc, enter; From 2628c2d22f3ec1bbe243b131bc9cc597ec43d87e Mon Sep 17 00:00:00 2001 From: Miguel Angel Astor Romero Date: Sun, 9 Mar 2014 16:00:40 -0430 Subject: [PATCH 26/26] Added a title. --- src/game_over.c | 2 +- src/main_menu.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/game_over.c b/src/game_over.c index f57b2c5..ca9528d 100644 --- a/src/game_over.c +++ b/src/game_over.c @@ -10,7 +10,7 @@ #include "constants.h" #include "game_over.h" -static const char * title = "TITLE PENDING"; +static const char * title = "NOT SO ROGUE-LIKE"; static const char * subtitle = "A game for the Cyberpunk Jam 2014"; static const char * aWinnerIsYou = "You have completed the scenario!"; static const char * thanks = "Thank you for playing."; diff --git a/src/main_menu.c b/src/main_menu.c index a1c4ddc..7f3b5e5 100644 --- a/src/main_menu.c +++ b/src/main_menu.c @@ -10,7 +10,7 @@ #include "constants.h" #include "main_menu.h" -static const char * title = "TITLE PENDING"; +static const char * title = "NOT SO ROGUE-LIKE"; static const char * subtitle = "A game for the Cyberpunk Jam 2014"; static const char * opt1 = "New game"; static const char * opt2 = "Replay intro";