bill@newbreedsoftware.com
http://www.newbreedsoftware.com/supertux/
- April 11, 2000 - December 9, 2003
+ April 11, 2000 - December 28, 2003
*/
#include <stdio.h>
#include "setup.h"
#include "high_scores.h"
#include "menu.h"
-
+#include "badguy.h"
+#include "world.h"
+#include "player.h"
/* Sound files: */
* cape_right[2], * cape_left[2],
* bigcape_right[2], * bigcape_left[2],
* ducktux_right, * ducktux_left,
-* skidtux_right, * skidtux_left;
+* skidtux_right, * skidtux_left, * tux_life;
SDL_Event event;
SDL_Rect src, dest;
SDLKey key;
floating_score_type floating_scores[NUM_FLOATING_SCORES];
upgrade_type upgrades[NUM_UPGRADES];
bullet_type bullets[NUM_BULLETS];
-char song_title[20];
-char levelname[20];
-char leveltheme[20];
-char str[10];
+char song_title[60];
+char levelname[60];
+char leveltheme[60];
+char str[60];
+
/* Local function prototypes: */
void loadshared(void);
void unloadshared(void);
void drawshape(int x, int y, unsigned char c);
+void savegame(void);
unsigned char shape(int x, int y, int sx);
int issolid(int x, int y, int sx);
int isbrick(int x, int y, int sx);
key = event.key.keysym.sym;
- /* Check for menu-events, if the menu is shown */
+ /* Check for menu-events, if the menu is shown */
if(show_menu)
menu_event(key);
-
+
if (key == SDLK_ESCAPE)
{
/* Escape: Open/Close the menu: */
game_pause = 1;
}
}
- else if (key == SDLK_TAB)
+ else if (key == SDLK_TAB && debug_mode == YES)
{
tux_size = !tux_size;
}
- else if (key == SDLK_END)
+ else if (key == SDLK_END && debug_mode == YES)
{
distros += 50;
}
- else if (key == SDLK_SPACE)
+ else if (key == SDLK_SPACE && debug_mode == YES)
{
next_level = 1;
}
if (score > highscore)
save_hs(score);
- unloadlevelgfx();
+ unloadlevelgfx();
unloadlevelsong();
- unloadshared();
+ unloadshared();
return(0);
} /* if (lives < 0) */
}
/* Keep tux in bounds: */
-
if (tux_x < 0)
tux_x = 0;
- else if (tux_x > 320 && scroll_x < ((level_width * 32) - 640))
+ else if (tux_x < 160 && scroll_x > 0 && debug_mode == YES)
+ {
+ scroll_x = scroll_x - ( 160 - tux_x);
+ tux_x = 160;
+
+ if(scroll_x < 0)
+ scroll_x = 0;
+
+ }
+ else if (tux_x > 320 && scroll_x < ((level_width * 32) - 640))
{
/* Scroll the screen in past center: */
current_music = LEVEL_MUSIC;
halt_music();
}
+
if (!playing_music())
- play_music( level_song, 1 );
+ {
+ if (time_left <= TIME_WARNING)
+ play_music( level_song_fast, 1 );
+ else
+ play_music( level_song, 1 );
+ }
+
if (tux_invincible_time > 0)
tux_invincible_time--;
}
drawtext("HIGH", 0, 20, letters_blue, NO_UPDATE);
drawtext(str, 96, 20, letters_gold, NO_UPDATE);
- if (time_left >= 50 || (frame % 10) < 5)
+ if (time_left >= TIME_WARNING || (frame % 10) < 5)
{
sprintf(str, "%d", time_left);
drawtext("TIME", 224, 0, letters_blue, NO_UPDATE);
drawtext("DISTROS", 480, 0, letters_blue, NO_UPDATE);
drawtext(str, 608, 0, letters_gold, NO_UPDATE);
+ drawtext("LIVES", 480, 20, letters_blue, NO_UPDATE);
+
+ for(i=0; i < lives; ++i)
+ {
+ drawimage(tux_life,565+(18*i),20,NO_UPDATE);
+ }
+
if(game_pause)
drawcenteredtext("PAUSE",230,letters_red, NO_UPDATE);
switch (current_music)
{
case LEVEL_MUSIC:
- play_music(level_song, 1);
+ if (time_left <= TIME_WARNING)
+ play_music(level_song_fast, 1);
+ else
+ play_music(level_song, 1);
break;
case HERRING_MUSIC:
play_music(herring_song, 1);
now_time = SDL_GetTicks();
if (now_time < last_time + FPS)
- SDL_Delay(last_time + FPS - now_time);
+ SDL_Delay(last_time + FPS - now_time);
/* Handle time: */
{
time_left--;
+ /* Stop the music; it will start again, faster! */
+ if (time_left == TIME_WARNING)
+ halt_music();
+
if (time_left <= 0)
killtux(KILL);
}
time_left = atoi(str);
/* (Song file for this level) */
- fgets(str, 20, fi);
+ fgets(str, sizeof(song_title), fi);
strcpy(song_title, str);
song_title[strlen(song_title)-1] = '\0';
{
char * song_path;
+ char * song_subtitle;
song_path = (char *) malloc(sizeof(char) * (strlen(DATA_PREFIX) +
strlen(song_title) + 8));
-
sprintf(song_path, "%s/music/%s", DATA_PREFIX, song_title);
-
level_song = load_song(song_path);
+ free(song_path);
+
+ song_path = (char *) malloc(sizeof(char) * (strlen(DATA_PREFIX) +
+ strlen(song_title) + 8 + 5));
+ song_subtitle = strdup(song_title);
+ strcpy(strstr(song_subtitle, "."), "\0");
+ sprintf(song_path, "%s/music/%s-fast%s", DATA_PREFIX, song_subtitle, strstr(song_title, "."));
+ level_song_fast = load_song(song_path);
+ free(song_subtitle);
free(song_path);
}
img_distro[3] = load_image(DATA_PREFIX "/images/shared/distro-3.png",
USE_ALPHA);
+ /* Tux life: */
+
+ tux_life = load_image(DATA_PREFIX "/images/shared/tux-life.png",
+ USE_ALPHA);
/* Herring: */
/* Sound effects: */
- /* if (use_sound) // this can help speeding up a little, but
- we shouldn't take care about "use_sound" here, it's load_sound's job
- / Send a mail to neoneurone@users.sf.net, if you have another opinion. :)
- */
+ /* if (use_sound) // this will introduce SERIOUS bugs here ! because "load_sound"
+ // initialize sounds[i] with the correct pointer's value:
+ // NULL or something else. And it will be dangerous to
+ // play with not-initialized pointers.
+ // This is also true with if (use_music)
+ Send a mail to me: neoneurone@users.sf.net, if you have another opinion. :)
+ */
for (i = 0; i < NUM_SOUNDS; i++)
sounds[i] = load_sound(soundfilenames[i]);
sleep(2);
}
-
+void savegame(void)
+{}