diff --git a/data/sprites/wingleft0.png b/data/sprites/wingleft0.png new file mode 100644 index 0000000..0e12127 Binary files /dev/null and b/data/sprites/wingleft0.png differ diff --git a/data/sprites/wingleft1.png b/data/sprites/wingleft1.png new file mode 100644 index 0000000..59f22b7 Binary files /dev/null and b/data/sprites/wingleft1.png differ diff --git a/data/sprites/wingleft2.png b/data/sprites/wingleft2.png new file mode 100644 index 0000000..9117f7a Binary files /dev/null and b/data/sprites/wingleft2.png differ diff --git a/data/sprites/wingleft3.png b/data/sprites/wingleft3.png new file mode 100644 index 0000000..e0c5d97 Binary files /dev/null and b/data/sprites/wingleft3.png differ diff --git a/data/sprites/wingright0.png b/data/sprites/wingright0.png new file mode 100644 index 0000000..e5d3700 Binary files /dev/null and b/data/sprites/wingright0.png differ diff --git a/data/sprites/wingright1.png b/data/sprites/wingright1.png new file mode 100644 index 0000000..c01f7c1 Binary files /dev/null and b/data/sprites/wingright1.png differ diff --git a/data/sprites/wingright2.png b/data/sprites/wingright2.png new file mode 100644 index 0000000..79e120b Binary files /dev/null and b/data/sprites/wingright2.png differ diff --git a/data/world1/level99.dat b/data/world1/level99.dat index a87a200..7e99256 100644 --- a/data/world1/level99.dat +++ b/data/world1/level99.dat @@ -12,7 +12,6 @@ monsters 49 2 13 7 10 3 7 3 1 -7 15 15 7 30 15 endmonsters exitdir 1 diff --git a/defs.h b/defs.h index 0bff732..e6f77ea 100644 --- a/defs.h +++ b/defs.h @@ -286,7 +286,7 @@ #define S_SLOPE 2 // Sprite types -#define MAXPTYPES 122 +#define MAXPTYPES 124 #define P_PLAYER 0 #define P_RAT 1 #define P_CHEESE 2 @@ -414,6 +414,8 @@ #define P_ACCORDION 119 #define P_WINGBOOTS 120 #define P_SKULL 121 +#define P_WINGLEFT 122 +#define P_WINGRIGHT 123 // cards #define CARDFONTX 4 diff --git a/edit.c b/edit.c index fb8ecf8..67c2e8f 100644 --- a/edit.c +++ b/edit.c @@ -637,7 +637,7 @@ void cleanup(void) { } void drawstatus(void) { - char temps[MIDBUFLEN]; + char temps[BUFLEN]; SDL_Rect area; int wid; SDL_Color *col; @@ -653,8 +653,8 @@ void drawstatus(void) { sprintf(temps, "Level %d",curlevelnum); wid = writetext(screen, area.x, area.y, temps, EDITTEXT, &white); area.x += (wid + STATUSPAD); - // show level name - sprintf(temps, "%s",curlevel->filename); + // show level filename + snprintf(temps, BUFLEN, "%s",curlevel->filename); wid = writetext(screen, area.x, area.y, temps, EDITTEXT, &white); area.x += (wid + STATUSPAD); // show level desc @@ -1053,6 +1053,9 @@ int isplacablesprite(int sid) { case P_MASK: case P_TAP: case P_CLOVER: + case P_SKULL: + case P_WINGLEFT: + case P_WINGRIGHT: return B_FALSE; } @@ -1082,12 +1085,6 @@ void draweditortile(SDL_Surface *where, int x, int y) { area.w = TILEW; area.h = TILEH; - - - - - - /* draw blank tile first */ tt = gettile(curlevel->bgtileid); SDL_BlitSurface(levelbg, &area, where, &area); diff --git a/rc.c b/rc.c index 4ddf0c2..da4a438 100644 --- a/rc.c +++ b/rc.c @@ -24,6 +24,7 @@ SDL_Surface *screen; TTF_Font *font[MAXLETTERHEIGHT]; +int havejoysticks; SDL_Joystick *joy; Uint8 *keys; int joyx,joyy,joybut[MAXJOYBUTTONS]; @@ -5797,7 +5798,9 @@ void initsdl(void) { if (joy) { printf("%d joystick(s) detected and enabled.\n",SDL_NumJoysticks()); SDL_JoystickEventState(SDL_ENABLE); + havejoysticks = B_TRUE; } else { + havejoysticks = B_FALSE; printf("No joysticks found.\n"); } } @@ -6585,7 +6588,7 @@ void handleinput(void) { keys = SDL_GetKeyState(NULL); // check for joystick - if (joy) { + if (havejoysticks) { joyx = SDL_JoystickGetAxis(joy,0); joyy = SDL_JoystickGetAxis(joy,1); for (i = 0; i < MAXJOYBUTTONS; i++) { @@ -6949,19 +6952,20 @@ int keydown(int checkfor) { return B_TRUE; } // check for joystick - if (checkfor == SDLK_RIGHT) { - //if ((joyx >= 6000) || (joybut[5])) return B_TRUE; - if (joybut[5]) return B_TRUE; - } else if (checkfor == SDLK_LEFT) { - if (joybut[7]) return B_TRUE; - } else if (checkfor == SDLK_UP) { - if (joybut[4]) return B_TRUE; - } else if (checkfor == SDLK_DOWN) { - if (joybut[6]) return B_TRUE; - } else if (checkfor == SDLK_z) { - if (joybut[0] || joybut[14]) return B_TRUE; - } else if (checkfor == SDLK_x) { - if (joybut[1] || joybut[13]) return B_TRUE; + if (havejoysticks) { + if (checkfor == SDLK_RIGHT) { + if (joybut[5]) return B_TRUE; + } else if (checkfor == SDLK_LEFT) { + if (joybut[7]) return B_TRUE; + } else if (checkfor == SDLK_UP) { + if (joybut[4]) return B_TRUE; + } else if (checkfor == SDLK_DOWN) { + if (joybut[6]) return B_TRUE; + } else if (checkfor == SDLK_z) { + if (joybut[0] || joybut[14]) return B_TRUE; + } else if (checkfor == SDLK_x) { + if (joybut[1] || joybut[13]) return B_TRUE; + } } return B_FALSE; diff --git a/shared.c b/shared.c index 3fc6e5a..1d2024f 100644 --- a/shared.c +++ b/shared.c @@ -403,6 +403,8 @@ int loadlevel(int wnum, int lnum, int wantmonsters) { tempanim[numanim] = y*LEVELW+x; numanim++; } + if (y*LEVELW+x == 800) printf("tileframe of 800 is %d\n",level->tileframe[y*LEVELW+x]); + x++; p = strtok(NULL, ","); @@ -1166,6 +1168,7 @@ int loadimagesets(void) { loadspriteimage(P_MASK,1, "sprites/maskleft.png"); imageset[P_MASK].numimages = 2; + loadspriteimage(P_MASKPOWERUP,F_WALK1, "sprites/maskpowerup.png"); imageset[P_MASKPOWERUP].numimages = 1; @@ -1292,6 +1295,26 @@ int loadimagesets(void) { loadspriteimage(P_WINGBOOTS,F_WALK1, "sprites/wingboots.png"); imageset[P_WINGBOOTS].numimages = 1; + // wings + loadspriteimage(P_WINGLEFT,0, "sprites/wingleft0.png"); // standing + loadspriteimage(P_WINGLEFT,1, "sprites/wingleft1.png"); // jumping + loadspriteimage(P_WINGLEFT,2, "sprites/wingleft2.png"); // jumping + loadspriteimage(P_WINGLEFT,3, "sprites/wingleft3.png"); // swimming + imageset[P_WINGLEFT].numimages = 4; + + loadspriteimage(P_WINGRIGHT,0, "sprites/wingright0.png"); // standing + loadspriteimage(P_WINGRIGHT,1, "sprites/wingright1.png"); // jumping + loadspriteimage(P_WINGRIGHT,2, "sprites/wingright2.png"); // jumping + imageset[P_WINGRIGHT].numimages = 3; + + // manually do flipped images + for (i = 0; i < 3; i++) { + imageset[P_WINGLEFT].img[MAXFRAMES+i] = rotozoomSurfaceXY(imageset[P_WINGLEFT].img[i], 0, -1,1,0); + imageset[P_WINGRIGHT].img[MAXFRAMES+i] = rotozoomSurfaceXY(imageset[P_WINGRIGHT].img[i], 0, -1,1,0); + } + // and one more for WINGLEFT... + imageset[P_WINGLEFT].img[MAXFRAMES+3] = rotozoomSurfaceXY(imageset[P_WINGLEFT].img[3], 0, -1,1,0); + loadspriteimage(P_SKULL,F_WALK1, "sprites/skull.png"); imageset[P_SKULL].numimages = 1; @@ -1647,6 +1670,10 @@ void drawsprite(sprite_t *s) { if (s->dir == -1) { frame += MAXFRAMES; } + } else if ((s->id == P_WINGLEFT) || (s->id == P_WINGRIGHT)) { + if (player->dir == -1) { + frame += MAXFRAMES; + } } /* make red if required */ if (s->angry && s->id != P_BLACKCLOUD) { @@ -1694,46 +1721,42 @@ void drawsprite(sprite_t *s) { area.w = 0; area.h = 0; - //if (area.y < (480-s->img->h)) { -/* -if (s == player) { -printf("player at %0.1f,%0.1f\n",player->x,player->y); -} -*/ - - if (s->invuln) { - if (timer % 2 == 0) { - //SDL_BlitSurface(s->img, NULL, screen, &area); + if (s->invuln) { + if (timer % 2 == 0) { + //SDL_BlitSurface(s->img, NULL, screen, &area); + if (s == player) { + drawplayer(s, &area); + } else { doblit(s->img, screen, &area); } - } else if (s == boss && s->dead) { - if ((timer / 10) % 2 == 0) { - //SDL_BlitSurface(s->img, NULL, screen, &area); - doblit(s->img, screen, &area); - } - } else { - // draw the sprite + } + } else if (s == boss && s->dead) { + if ((timer / 10) % 2 == 0) { //SDL_BlitSurface(s->img, NULL, screen, &area); doblit(s->img, screen, &area); - /* for opengl */ - //SDL_UpdateRect(screen, area.x, area.y, area.w, area.h); } + } else { + if (s == player) { + drawplayer(s, &area); + } else { + doblit(s->img, screen, &area); + } + } - // ice cube - if (s->iced) { - if (!s->iceimg) { - double xmod,ymod; - xmod = (double)s->img->w / (double)icecube->w; - ymod = (double)s->img->h / (double)icecube->h; - // create image - s->iceimg = rotozoomSurfaceXY(icecube,0, xmod, ymod ,0); - } - // draw it - doblit(s->iceimg, screen, &area); - //SDL_BlitSurface(s->iceimg, NULL, screen, &area); - + // ice cube + if (s->iced) { + if (!s->iceimg) { + double xmod,ymod; + xmod = (double)s->img->w / (double)icecube->w; + ymod = (double)s->img->h / (double)icecube->h; + // create image + s->iceimg = rotozoomSurfaceXY(icecube,0, xmod, ymod ,0); } - //} + // draw it + doblit(s->iceimg, screen, &area); + //SDL_BlitSurface(s->iceimg, NULL, screen, &area); + + } @@ -1756,6 +1779,7 @@ printf("player at %0.1f,%0.1f\n",player->x,player->y); void killsprite(sprite_t *s) { sprite_t *nextone, *lastone; +#ifndef __EDITOR sprite_t *s2; // remove boss pointer @@ -1794,6 +1818,7 @@ void killsprite(sprite_t *s) { SDL_FreeSurface(s->img); } } +#endif nextone = s->next; if (nextone != NULL) { @@ -1954,6 +1979,9 @@ int iseffect(int id) { case P_MASK: case P_MOVINGCARD: case P_FIVECARDS: + // these last two aren't REALLY effects since they never have a sprite allocated + case P_WINGLEFT: + case P_WINGRIGHT: return B_TRUE; } @@ -3105,3 +3133,98 @@ int getcardvalue(int cardid) { return (points+1); } + +// draw player, and wings if required +void drawplayer(sprite_t *s, SDL_Rect *where) { +#ifndef __EDITOR + SDL_Rect wingarea; + int wingframe; +#endif + +#ifndef __EDITOR + if (s->doublejump) { + // draw wings behind the sprite + if (s->jumping || s->falling) { + // flapping wings + if ((timer/12) % 2 == 0) { + wingframe = 1; + } else { + wingframe = 2; + } + } else { + // still wings + wingframe = 0; + } + + wingarea.x = player->x - (imageset[P_WINGRIGHT].img[wingframe]->w/2); + wingarea.y = player->y - (imageset[P_WINGRIGHT].img[wingframe]->h); + if (wingframe == 0) { // still + wingarea.x += (4*player->dir); + wingarea.y += 2; + } else if ((wingframe >= 1) && (wingframe <= 2)) { // flapping + wingarea.x += (11*player->dir); + wingarea.y -= 9; + } + + // when climbing, show "left" wing twice instead + // when swimming, only show left wing + if (!s->climbing && !s->swimming) { + if (player->dir == -1) wingframe += MAXFRAMES; + doblit(imageset[P_WINGRIGHT].img[wingframe], screen, &wingarea); + } + } +#endif + + // draw the sprite + doblit(s->img, screen, where); + +#ifndef __EDITOR + if (s->doublejump) { + // draw wings in front of the sprite + if (s->swimming) { + wingframe = 3; + } else if (s->jumping || s->falling) { + // flapping wings + if ((timer/12) % 2 == 0) { + wingframe = 1; + } else { + wingframe = 2; + } + } else { + // still wings + wingframe = 0; + } + + wingarea.x = player->x - (imageset[P_WINGLEFT].img[wingframe]->w/2); + wingarea.y = player->y - (imageset[P_WINGLEFT].img[wingframe]->h); + if (wingframe == 0) { // still + if (s->climbing) { + wingarea.x -= 4; + wingarea.y += 2; + } else { + wingarea.x -= (6*player->dir); + wingarea.y += 2; + } + } else if ((wingframe >= 1) && (wingframe <= 2)) { // flapping + wingarea.x -= (11*player->dir); + wingarea.y -= 9; + } else if (wingframe == 3) { + wingarea.y -= 9; + wingarea.x -= (6*player->dir); + } + + + if (player->dir == -1) wingframe += MAXFRAMES; + doblit(imageset[P_WINGLEFT].img[wingframe], screen, &wingarea); + + if (s->climbing) { + // draw the other wing + wingarea.x += 8; + // reverse it + if (player->dir == -1) wingframe -= MAXFRAMES; + else wingframe += MAXFRAMES; + doblit(imageset[P_WINGLEFT].img[wingframe], screen, &wingarea); + } + } +#endif +} diff --git a/shared.h b/shared.h index f4fe5f6..4b847b5 100644 --- a/shared.h +++ b/shared.h @@ -60,6 +60,7 @@ int getcardvalue(int cardid); int getcardsuit(int cardid); int getworld(int lev); int getlevel(int lev); +void drawplayer(sprite_t *s, SDL_Rect *where); // for doco void setfruitinfo(void); void setinfo(int id, char *name, char *desc, char *file); diff --git a/templates/wings.png b/templates/wings.png new file mode 100644 index 0000000..8602713 Binary files /dev/null and b/templates/wings.png differ