Added test map file.

This commit is contained in:
2014-03-08 18:26:53 -04:30
parent 87a90c816a
commit 8551458965
2 changed files with 80 additions and 12 deletions

61
maps/start.map Normal file
View File

@@ -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.

View File

@@ -28,7 +28,7 @@ static bool **vis;
static bool **seen; static bool **seen;
static bool ** wmap; static bool ** wmap;
static bool w_mov = FALSE; static bool w_mov = FALSE;
static bool uK, dK, lK, rK; static bool uK, dK, lK, rK, esc;
static clock_t then, msgThen; static clock_t then, msgThen;
static player_t player; static player_t player;
static map_cell_t ** map; static map_cell_t ** map;
@@ -56,6 +56,8 @@ bool canMoveTo(int, int);
void initInGameState( gs_t * gs) { void initInGameState( gs_t * gs) {
int i, j; int i, j;
uK = dK = lK = rK = esc = FALSE;
gs->name = IN_GAME; gs->name = IN_GAME;
gs->input = &input; gs->input = &input;
gs->update = &update; gs->update = &update;
@@ -86,7 +88,7 @@ void initInGameState( gs_t * gs) {
} }
initObjects(); initObjects();
loadMap("map_file.map"); loadMap("maps/start.map");
fov_settings_init(&fov_settings); fov_settings_init(&fov_settings);
fov_settings_set_opacity_test_function(&fov_settings, opaque); fov_settings_set_opacity_test_function(&fov_settings, opaque);
@@ -103,6 +105,7 @@ void input(){
if(key == KEY_DOWN) dK = TRUE; if(key == KEY_DOWN) dK = TRUE;
if(key == KEY_LEFT) lK = TRUE; if(key == KEY_LEFT) lK = TRUE;
if(key == KEY_RIGHT) rK = 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(rK) nX = (iX + 1) % mW;
if(esc) return IN_GAME;
/* Find if the player is standing on an exit, then load the next map. */ /* Find if the player is standing on an exit, then load the next map. */
for(i = 0; i < nO; i++){ for(i = 0; i < nO; i++){
if(objs[i].type == EXIT){ 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++){ for(i = 0; i < nO; i++){
if(objs[i].type == KEY){ if(objs[i].type == KEY){
if(objs[i].x == iY && objs[i].y == iX){ 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++){ for(i = 0; i < nO; i++){
if(objs[i].type == PERSON){ if(objs[i].type == PERSON){
if(objs[i].x == nY && objs[i].y == nX){ 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++){ for(i = 0; i < nO; i++){
if(objs[i].type == DOOR){ if(objs[i].type == DOOR){
if(objs[i].x == nY && objs[i].y == nX){ 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){ if(newMsg){
msgNow = clock(); msgNow = clock();
delta = msgNow - msgThen; delta = msgNow - msgThen;