Fixed bug where top-left tile was always empty.

This commit is contained in:
Rob Pearce 2016-08-01 15:32:00 +10:00
parent ec44f15c35
commit 1ee8d7aea8
4 changed files with 12 additions and 25 deletions

1
defs.h
View File

@ -992,6 +992,7 @@ typedef struct level_s {
int map3[LEVELW*LEVELH]; // third map layer int map3[LEVELW*LEVELH]; // third map layer
int tileframe[LEVELW*LEVELH]; // tracks frame numbers for tiles int tileframe[LEVELW*LEVELH]; // tracks frame numbers for tiles
int tilewalkvanish[LEVELW*LEVELH]; // tracks how long before tiles disappear int tilewalkvanish[LEVELW*LEVELH]; // tracks how long before tiles disappear
// -1 == "don't disappear"
int *animtiles; // array of offsets to map positions which are animated int *animtiles; // array of offsets to map positions which are animated
int *l3tiles; // array of layer 3 tiles int *l3tiles; // array of layer 3 tiles
struct level_s *next; struct level_s *next;

22
rc.c
View File

@ -884,8 +884,6 @@ int main (int argc, char **argv) {
} }
} }
/********************************************** /**********************************************
* Drawing routines * Drawing routines
*/ */
@ -906,7 +904,6 @@ int main (int argc, char **argv) {
} }
} }
// draw sprites // draw sprites
if (levelcomplete != LV_DOPOKER) { if (levelcomplete != LV_DOPOKER) {
drawallsprites(); drawallsprites();
@ -924,7 +921,6 @@ int main (int argc, char **argv) {
// redraw it // redraw it
drawl3tile(screen, offset%LEVELW,offset/LEVELW); drawl3tile(screen, offset%LEVELW,offset/LEVELW);
} }
@ -1305,7 +1301,6 @@ printf("timer = %d\n",timer);
n--; n--;
} }
} }
} }
if (toggletimer > 0) toggletimer--; if (toggletimer > 0) toggletimer--;
@ -1696,7 +1691,7 @@ void nextlevel(void) {
loadlevel(curlevelnum, B_TRUE); loadlevel(curlevelnum, B_TRUE);
} }
// remmeber layer 2 in case we replace it with water // remember layer 2 in case we replace it with water
for (y = 0 ; y < LEVELH; y++) { for (y = 0 ; y < LEVELH; y++) {
for (x = 0 ; x < LEVELW; x++) { for (x = 0 ; x < LEVELW; x++) {
savemap[y*LEVELW+x] = curlevel->map2[y*LEVELW+x]; savemap[y*LEVELW+x] = curlevel->map2[y*LEVELW+x];
@ -1707,7 +1702,7 @@ void nextlevel(void) {
fruittime = -1; fruittime = -1;
// do the moving to next level transition (ie. scroll the screen) // do the moving to next level transition (ie. scroll the screen)
drawlevel(); drawleveltransition();
// now the player gets invincibility // now the player gets invincibility
if (!inintro()) { if (!inintro()) {
@ -7107,7 +7102,7 @@ void dotileeffects(sprite_t *s) {
// initial transition to a new level // initial transition to a new level
void drawlevel(void) { void drawleveltransition(void) {
int x,y,i; int x,y,i;
double turns; double turns;
double dist[2]; double dist[2];
@ -7194,7 +7189,6 @@ void drawlevel(void) {
} }
} }
// figure out where the players' new start positions are // figure out where the players' new start positions are
if (player) { if (player) {
scrollinfo.dstx[0] = (curlevel->p1x * TILEW) + (TILEW/2); scrollinfo.dstx[0] = (curlevel->p1x * TILEW) + (TILEW/2);
@ -7842,8 +7836,6 @@ void removeall(void) {
SDL_Rect area; SDL_Rect area;
int clearfull = B_FALSE; int clearfull = B_FALSE;
int *animtile; int *animtile;
/* /*
switch (player->powerup) { switch (player->powerup) {
case PW_CANNONFIRE: case PW_CANNONFIRE:
@ -7879,14 +7871,13 @@ void removeall(void) {
*/ */
clearfull = B_TRUE; clearfull = B_TRUE;
if (clearfull) { if (clearfull) {
// clear the entire screen // clear the entire screen
SDL_BlitSurface(temps, NULL, screen, NULL); SDL_BlitSurface(temps, NULL, screen, NULL);
} else { } else {
for (s = sprite; s ; s = s->next) { for (s = sprite; s ; s = s->next) {
/* /*
// blit every tile coverting this sprite // blit every tile covering this sprite
startx = s->x - (s->img->w/2); startx = s->x - (s->img->w/2);
starty = s->y - s->img->h; starty = s->y - s->img->h;
endx = s->x + (s->img->w/2); endx = s->x + (s->img->w/2);
@ -7947,8 +7938,6 @@ void removeall(void) {
area.h = 24; area.h = 24;
SDL_BlitSurface(temps, &area, screen, &area); SDL_BlitSurface(temps, &area, screen, &area);
} }
} }
void drawnetting(sprite_t *s) { void drawnetting(sprite_t *s) {
@ -11399,7 +11388,6 @@ void undoflood(void) {
} }
} }
SDL_BlitSurface(temps, NULL, screen, NULL); SDL_BlitSurface(temps, NULL, screen, NULL);
} }
@ -13466,8 +13454,6 @@ void startgame(void) {
nextlevel(); nextlevel();
firstlevel = B_FALSE; firstlevel = B_FALSE;
flip(B_TRUE);
if (skipto == -1) { if (skipto == -1) {
playfx(FX_BIRDS); playfx(FX_BIRDS);
} }

2
rc.h
View File

@ -7,7 +7,7 @@ void drawbosshealth(void);
void drawtext(void); void drawtext(void);
void movetext(void); void movetext(void);
void removeall(void); void removeall(void);
void drawlevel(void); void drawleveltransition(void);
int randommonster(void); int randommonster(void);
void removesprite(sprite_t *s); void removesprite(sprite_t *s);
void removenetting(sprite_t *s); void removenetting(sprite_t *s);

View File

@ -497,7 +497,7 @@ nfadingtiles = 0;
if (newversion) { if (newversion) {
strncpy(buf2, buf, BUFLEN); strncpy(buf2, buf, BUFLEN);
p = strtok(buf2, ","); p = strtok(buf2, ",");
while (p) { while (p && *p != '\n') {
int numframes; int numframes;
tileid = atoi(p); tileid = atoi(p);
/* validate it */ /* validate it */
@ -536,10 +536,9 @@ nfadingtiles = 0;
numanim++; numanim++;
} }
level->tilewalkvanish[y*LEVELW+x] = getwalkvanish(tileid); if (level->tilewalkvanish[y*LEVELW+x] != -1) {
/*if (level->tilewalkvanish[y*LEVELW+x] != -1) {
printf("tilevanish %d,%d = %d\n",x,y,level->tilewalkvanish[y*LEVELW+x]); printf("tilevanish %d,%d = %d\n",x,y,level->tilewalkvanish[y*LEVELW+x]);
} */ }
// if this is the last line, update level->bottomopen // if this is the last line, update level->bottomopen
if (y == LEVELH-1) { if (y == LEVELH-1) {
@ -561,7 +560,7 @@ nfadingtiles = 0;
} }
/* make sure enough data was found */ /* make sure enough data was found */
if (x < LEVELW+1) { if (x < LEVELW) {
printf("Not enough tiles on line: y = %d\n",y); printf("Not enough tiles on line: y = %d\n",y);
fclose(f); fclose(f);
return B_TRUE; return B_TRUE;
@ -2952,6 +2951,7 @@ void flip(int wantclear) {
gengl(screen); gengl(screen);
blittoscreen(); blittoscreen();
if (wantclear) { if (wantclear) {
// clear screen buffer afterwards
SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, black.r, black.g, black.b)); SDL_FillRect(screen, NULL, SDL_MapRGB(screen->format, black.r, black.g, black.b));
} }
#else #else
@ -3554,6 +3554,7 @@ void drawtile(SDL_Surface *where, int x, int y) {
#endif #endif
} }
/* now draw layer2 if it exists */ /* now draw layer2 if it exists */
if (curlevel->map2[offset] != T_BLANK) { if (curlevel->map2[offset] != T_BLANK) {
tt = gettile(curlevel->map2[offset]); tt = gettile(curlevel->map2[offset]);
@ -3565,7 +3566,6 @@ void drawtile(SDL_Surface *where, int x, int y) {
if (tt->id != curlevel->bgtileid) { if (tt->id != curlevel->bgtileid) {
SDL_BlitSurface(tt->img[frame], NULL, where, &area); SDL_BlitSurface(tt->img[frame], NULL, where, &area);
} }
} }
} }