April 11, 2000 - March 15, 2004
*/
+#include <iostream>
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
if (exit_status == NONE)
{
- Player* tux = world->get_tux();
-
// Update Tux and the World
- tux->action(frame_ratio);
world->action(frame_ratio);
}
}
draw();
+ float overlap = 0.0f;
while (exit_status == NONE)
{
/* Calculate the movement-factor */
double frame_ratio = ((double)(update_time-last_update_time))/((double)FRAME_RATE);
- if(frame_ratio > 1.5) /* Quick hack to correct the unprecise CPU clocks a little bit. */
- frame_ratio = 1.5 + (frame_ratio - 1.5) * 0.85;
if(!frame_timer.check())
{
// Handle actions:
if(!game_pause && !show_menu)
{
- action(frame_ratio);
+ frame_ratio *= game_speed;
+ frame_ratio += overlap;
+ while (frame_ratio > 0)
+ {
+ action(1.0f);
+ frame_ratio -= 1.0f;
+ }
+ overlap = frame_ratio;
+
if (exit_status != NONE)
return exit_status;
}
bool use_fullscreen;
bool debug_mode;
bool show_fps;
+float game_speed = 1.0f;
int joystick_num = 0;
char* level_startup_file = 0;
extern char* st_dir;
extern char* st_save_dir;
+extern float game_speed;
extern SDL_Joystick * js;
int wait_for_event(SDL_Event& event,unsigned int min_delay = 0, unsigned int max_delay = 0, bool empty_events = false);
levels = 0;
}
+Level::Level()
+{
+}
+
+Level::Level(const std::string& subset, int level)
+{
+ load(subset, level);
+}
+
+Level::Level(const std::string& filename)
+{
+ load(filename);
+}
+
void
Level::init_defaults()
{
free(song_path);
}
-
unsigned int
Level::gettileid(float x, float y)
{
std::vector<BadGuyData> badguy_data;
public:
+ Level();
+ Level(const std::string& subset, int level);
+ Level(const std::string& filename);
+
/** Will the Level structure with default values */
void init_defaults();
int load(const std::string& filename);
void load_gfx();
+ void free_gfx();
void load_song();
void free_song();
/** Return the id of the tile at position x/y */
unsigned int gettileid(float x, float y);
- void free_gfx();
-
void load_image(Surface** ptexture, std::string theme, const char * file, int use_alpha);
};
ducktux_right = new Surface(datadir +
- "/images/shared/ducktux-right.png",
+ "/images/shared/tux-duck-right.png",
USE_ALPHA);
ducktux_left = new Surface(datadir +
- "/images/shared/ducktux-left.png",
+ "/images/shared/tux-duck-left.png",
USE_ALPHA);
skidtux_right = new Surface(datadir +
img_growup = new Surface(datadir + "/images/shared/egg.png", USE_ALPHA);
img_iceflower = new Surface(datadir + "/images/shared/iceflower.png",
USE_ALPHA);
- img_golden_herring = new Surface(datadir +
- "/images/shared/star.png", USE_ALPHA);
+ img_golden_herring = new Surface(datadir + "/images/shared/star.png", USE_ALPHA);
img_1up = new Surface(datadir + "/images/shared/1up.png",
USE_ALPHA);
// world calls child functions
current_ = this;
- level = new Level;
+ level = new Level(filename);
tux.init();
- level->load(filename);
set_defaults();
get_level()->load_gfx();
// world calls child functions
current_ = this;
- level = new Level;
+ level = new Level(subset, level_nr);
tux.init();
- level->load(subset, level_nr);
set_defaults();
get_level()->load_gfx();
void
World::action(double frame_ratio)
{
+ tux.action(frame_ratio);
+
/* Handle bouncy distros: */
for (unsigned int i = 0; i < bouncy_distros.size(); i++)
bouncy_distros[i].action(frame_ratio);