From 827ea504010b9eeb4eeba02b507b98f48fa5f693 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tobias=20Gl=C3=A4=C3=9Fer?= Date: Sun, 14 Mar 2004 13:08:04 +0000 Subject: [PATCH] level-end bug fixed err hacked to be a bit less annoying ;) SVN-Revision: 214 --- src/gameloop.c | 4 ---- src/level.c | 29 ++++++++++++++++++++++------- src/player.c | 2 +- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/gameloop.c b/src/gameloop.c index 9cc6de8e4..b41f7a404 100644 --- a/src/gameloop.c +++ b/src/gameloop.c @@ -644,7 +644,6 @@ int gameloop(char * subset, int levelnb, int mode) ++frame; } - /* Handle events: */ tux.input.old_fire = tux.input.fire; @@ -1333,9 +1332,6 @@ void drawshape(float x, float y, unsigned char c) { texture_draw(&img_pole, x, y, NO_UPDATE); - /* Mark this as the end position of the level! */ - - endpos = (int)x; } else if (c == '\\') { diff --git a/src/level.c b/src/level.c index bbc704104..de04dd32a 100644 --- a/src/level.c +++ b/src/level.c @@ -18,6 +18,7 @@ #include "screen.h" #include "level.h" #include "physic.h" +#include "scene.h" texture_type img_bkgd, img_bkgd_tile[2][4], img_solid[4], img_brick[2]; @@ -104,7 +105,7 @@ void subset_save(st_subset* st_subset) /* Save data file: */ sprintf(filename, "/levels/%s/", st_subset->name); - + fcreatedir(filename); snprintf(filename, 1024, "%s/levels/%s/info", st_dir, st_subset->name); if(!fwriteable(filename)) @@ -143,7 +144,7 @@ void subset_free(st_subset* st_subset) /* Returns -1, if the loading of the level failed. */ int level_load(st_level* plevel, char *subset, int level) { - int y; + int y,x; FILE * fi; char str[80]; char filename[1024]; @@ -236,6 +237,20 @@ int level_load(st_level* plevel, char *subset, int level) plevel->tiles[y] = (unsigned char*) strdup(line); } + /* Mark the end position of this level! - Is a bit wrong here thought */ + + for (y = 0; y < 15; ++y) + { + for (x = 0; x < plevel->width; ++x) + { + if(plevel->tiles[y][x] == '|') + { + if(x*32 > endpos) + endpos = x*32; + } + } + } + free(line); fclose(fi); return 0; @@ -339,9 +354,9 @@ void level_load_gfx(st_level *plevel) snprintf(fname, 1024, "%s/images/background/%s", DATA_PREFIX, plevel->bkgd_image); texture_load(&img_bkgd, fname, IGNORE_ALPHA); } - else + else { - /* Quick hack to make sure an image is loaded, when we are freeing it afterwards. */# + /* Quick hack to make sure an image is loaded, when we are freeing it afterwards. */# level_load_image(&img_bkgd, plevel->theme,"solid0.png", IGNORE_ALPHA); } } @@ -362,7 +377,7 @@ void level_free_gfx(void) texture_free(&img_bkgd_tile[0][i]); texture_free(&img_bkgd_tile[1][i]); } - + texture_free(&img_bkgd); } @@ -371,11 +386,11 @@ void level_free_gfx(void) void level_load_image(texture_type* ptexture, char* theme, char * file, int use_alpha) { char fname[1024]; - + snprintf(fname, 1024, "%s/themes/%s/%s", st_dir, theme, file); if(!faccessible(fname)) snprintf(fname, 1024, "%s/images/themes/%s/%s", DATA_PREFIX, theme, file); - + texture_load(ptexture, fname, use_alpha); } diff --git a/src/player.c b/src/player.c index 12817e630..bd01d323f 100644 --- a/src/player.c +++ b/src/player.c @@ -321,7 +321,7 @@ void player_action(player_type* pplayer) /* End of level? */ - if (pplayer->base.x - scroll_x >= endpos && endpos != 0) + if (pplayer->base.x >= endpos && endpos != 0) { next_level = 1; } -- 2.11.0