super-tux-commit Mailing List for Super Tux (Page 32)
Brought to you by:
wkendrick
You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
(94) |
Apr
(500) |
May
(531) |
Jun
(196) |
Jul
(224) |
Aug
(193) |
Sep
(117) |
Oct
(115) |
Nov
(319) |
Dec
(97) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(19) |
Feb
|
Mar
(105) |
Apr
(41) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(6) |
2007 |
Jan
(1) |
Feb
(2) |
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
(2) |
Aug
(2) |
Sep
|
Oct
|
Nov
|
Dec
|
2008 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
(4) |
Jul
|
Aug
|
Sep
(7) |
Oct
(12) |
Nov
(26) |
Dec
(39) |
2009 |
Jan
(6) |
Feb
(15) |
Mar
(10) |
Apr
(25) |
May
(29) |
Jun
(21) |
Jul
(26) |
Aug
(8) |
Sep
(3) |
Oct
|
Nov
|
Dec
(10) |
2010 |
Jan
(5) |
Feb
(5) |
Mar
(2) |
Apr
|
May
(5) |
Jun
|
Jul
(1) |
Aug
(2) |
Sep
(2) |
Oct
(2) |
Nov
|
Dec
|
From: Ricardo C. <rm...@us...> - 2004-09-15 22:12:12
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28065/src Modified Files: gameloop.cpp Log Message: Forgot to make this translatable. Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.178 retrieving revision 1.179 diff -u -d -r1.178 -r1.179 --- gameloop.cpp 15 Sep 2004 21:59:30 -0000 1.178 +++ gameloop.cpp 15 Sep 2004 22:12:00 -0000 1.179 @@ -194,7 +194,7 @@ Vector(0, 310), LAYER_FOREGROUND1); if(best_level_statistics != NULL) - best_level_statistics->draw_message_info(context, "Best Level Statistics"); + best_level_statistics->draw_message_info(context, _("Best Level Statistics")); context.do_drawing(); |
From: Ricardo C. <rm...@us...> - 2004-09-15 21:59:39
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24462/src Modified Files: gameloop.cpp gameloop.h statistics.cpp statistics.h worldmap.cpp Log Message: Added drawing of statistics on levels messages and game over. Also fixed a couple of things on statistics. Index: gameloop.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.h,v retrieving revision 1.60 retrieving revision 1.61 diff -u -d -r1.60 -r1.61 --- gameloop.h 14 Sep 2004 22:26:13 -0000 1.60 +++ gameloop.h 15 Sep 2004 21:59:30 -0000 1.61 @@ -45,6 +45,7 @@ class Level; class Sector; +class Statistics; namespace SuperTux { class DrawingContext; @@ -95,7 +96,7 @@ DrawingContext* context; Timer time_left; - GameSession(const std::string& level, int mode, bool flip_level_ = false); + GameSession(const std::string& level, int mode, bool flip_level_ = false, Statistics* statistics = NULL); ~GameSession(); /** Enter the busy loop */ @@ -134,6 +135,8 @@ void on_escape_press(); void process_menu(); + + Statistics* best_level_statistics; }; std::string slotinfo(int slot); Index: statistics.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/statistics.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- statistics.cpp 15 Sep 2004 18:49:24 -0000 1.3 +++ statistics.cpp 15 Sep 2004 21:59:30 -0000 1.4 @@ -44,6 +44,16 @@ } } +int +my_min(int a, int b) +{ +if(a == -1) + return b; +if(b == -1) + return a; +return std::min(a, b); +} + Statistics::Statistics() { timer.init(true); @@ -77,6 +87,9 @@ void Statistics::draw_worldmap_info(DrawingContext& context) { + if(stats[SCORE_STAT] == -1) // not initialized yet + return; + if(!timer.check()) { timer.start(TOTAL_DISPLAY_TIME); @@ -113,9 +126,29 @@ } void -Statistics::draw_message_info(DrawingContext& context) +Statistics::draw_message_info(DrawingContext& context, std::string title) { - // TODO + if(stats[SCORE_STAT] == -1) // not initialized yet + return; + + context.draw_text_center(gold_text, title, Vector(0, 400), LAYER_GUI); + + char str[128]; + for(int i = 0; i < NUM_STATS; i++) + { + if(i == SCORE_STAT) + sprintf(str, _("Max score: %d"), stats[SCORE_STAT]); + else if(i == BADGUYS_SQUISHED_STAT) + sprintf(str, _("Max fragging: %d"), stats[BADGUYS_SQUISHED_STAT]); + else if(i == SHOTS_STAT) + sprintf(str, _("Min shots: %d"), stats[SHOTS_STAT]); + else if(i == TIME_NEEDED_STAT) + sprintf(str, _("Min time needed: %d"), stats[TIME_NEEDED_STAT]); + else// if(i == JUMPS_STAT) + sprintf(str, _("Min jumps: %d"), stats[JUMPS_STAT]); + + context.draw_text_center(white_text, str, Vector(0, 430 + i*22), LAYER_GUI); + } } void @@ -147,12 +180,13 @@ Statistics::merge(Statistics& stats_) { stats[SCORE_STAT] = std::max(stats[SCORE_STAT], stats_.stats[SCORE_STAT]); - stats[JUMPS_STAT] = std::min(stats[JUMPS_STAT], stats_.stats[JUMPS_STAT]); + if(stats[JUMPS_STAT] != -1) + stats[JUMPS_STAT] = my_min(stats[JUMPS_STAT], stats_.stats[JUMPS_STAT]); stats[BADGUYS_SQUISHED_STAT] = std::max(stats[BADGUYS_SQUISHED_STAT], stats_.stats[BADGUYS_SQUISHED_STAT]); - stats[SHOTS_STAT] = std::min(stats[SHOTS_STAT], stats_.stats[SHOTS_STAT]); + stats[SHOTS_STAT] = my_min(stats[SHOTS_STAT], stats_.stats[SHOTS_STAT]); stats[TIME_NEEDED_STAT] = - std::min(stats[TIME_NEEDED_STAT], stats_.stats[TIME_NEEDED_STAT]); + my_min(stats[TIME_NEEDED_STAT], stats_.stats[TIME_NEEDED_STAT]); } void Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.117 retrieving revision 1.118 diff -u -d -r1.117 -r1.118 --- worldmap.cpp 15 Sep 2004 11:50:31 -0000 1.117 +++ worldmap.cpp 15 Sep 2004 21:59:30 -0000 1.118 @@ -834,7 +834,8 @@ shrink_fade(Vector((special_tile->x*32 + 16 + offset.x),(special_tile->y*32 + 16 + offset.y)), 500); GameSession session(datadir + "/levels/" + special_tile->level_name, - ST_GL_LOAD_LEVEL_FILE, special_tile->vertical_flip); + ST_GL_LOAD_LEVEL_FILE, special_tile->vertical_flip, + &special_tile->statistics); switch (session.run()) { @@ -908,18 +909,20 @@ context.draw_text_center(blue_text, _("GAMEOVER"), Vector(0, 200), LAYER_FOREGROUND1); - sprintf(str, _("SCORE: %d"), total_stats.get_points(SCORE_STAT)); - context.draw_text_center(gold_text, str, - Vector(0, 230), LAYER_FOREGROUND1); +// sprintf(str, _("SCORE: %d"), total_stats.get_points(SCORE_STAT)); +// context.draw_text_center(gold_text, str, +// Vector(0, 230), LAYER_FOREGROUND1); sprintf(str, _("COINS: %d"), player_status.distros); context.draw_text_center(gold_text, str, Vector(0, screen->w - 32), LAYER_FOREGROUND1); + total_stats.draw_message_info(context, _("Total Statistics")); + context.do_drawing(); SDL_Event event; - wait_for_event(event,2000,5000,true); + wait_for_event(event,2000,6000,true); quit = true; player_status.reset(); Index: statistics.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/statistics.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- statistics.h 15 Sep 2004 18:49:24 -0000 1.3 +++ statistics.h 15 Sep 2004 21:59:30 -0000 1.4 @@ -57,7 +57,7 @@ /* Draw to the worldmap or a game message */ // TODO: make this functions working void draw_worldmap_info(DrawingContext& context); - void draw_message_info(DrawingContext& context); + void draw_message_info(DrawingContext& context, std::string title); /* Add / Set / Get points to/from one of the stats this can keep track of */ void add_points(int stat, int points); Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.177 retrieving revision 1.178 diff -u -d -r1.177 -r1.178 --- gameloop.cpp 15 Sep 2004 21:38:49 -0000 1.177 +++ gameloop.cpp 15 Sep 2004 21:59:30 -0000 1.178 @@ -78,9 +78,10 @@ return false; } -GameSession::GameSession(const std::string& levelname_, int mode, bool flip_level_) +GameSession::GameSession(const std::string& levelname_, int mode, bool flip_level_, Statistics* statistics) : level(0), currentsector(0), st_gl_mode(mode), - end_sequence(NO_ENDSEQUENCE), levelname(levelname_), flip_level(flip_level_) + end_sequence(NO_ENDSEQUENCE), levelname(levelname_), flip_level(flip_level_), + best_level_statistics(statistics) { current_ = this; @@ -184,7 +185,7 @@ if(level->get_author().size()) context.draw_text_center(white_small_text, std::string(_("by ")) + level->get_author(), - Vector(0, 400), LAYER_FOREGROUND1); + Vector(0, 360), LAYER_FOREGROUND1); if(flip_level) @@ -192,6 +193,9 @@ _("Level Vertically Flipped!"), Vector(0, 310), LAYER_FOREGROUND1); + if(best_level_statistics != NULL) + best_level_statistics->draw_message_info(context, "Best Level Statistics"); + context.do_drawing(); SDL_Event event; @@ -546,7 +550,7 @@ tux->invincible_timer.start(7000); //FIXME: Implement a winning timer for the end sequence (with special winning animation etc.) // add left time to stats - global_stats.set_points(TIME_NEEDED_STAT, time_left.get_gone()); + global_stats.set_points(TIME_NEEDED_STAT, time_left.get_gone() / 1000); } else if (!end_sequence && tux->is_dead()) { |
From: Marek M. <wa...@us...> - 2004-09-15 21:38:59
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17297/src Modified Files: gameloop.cpp Log Message: added two new cheat codes: "shrink" lets Tux react like being hit by an enemy "kill" kills Tux (useful if stuck in an unfinished level) Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.176 retrieving revision 1.177 diff -u -d -r1.176 -r1.177 --- gameloop.cpp 15 Sep 2004 11:50:31 -0000 1.176 +++ gameloop.cpp 15 Sep 2004 21:38:49 -0000 1.177 @@ -433,7 +433,16 @@ tux.invincible_timer.start(time_left.get_left()); last_keys.clear(); } - + if(compare_last(last_keys, "shrink")) + { // remove powerups + tux.kill(tux.SHRINK); + last_keys.clear(); + } + if(compare_last(last_keys, "kill")) + { // kill Tux + tux.kill(tux.KILL); + last_keys.clear(); + } break; case SDL_JOYAXISMOTION: |
From: Ricardo C. <rm...@us...> - 2004-09-15 18:49:33
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9304/src Modified Files: statistics.cpp statistics.h Log Message: Added a Jump 'n Bump like way to show statistics. It won't work on SDL mode, cause of a bug in draw_part(). I'll have a look at this. Index: statistics.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/statistics.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- statistics.cpp 15 Sep 2004 11:50:31 -0000 1.2 +++ statistics.cpp 15 Sep 2004 18:49:24 -0000 1.3 @@ -21,6 +21,7 @@ #include "utils/lispwriter.h" #include "statistics.h" #include "video/drawing_context.h" +#include "app/gettext.h" #include "resources.h" Statistics global_stats; @@ -45,7 +46,11 @@ Statistics::Statistics() { - reset(); + timer.init(true); + display_stat = 1; + + for(int i = 0; i < NUM_STATS; i++) + stats[i] = -1; } Statistics::~Statistics() @@ -66,14 +71,45 @@ writer.write_int(stat_name_to_string(i), stats[i]); } +#define TOTAL_DISPLAY_TIME 3400 +#define FADING_TIME 600 + void Statistics::draw_worldmap_info(DrawingContext& context) { + if(!timer.check()) + { + timer.start(TOTAL_DISPLAY_TIME); + display_stat++; + if(display_stat >= NUM_STATS) + display_stat = 1; + } + + int alpha; + if(timer.get_gone() < FADING_TIME) + alpha = timer.get_gone() * 255 / FADING_TIME; + else if(timer.get_left() < FADING_TIME) + alpha = timer.get_left() * 255 / FADING_TIME; + else + alpha = 255; + char str[128]; - //TODO: this is just a simple message, will be imporved - sprintf(str, "Level Max Score: %d", stats[SCORE_STAT]); - context.draw_text(white_small_text, str, Vector(580, 580), LAYER_GUI); + context.draw_text(white_small_text, _("Level Statistics"), Vector(550, 490), LAYER_GUI); + + sprintf(str, _("Max score: %d"), stats[SCORE_STAT]); + context.draw_text(white_small_text, str, Vector(560, 506), LAYER_GUI); + + if(display_stat == BADGUYS_SQUISHED_STAT) + sprintf(str, _("Max fragging: %d"), stats[BADGUYS_SQUISHED_STAT]); + else if(display_stat == SHOTS_STAT) + sprintf(str, _("Min shots: %d"), stats[SHOTS_STAT]); + else if(display_stat == TIME_NEEDED_STAT) + sprintf(str, _("Min time needed: %d"), stats[TIME_NEEDED_STAT]); + else// if(display_stat == JUMPS_STAT) + sprintf(str, _("Min jumps: %d"), stats[JUMPS_STAT]); + + context.draw_text(white_small_text, str, Vector(560, 522), LAYER_GUI, NONE_EFFECT, alpha); } void Index: statistics.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/statistics.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- statistics.h 15 Sep 2004 11:50:31 -0000 1.2 +++ statistics.h 15 Sep 2004 18:49:24 -0000 1.3 @@ -20,6 +20,8 @@ #ifndef SUPERTUX_STATISTICS_H #define SUPERTUX_STATISTICS_H +#include "special/timer.h" + using namespace SuperTux; namespace SuperTux { @@ -57,11 +59,12 @@ void draw_worldmap_info(DrawingContext& context); void draw_message_info(DrawingContext& context); + /* Add / Set / Get points to/from one of the stats this can keep track of */ void add_points(int stat, int points); - int get_points(int stat); - void set_points(int stat, int points); + int get_points(int stat); + /* Reset statistics */ void reset(); /* Give another Statistics object, find the best of each one */ @@ -72,6 +75,9 @@ private: int stats[NUM_STATS]; + + Timer timer; + int display_stat; }; extern Statistics global_stats; |
From: Ricardo C. <rm...@us...> - 2004-09-15 18:47:56
|
Update of /cvsroot/super-tux/supertux/lib/video In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8936/lib/video Modified Files: drawing_context.cpp drawing_context.h font.cpp font.h Log Message: Added an alpha argument for drawing fonts. Index: font.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/font.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- font.cpp 29 Jul 2004 11:24:41 -0000 1.6 +++ font.cpp 15 Sep 2004 18:47:45 -0000 1.7 @@ -114,17 +114,17 @@ } void -Font::draw(const std::string& text, const Vector& pos, Uint32 drawing_effect) +Font::draw(const std::string& text, const Vector& pos, Uint32 drawing_effect, int alpha) { if(shadowsize > 0) draw_chars(shadow_chars, text, pos + Vector(shadowsize, shadowsize), - drawing_effect); + drawing_effect, alpha); - draw_chars(chars, text, pos, drawing_effect); + draw_chars(chars, text, pos, drawing_effect, alpha); } void -Font::draw_center(const std::string& text, const Vector& pos, Uint32 drawing_effect) +Font::draw_center(const std::string& text, const Vector& pos, Uint32 drawing_effect, int alpha) { /* Cut lines changes into seperate strings, needed to support centering text with break lines. @@ -140,12 +140,12 @@ { temp[text.copy(temp, text.size() - i, i)] = '\0'; draw(temp, Vector(screen->w/2 - get_text_width(temp)/2 + pos.x, pos.y + y), - drawing_effect); + drawing_effect, alpha); break; } temp[text.copy(temp, l - i, i)] = '\0'; draw(temp, Vector(screen->w/2 - get_text_width(temp)/2 + pos.x, pos.y + y), - drawing_effect); + drawing_effect, alpha); i = l+1; y += h + 2; @@ -154,7 +154,7 @@ void Font::draw_chars(Surface* pchars, const std::string& text, const Vector& pos, - Uint32 drawing_effect) + Uint32 drawing_effect, int alpha) { SurfaceImpl* impl = pchars->impl; @@ -179,7 +179,7 @@ int source_x = (index % 16) * w; int source_y = (index / 16) * h; - impl->draw_part(source_x, source_y, p.x, p.y, w, h, 255, drawing_effect); + impl->draw_part(source_x, source_y, p.x, p.y, w, h, alpha, drawing_effect); p.x += w; } } Index: drawing_context.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/drawing_context.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- drawing_context.cpp 28 Jul 2004 14:57:24 -0000 1.4 +++ drawing_context.cpp 15 Sep 2004 18:47:45 -0000 1.5 @@ -78,7 +78,7 @@ void DrawingContext::draw_text(Font* font, const std::string& text, - const Vector& position, int layer, Uint32 drawing_effect) + const Vector& position, int layer, Uint32 drawing_effect, int alpha) { DrawingRequest request; @@ -91,6 +91,7 @@ textrequest->font = font; textrequest->text = text; textrequest->center = false; + textrequest->alpha = alpha; request.request_data = textrequest; drawingrequests.push_back(request); @@ -98,7 +99,7 @@ void DrawingContext::draw_text_center(Font* font, const std::string& text, - const Vector& position, int layer, Uint32 drawing_effect) + const Vector& position, int layer, Uint32 drawing_effect, int alpha) { DrawingRequest request; @@ -111,6 +112,7 @@ textrequest->font = font; textrequest->text = text; textrequest->center = true; + textrequest->alpha = alpha; request.request_data = textrequest; drawingrequests.push_back(request); @@ -218,9 +220,9 @@ TextRequest* textrequest = (TextRequest*) request.request_data; if(textrequest->center) - textrequest->font->draw_center(textrequest->text, request.pos, request.drawing_effect); + textrequest->font->draw_center(textrequest->text, request.pos, request.drawing_effect, textrequest->alpha); else - textrequest->font->draw(textrequest->text, request.pos, request.drawing_effect); + textrequest->font->draw(textrequest->text, request.pos, request.drawing_effect, textrequest->alpha); delete textrequest; } Index: drawing_context.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/drawing_context.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- drawing_context.h 28 Jul 2004 14:57:24 -0000 1.5 +++ drawing_context.h 15 Sep 2004 18:47:45 -0000 1.6 @@ -67,10 +67,10 @@ Uint32 drawing_effect = NONE_EFFECT); /// Draws a text. void draw_text(Font* font, const std::string& text, const Vector& position, - int layer, Uint32 drawing_effect = NONE_EFFECT); + int layer, Uint32 drawing_effect = NONE_EFFECT, int alpha = 255); /// Draws aligned text. void draw_text_center(Font* font, const std::string& text, - const Vector& position, int layer, Uint32 drawing_effect = NONE_EFFECT); + const Vector& position, int layer, Uint32 drawing_effect = NONE_EFFECT, int alpha = 255); /// Draws a color gradient onto the whole screen */ void draw_gradient(Color from, Color to, int layer); /// Fills a rectangle. @@ -130,6 +130,7 @@ Font* font; std::string text; bool center; + int alpha; }; struct GradientRequest Index: font.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/font.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- font.h 29 Jul 2004 11:24:41 -0000 1.7 +++ font.h 15 Sep 2004 18:47:45 -0000 1.8 @@ -64,11 +64,11 @@ friend class DrawingContext; void draw(const std::string& text, const Vector& pos, - Uint32 drawing_effect = NONE_EFFECT); + Uint32 drawing_effect = NONE_EFFECT, int alpha = 255); void draw_center(const std::string& text, const Vector& pos, - Uint32 drawing_effect = NONE_EFFECT); + Uint32 drawing_effect = NONE_EFFECT, int alpha = 255); void draw_chars(Surface* pchars, const std::string& text, - const Vector& position, Uint32 drawing_effect); + const Vector& position, Uint32 drawing_effect, int alpha); Surface* chars; Surface* shadow_chars; |
From: Marek M. <wa...@us...> - 2004-09-15 15:15:35
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24424/src Modified Files: player.cpp player.h Log Message: implemented double jump (press up again while jumping) and hovering (press and hold up while falling down) both need some tweaking (especially when jumping off enemies) and should of course be triggered by special items in the final game Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.166 retrieving revision 1.167 diff -u -d -r1.166 -r1.167 --- player.cpp 15 Sep 2004 11:50:31 -0000 1.166 +++ player.cpp 15 Sep 2004 15:15:24 -0000 1.167 @@ -158,7 +158,9 @@ last_ground_y = 0; fall_mode = ON_GROUND; jumping = false; + double_jumping = false; can_jump = true; + can_double_jump = false; butt_jump = false; frame_main = 0; @@ -532,7 +534,9 @@ --base.y; jumping = true; + double_jumping = false; can_jump = false; + can_double_jump = false; if (size == SMALL) SoundManager::get()->play_sound(IDToSound(SND_JUMP)); else @@ -541,9 +545,25 @@ // Let go of jump key else if(input.up == UP && jumping && physic.get_velocity_y() > 0) { - jumping = false; + if (!double_jumping && !duck) {can_double_jump = true;} + jumping = false; physic.set_velocity_y(0); } + + // Double jump + if (input.up == DOWN && can_double_jump) + { + can_double_jump = false; + jumping = true; + double_jumping = true; + physic.set_velocity_y(5.2); + } + + // Hover + if (input.up == DOWN && !jumping && !butt_jump && physic.get_velocity_y() <= 0) + { + physic.set_velocity_y(-1); + } /* In case the player has pressed Down while in a certain range of air, enable butt jump action */ Index: player.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.h,v retrieving revision 1.84 retrieving revision 1.85 diff -u -d -r1.84 -r1.85 --- player.h 9 Sep 2004 18:42:18 -0000 1.84 +++ player.h 15 Sep 2004 15:15:25 -0000 1.85 @@ -147,7 +147,9 @@ FallMode fall_mode; bool jumping; + bool double_jumping; bool can_jump; + bool can_double_jump; bool butt_jump; int frame_; int frame_main; |
From: Ricardo C. <rm...@us...> - 2004-09-15 11:50:43
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13781/src Modified Files: badguy.cpp gameloop.cpp player.cpp sector.cpp statistics.cpp statistics.h worldmap.cpp Log Message: Made statistics to keep track of also: bad guys squished, shots, time needed and jumps number. Also print in the worldmap a message to show the maximum level's score. This is temporary and will be replaced with a better info text. Index: statistics.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/statistics.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- statistics.cpp 14 Sep 2004 22:31:46 -0000 1.1 +++ statistics.cpp 15 Sep 2004 11:50:31 -0000 1.2 @@ -1,5 +1,6 @@ -// SuperTux -// Copyright (C) 2004 SuperTux Development Team, see AUTHORS for details +// +// SuperTux - A Jump'n Run +// Copyright (C) 2004 Ricardo Cruz <ri...@ae...> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -19,9 +20,29 @@ #include "utils/lispreader.h" #include "utils/lispwriter.h" #include "statistics.h" +#include "video/drawing_context.h" +#include "resources.h" Statistics global_stats; +std::string +stat_name_to_string(int stat_enum) +{ + switch(stat_enum) + { + case SCORE_STAT: + return "score"; + case BADGUYS_SQUISHED_STAT: + return "badguys-squished"; + case SHOTS_STAT: + return "shots"; + case TIME_NEEDED_STAT: + return "time-needed"; + case JUMPS_STAT: + return "jumps"; + } +} + Statistics::Statistics() { reset(); @@ -34,13 +55,31 @@ void Statistics::parse(LispReader& reader) { - reader.read_int("score", stats[SCORE_STAT]); + for(int i = 0; i < NUM_STATS; i++) + reader.read_int(stat_name_to_string(i).c_str(), stats[i]); } void Statistics::write(LispWriter& writer) { - writer.write_int("score", stats[SCORE_STAT]); + for(int i = 0; i < NUM_STATS; i++) + writer.write_int(stat_name_to_string(i), stats[i]); +} + +void +Statistics::draw_worldmap_info(DrawingContext& context) +{ + char str[128]; + + //TODO: this is just a simple message, will be imporved + sprintf(str, "Level Max Score: %d", stats[SCORE_STAT]); + context.draw_text(white_small_text, str, Vector(580, 580), LAYER_GUI); +} + +void +Statistics::draw_message_info(DrawingContext& context) +{ + // TODO } void @@ -56,9 +95,15 @@ } void +Statistics::set_points(int stat, int points) +{ + stats[stat] = points; +} + +void Statistics::reset() { - for(int i = 0; i < MAX_STATS; i++) + for(int i = 0; i < NUM_STATS; i++) stats[i] = 0; } @@ -66,10 +111,17 @@ Statistics::merge(Statistics& stats_) { stats[SCORE_STAT] = std::max(stats[SCORE_STAT], stats_.stats[SCORE_STAT]); + stats[JUMPS_STAT] = std::min(stats[JUMPS_STAT], stats_.stats[JUMPS_STAT]); + stats[BADGUYS_SQUISHED_STAT] = + std::max(stats[BADGUYS_SQUISHED_STAT], stats_.stats[BADGUYS_SQUISHED_STAT]); + stats[SHOTS_STAT] = std::min(stats[SHOTS_STAT], stats_.stats[SHOTS_STAT]); + stats[TIME_NEEDED_STAT] = + std::min(stats[TIME_NEEDED_STAT], stats_.stats[TIME_NEEDED_STAT]); } void Statistics::operator+=(const Statistics& stats_) { - stats[SCORE_STAT] += stats_.stats[SCORE_STAT]; + for(int i = 0; i < NUM_STATS; i++) + stats[i] += stats_.stats[i]; } Index: statistics.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/statistics.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- statistics.h 14 Sep 2004 22:31:46 -0000 1.1 +++ statistics.h 15 Sep 2004 11:50:31 -0000 1.2 @@ -1,5 +1,6 @@ -// SuperTux -// Copyright (C) 2004 SuperTux Development Team, see AUTHORS for details +// +// SuperTux - A Jump'n Run +// Copyright (C) 2004 Ricardo Cruz <ri...@ae...> // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -24,11 +25,16 @@ namespace SuperTux { class LispReader; class LispWriter; +class DrawingContext; } enum { SCORE_STAT, - MAX_STATS + BADGUYS_SQUISHED_STAT, + SHOTS_STAT, + TIME_NEEDED_STAT, + JUMPS_STAT, + NUM_STATS }; /** This class is a layer between level and worldmap to keep @@ -46,11 +52,16 @@ /// write statistics to lisp file void write(LispWriter& writer); - // TODO: add drawing functions to draw stats on WorldMap + /* Draw to the worldmap or a game message */ + // TODO: make this functions working + void draw_worldmap_info(DrawingContext& context); + void draw_message_info(DrawingContext& context); void add_points(int stat, int points); int get_points(int stat); + void set_points(int stat, int points); + void reset(); /* Give another Statistics object, find the best of each one */ @@ -60,7 +71,7 @@ void operator+=(const Statistics& o); private: - int stats[MAX_STATS]; + int stats[NUM_STATS]; }; extern Statistics global_stats; Index: sector.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sector.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- sector.cpp 14 Sep 2004 22:26:23 -0000 1.25 +++ sector.cpp 15 Sep 2004 11:50:31 -0000 1.26 @@ -724,7 +724,8 @@ else throw std::runtime_error("wrong bullet type."); add_object(new_bullet); - + + global_stats.add_points(SHOTS_STAT, 1); SoundManager::get()->play_sound(IDToSound(SND_SHOOT)); return true; Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.165 retrieving revision 1.166 diff -u -d -r1.165 -r1.166 --- player.cpp 13 Sep 2004 22:45:44 -0000 1.165 +++ player.cpp 15 Sep 2004 11:50:31 -0000 1.166 @@ -35,6 +35,7 @@ #include "resources.h" #include "interactive_object.h" #include "video/screen.h" +#include "statistics.h" // behavior definitions: #define TILES_FOR_BUTTJUMP 3 @@ -517,6 +518,8 @@ // Press jump key if(input.up == DOWN && can_jump && on_ground()) { + global_stats.add_points(JUMPS_STAT, 1); + if(duck) { // only jump a little bit when in duck mode { physic.set_velocity_y(3); } else { Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.cpp,v retrieving revision 1.122 retrieving revision 1.123 diff -u -d -r1.122 -r1.123 --- badguy.cpp 14 Sep 2004 10:39:32 -0000 1.122 +++ badguy.cpp 15 Sep 2004 11:50:31 -0000 1.123 @@ -34,6 +34,7 @@ #include "level.h" #include "sector.h" #include "tilemap.h" +#include "statistics.h" Sprite* img_mriceblock_flat_left; Sprite* img_mriceblock_flat_right; @@ -1070,6 +1071,8 @@ Sector::current()->add_score(Vector(base.x, base.y), 25 * player_status.score_multiplier); SoundManager::get()->play_sound(IDToSound(SND_SQUISH), get_pos(), Sector::current()->player->get_pos()); + + global_stats.add_points(BADGUYS_SQUISHED_STAT, 1); player_status.score_multiplier++; return; @@ -1121,6 +1124,8 @@ Sector::current()->add_score(Vector(base.x, base.y), 25 * player_status.score_multiplier); + + global_stats.add_points(BADGUYS_SQUISHED_STAT, 1); player_status.score_multiplier++; // simply remove the fish... @@ -1156,7 +1161,8 @@ player->bounce(this); base.y += 66 - base.height; - + + global_stats.add_points(BADGUYS_SQUISHED_STAT, 1); Sector::current()->add_score(Vector(base.x, base.y), 25 * player_status.score_multiplier); player_status.score_multiplier++; Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.116 retrieving revision 1.117 diff -u -d -r1.116 -r1.117 --- worldmap.cpp 14 Sep 2004 22:26:23 -0000 1.116 +++ worldmap.cpp 15 Sep 2004 11:50:31 -0000 1.117 @@ -1109,6 +1109,8 @@ context.draw_text_center(white_text, i->title, Vector(0, screen->h - white_text->get_height() - 30), LAYER_FOREGROUND1); + + i->statistics.draw_worldmap_info(context); } /* Display an in-map message in the map, if any as been selected */ Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.175 retrieving revision 1.176 diff -u -d -r1.175 -r1.176 --- gameloop.cpp 14 Sep 2004 22:26:08 -0000 1.175 +++ gameloop.cpp 15 Sep 2004 11:50:31 -0000 1.176 @@ -535,6 +535,9 @@ SoundManager::get()->play_music(level_end_song, 0); endsequence_timer.start(7000); // 5 seconds until we finish the map tux->invincible_timer.start(7000); //FIXME: Implement a winning timer for the end sequence (with special winning animation etc.) + + // add left time to stats + global_stats.set_points(TIME_NEEDED_STAT, time_left.get_gone()); } else if (!end_sequence && tux->is_dead()) { |
From: Ricardo C. <rm...@us...> - 2004-09-15 10:43:28
|
Update of /cvsroot/super-tux/supertux/data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1311/data Modified Files: Makefile.am Log Message: Don't forget to include extro-bonus.txt. Index: Makefile.am =================================================================== RCS file: /cvsroot/super-tux/supertux/data/Makefile.am,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- Makefile.am 17 Aug 2004 21:50:58 -0000 1.16 +++ Makefile.am 15 Sep 2004 10:43:19 -0000 1.17 @@ -7,6 +7,7 @@ EXTRA_DIST = \ intro.txt \ extro.txt \ + extro-bonus.txt \ CREDITS \ images/supertux.strf \ $(wildcard sounds/*.wav) \ |
From: Ricardo C. <rm...@us...> - 2004-09-15 10:41:39
|
Update of /cvsroot/super-tux/supertux/po In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv958/po Modified Files: pt.po Log Message: Updated Portuguese translation. Index: pt.po =================================================================== RCS file: /cvsroot/super-tux/supertux/po/pt.po,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- pt.po 14 Sep 2004 22:59:55 -0000 1.11 +++ pt.po 15 Sep 2004 10:41:27 -0000 1.12 @@ -1,4 +1,5 @@ -# translation of pt.po to +# translation of pt.po to European Portuguese +# translation of pt.po to # translation of pt.po to # translation of pt.po to # translation of pt.po to @@ -11,13 +12,14 @@ "Project-Id-Version: pt\n" "Report-Msgid-Bugs-To: sup...@li...\n" "POT-Creation-Date: 2004-09-15 00:08+0100\n" -"PO-Revision-Date: 2004-06-10 14:53+0100\n" +"PO-Revision-Date: 2004-09-15 11:51+0100\n" "Last-Translator: Ricardo Cruz <ri...@ae...>\n" -"Language-Team: \n" +"Language-Team: European Portuguese\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" "X-Generator: KBabel 1.3\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" #: src/gameloop.cpp:186 msgid "by " @@ -25,7 +27,7 @@ #: src/gameloop.cpp:192 msgid "Level Vertically Flipped!" -msgstr "" +msgstr "NÃvel Invertido na Vertical!" #: src/gameloop.cpp:612 msgid "PAUSE - Press 'P' To Play" @@ -77,11 +79,11 @@ #: src/gameloop.cpp:898 msgid "Slot" -msgstr "" +msgstr "Slot" #: src/gameloop.cpp:898 msgid "Free" -msgstr "" +msgstr "Livre" #: src/misc.cpp:94 src/misc.cpp:154 msgid "Start Game" @@ -223,9 +225,8 @@ "para mais informações.\n" #: src/title.cpp:385 -#, fuzzy msgid "Are you sure you want to delete slot" -msgstr "Tens a certeza que queres remover o slot %d?" +msgstr "Tens a certeza que queres remover o slot" #: src/worldmap.cpp:908 msgid "GAMEOVER" @@ -241,7 +242,6 @@ "\n" #: lib/app/setup.cpp:775 -#, fuzzy msgid "" "Display Options:\n" " -f, --fullscreen Run in fullscreen mode.\n" @@ -273,7 +273,8 @@ "\n" msgstr "" "Opções Gráficas:\n" -" --fullscreen Ocupar todo o ecrã.\n" +" --fullscreen Correr ocupando todo o ecrã.\n" +" -w, --window Correr numa janela.\n" " --opengl Caso tenha sido compilado com suporte para OpenGL, " "isto irá fazer\n" " com que o SuperTux o use.\n" @@ -290,6 +291,8 @@ " Define como os botões e eixos devem ser mapeados\n" " --leveleditor Abre o editor de nÃveis num dado ficheiro (e apenas " "quando um é fornecido.)\n" +" --worldmap Abre o ficheiro de worldmap especificado.\n" +" --flip-levels Inverte os nÃveis na vertical.\n" " -d, --datadir DIR Carregar os dados do jogo do DIR (omissão: " "automático)\n" " --debug-mode Activa o modo de depuração, que é útil para " @@ -299,19 +302,19 @@ " opções, licença e contolos do jogo.\n" " --usage Mostra uma breve listagem das opções via a linha de " "comandos.\n" -" --version Mostra a versão do SuperTux que está a correr.\n" +" --version Mostra a versão do SuperTux que estás a correr.\n" "\n" #: lib/app/setup.cpp:834 -#, fuzzy, c-format +#, c-format msgid "" "Usage: %s [--fullscreen] [--opengl] [--disable-sound] [--disable-music] [--" "debug] | [--usage | --help | --version] [--leveleditor] [--worldmap] [--flip-" "levels] FILENAME\n" msgstr "" "Uso: %s [--fullscreen] [--opengl] [--disable-sound] [--disable-music] [--" -"debug-mode] | [--usage | --help | --version] [--leveleditor] " -"NOME_DO_FICHEIRO\n" +"debug] | [--usage | --help | --version] [--leveleditor] [--worldmap] [--flip-" +"levels] NOME_DO_FICHEIRO\n" #: lib/gui/menu.cpp:67 msgid "Yes" @@ -369,18 +372,3 @@ msgid "Left Alt" msgstr "Alt esquerdo" -#~ msgid "Slot %d - Savegame" -#~ msgstr "Slot %d - Jogo gravado" - -#~ msgid "Slot %d - Free" -#~ msgstr "Slot %d - Livre" - -#~ msgid " SuperTux " -#~ msgstr " SuperTux " - -#~ msgid "" -#~ "\n" -#~ " Please see the file \"README.txt\" for more details.\n" -#~ msgstr "" -#~ "\n" -#~ " Dá uma olhadela no ficheiro \"README.txt\" para mais detalhes.\n" |
From: Ricardo C. <rm...@us...> - 2004-09-14 22:31:54
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12369/src Added Files: statistics.cpp statistics.h Log Message: Ooops, forgot to upload the actual Statistics implementation. --- NEW FILE: statistics.cpp --- // SuperTux // Copyright (C) 2004 SuperTux Development Team, see AUTHORS for details // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. #include "utils/lispreader.h" #include "utils/lispwriter.h" #include "statistics.h" Statistics global_stats; Statistics::Statistics() { reset(); } Statistics::~Statistics() { } void Statistics::parse(LispReader& reader) { reader.read_int("score", stats[SCORE_STAT]); } void Statistics::write(LispWriter& writer) { writer.write_int("score", stats[SCORE_STAT]); } void Statistics::add_points(int stat, int points) { stats[stat] += points; } int Statistics::get_points(int stat) { return stats[stat]; } void Statistics::reset() { for(int i = 0; i < MAX_STATS; i++) stats[i] = 0; } void Statistics::merge(Statistics& stats_) { stats[SCORE_STAT] = std::max(stats[SCORE_STAT], stats_.stats[SCORE_STAT]); } void Statistics::operator+=(const Statistics& stats_) { stats[SCORE_STAT] += stats_.stats[SCORE_STAT]; } --- NEW FILE: statistics.h --- // SuperTux // Copyright (C) 2004 SuperTux Development Team, see AUTHORS for details // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA // 02111-1307, USA. #ifndef SUPERTUX_STATISTICS_H #define SUPERTUX_STATISTICS_H using namespace SuperTux; namespace SuperTux { class LispReader; class LispWriter; } enum { SCORE_STAT, MAX_STATS }; /** This class is a layer between level and worldmap to keep * track of stuff like scores, and minor, but funny things, like * number of jumps and stuff */ class Statistics { public: Statistics(); ~Statistics(); /// read statistics from lisp file void parse(LispReader& reader); /// write statistics to lisp file void write(LispWriter& writer); // TODO: add drawing functions to draw stats on WorldMap void add_points(int stat, int points); int get_points(int stat); void reset(); /* Give another Statistics object, find the best of each one */ void merge(Statistics& stats); /* Add two statistic objects */ void operator+=(const Statistics& o); private: int stats[MAX_STATS]; }; extern Statistics global_stats; #endif /*SUPERTUX_STATISTICS_H*/ |
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11135/src Modified Files: gameloop.cpp gameloop.h level.cpp Makefile.am scene.cpp scene.h sector.cpp worldmap.cpp worldmap.h Log Message: Implemented a statistics system. I believe this feature was originally requested by Ryan and the aim is to provide more replay value. Currently, it just keeps track of score. In future, it could keep track of other things like: min number of jumps, max number of enemies killed, min number of shots, min time needed, etc. When a better value is reached after playing the level again, it is replaced in the old statistics. Worldmap is the one in charge for saving statistics. TODO: draw current score and other stats of the current level in world map. I am thinking in drawing it in the Jump'n Bump way, that is using fade on text. I had to use LispWriter when saving a slot. Index: scene.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.cpp,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- scene.cpp 26 Jul 2004 18:09:14 -0000 1.33 +++ scene.cpp 14 Sep 2004 22:26:23 -0000 1.34 @@ -25,8 +25,7 @@ PlayerStatus player_status; PlayerStatus::PlayerStatus() - : score(0), - distros(0), + : distros(0), lives(START_LIVES), bonus(NO_BONUS), score_multiplier(1) @@ -35,7 +34,6 @@ void PlayerStatus::reset() { - score = 0; distros = 0; lives = START_LIVES; bonus = NO_BONUS; Index: Makefile.am =================================================================== RCS file: /cvsroot/super-tux/supertux/src/Makefile.am,v retrieving revision 1.41 retrieving revision 1.42 diff -u -d -r1.41 -r1.42 --- Makefile.am 29 Jul 2004 23:11:03 -0000 1.41 +++ Makefile.am 14 Sep 2004 22:26:23 -0000 1.42 @@ -14,7 +14,8 @@ scene.h special.cpp special.h supertux.cpp title.cpp title.h worldmap.cpp \ worldmap.h tile.h tile.cpp tile_manager.h tile_manager.cpp resources.h \ resources.cpp gameobjs.h gameobjs.cpp background.h background.cpp tilemap.h \ - tilemap.cpp serializable.h sector.cpp sector.h misc.h misc.cpp defines.h + tilemap.cpp serializable.h sector.cpp sector.h misc.h misc.cpp defines.h \ + statistics.cpp # EOF # INCLUDES = -I$(top_srcdir)/lib Index: sector.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sector.cpp,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- sector.cpp 14 Sep 2004 10:27:05 -0000 1.24 +++ sector.cpp 14 Sep 2004 22:26:23 -0000 1.25 @@ -40,6 +40,7 @@ #include "resources.h" #include "interactive_object.h" #include "door.h" +#include "statistics.h" Sector* Sector::_current = 0; @@ -653,7 +654,7 @@ void Sector::add_score(const Vector& pos, int s) { - player_status.score += s; + global_stats.add_points(SCORE_STAT, s); add_object(new FloatingScore(pos, s)); } @@ -779,9 +780,9 @@ counting_distros = false; solids->change_at(pos, tile->next_tile); } - + SoundManager::get()->play_sound(IDToSound(SND_DISTRO)); - player_status.score = player_status.score + SCORE_DISTRO; + global_stats.add_points(SCORE_STAT, SCORE_DISTRO); player_status.distros++; return true; } @@ -797,7 +798,7 @@ /* Get some score: */ SoundManager::get()->play_sound(IDToSound(SND_BRICK)); - player_status.score = player_status.score + SCORE_BRICK; + global_stats.add_points(SCORE_STAT, SCORE_BRICK); return true; } @@ -835,7 +836,7 @@ case 1: // Box with a distro! add_bouncy_distro(Vector(posx, posy)); SoundManager::get()->play_sound(IDToSound(SND_DISTRO)); - player_status.score = player_status.score + SCORE_DISTRO; + global_stats.add_points(SCORE_STAT, SCORE_DISTRO); player_status.distros++; break; @@ -900,7 +901,7 @@ (int)(pos.y / 32) * 32)); } - player_status.score = player_status.score + SCORE_DISTRO; + global_stats.add_points(SCORE_STAT, SCORE_DISTRO); player_status.distros++; } Index: gameloop.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.h,v retrieving revision 1.59 retrieving revision 1.60 diff -u -d -r1.59 -r1.60 --- gameloop.h 13 Sep 2004 22:48:50 -0000 1.59 +++ gameloop.h 14 Sep 2004 22:26:13 -0000 1.60 @@ -86,6 +86,7 @@ // the sector and spawnpoint we shoudl spawn after this frame std::string newsector; std::string newspawnpoint; + public: enum ExitStatus { ES_NONE, ES_LEVEL_FINISHED, ES_GAME_OVER, ES_LEVEL_ABORT }; private: Index: level.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.cpp,v retrieving revision 1.99 retrieving revision 1.100 diff -u -d -r1.99 -r1.100 --- level.cpp 20 Jul 2004 18:04:47 -0000 1.99 +++ level.cpp 14 Sep 2004 22:26:22 -0000 1.100 @@ -156,4 +156,3 @@ return i->second; } - Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.115 retrieving revision 1.116 diff -u -d -r1.115 -r1.116 --- worldmap.cpp 8 Sep 2004 17:32:31 -0000 1.115 +++ worldmap.cpp 14 Sep 2004 22:26:23 -0000 1.116 @@ -28,6 +28,7 @@ #include "video/screen.h" #include "video/drawing_context.h" #include "utils/lispreader.h" +#include "utils/lispwriter.h" #include "special/frame_rate.h" #include "gameloop.h" #include "app/setup.h" @@ -512,7 +513,7 @@ reader.read_int("x", special_tile.x); reader.read_int("y", special_tile.y); - reader.read_string("level", special_tile.level_name, true); + reader.read_string("level", special_tile.level_name, false); special_tile.vertical_flip = false; reader.read_bool("vertical-flip", special_tile.vertical_flip); @@ -623,6 +624,18 @@ delete reader; } +void WorldMap::calculate_total_stats() +{ + total_stats.reset(); + for(SpecialTiles::iterator i = special_tiles.begin(); i != special_tiles.end(); ++i) + { + if (!i->level_name.empty() && i->solved) + { + total_stats += i->statistics; + } + } +} + void WorldMap::on_escape_press() { @@ -831,6 +844,10 @@ bool old_level_state = special_tile->solved; special_tile->solved = true; + // deal with statistics + special_tile->statistics.merge(global_stats); + calculate_total_stats(); + if (session.get_current_sector()->player->got_power != session.get_current_sector()->player->NONE_POWER) player_status.bonus = PlayerStatus::FLOWER_BONUS; @@ -870,7 +887,6 @@ level_finished = false; /* In case the player's abort the special_tile, keep it using the old status. But the minimum lives and no bonus. */ - player_status.score = old_player_status.score; player_status.distros = old_player_status.distros; player_status.lives = std::min(old_player_status.lives, player_status.lives); player_status.bonus = player_status.NO_BONUS; @@ -880,9 +896,9 @@ { level_finished = false; /* draw an end screen */ - /* in the future, this should make a dialog a la SuperMario, asking + /* TODO: in the future, this should make a dialog a la SuperMario, asking if the player wants to restart the world map with no score and from - special_tile 1 */ + level 1 */ char str[80]; DrawingContext context; @@ -892,7 +908,7 @@ context.draw_text_center(blue_text, _("GAMEOVER"), Vector(0, 200), LAYER_FOREGROUND1); - sprintf(str, _("SCORE: %d"), player_status.score); + sprintf(str, _("SCORE: %d"), total_stats.get_points(SCORE_STAT)); context.draw_text_center(gold_text, str, Vector(0, 230), LAYER_FOREGROUND1); @@ -1047,7 +1063,7 @@ WorldMap::draw_status(DrawingContext& context) { char str[80]; - sprintf(str, " %d", player_status.score); + sprintf(str, " %d", total_stats.get_points(SCORE_STAT)); context.draw_text(white_text, _("SCORE"), Vector(0, 0), LAYER_FOREGROUND1); context.draw_text(gold_text, str, Vector(96, 0), LAYER_FOREGROUND1); @@ -1174,38 +1190,60 @@ return; std::cout << "savegame: " << filename << std::endl; - std::ofstream out(filename.c_str()); - int nb_solved_levels = 0; + std::ofstream file(filename.c_str(), std::ios::out); + LispWriter* writer = new LispWriter(file); + + int nb_solved_levels = 0, total_levels = 0; for(SpecialTiles::iterator i = special_tiles.begin(); i != special_tiles.end(); ++i) { + if(!i->level_name.empty()) + ++total_levels; if (i->solved) ++nb_solved_levels; } + char nb_solved_levels_str[80], total_levels_str[80]; + sprintf(nb_solved_levels_str, "%d", nb_solved_levels); + sprintf(total_levels_str, "%d", total_levels); + + writer->write_comment("Worldmap save file"); + + writer->start_list("supertux-savegame"); + + writer->write_int("version", 1); + writer->write_string("title", std::string(name + " - " + nb_solved_levels_str + "/" + total_levels_str)); + writer->write_string("map", map_filename); + writer->write_int("lives", player_status.lives); + writer->write_int("distros", player_status.lives); + + writer->start_list("tux"); + + writer->write_float("x", tux->get_tile_pos().x); + writer->write_float("y", tux->get_tile_pos().y); + writer->write_string("back", direction_to_string(tux->back_direction)); + writer->write_string("bonus", bonus_to_string(player_status.bonus)); + + writer->end_list("tux"); + + writer->start_list("levels"); - out << "(supertux-savegame\n" - << " (version 1)\n" - << " (title \"" << name << " - " << nb_solved_levels << "/" << special_tiles.size() << "\")\n" - << " (map \"" << map_filename << "\")\n" - << " (lives " << player_status.lives << ")\n" - << " (score " << player_status.score << ")\n" - << " (distros " << player_status.distros << ")\n" - << " (tux (x " << tux->get_tile_pos().x << ") (y " << tux->get_tile_pos().y << ")\n" - << " (back \"" << direction_to_string(tux->back_direction) << "\")\n" - << " (bonus \"" << bonus_to_string(player_status.bonus) << "\"))\n" - << " (levels\n"; - for(SpecialTiles::iterator i = special_tiles.begin(); i != special_tiles.end(); ++i) { if (i->solved && !i->level_name.empty()) { - out << " (level (name \"" << i->level_name << "\")\n" - << " (solved #t))\n"; + writer->start_list("level"); + + writer->write_string("name", i->level_name); + writer->write_bool("solved", true); + i->statistics.write(*writer); + + writer->end_list("level"); } } - out << " )\n" - << " )\n\n;; EOF ;;" << std::endl; + writer->end_list("levels"); + + writer->end_list("supertux-savegame"); } void @@ -1245,7 +1283,6 @@ load_map(); reader.read_int("lives", player_status.lives); - reader.read_int("score", player_status.score); reader.read_int("distros", player_status.distros); if (player_status.lives < 0) @@ -1283,13 +1320,17 @@ bool solved = false; LispReader level_reader(data); - level_reader.read_string("name", name, true); + level_reader.read_string("name", name); level_reader.read_bool("solved", solved); for(SpecialTiles::iterator i = special_tiles.begin(); i != special_tiles.end(); ++i) { if (name == i->level_name) + { i->solved = solved; + i->statistics.parse(level_reader); + break; + } } } @@ -1298,6 +1339,8 @@ } lisp_free(savegame); + + calculate_total_stats(); } void Index: scene.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/scene.h,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- scene.h 20 Jul 2004 18:04:48 -0000 1.33 +++ scene.h 14 Sep 2004 22:26:23 -0000 1.34 @@ -28,7 +28,6 @@ // Player stats struct PlayerStatus { - int score; int distros; int lives; enum BonusType { NO_BONUS, GROWUP_BONUS, FLOWER_BONUS }; Index: worldmap.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.h,v retrieving revision 1.45 retrieving revision 1.46 diff -u -d -r1.45 -r1.46 --- worldmap.h 26 Aug 2004 23:05:03 -0000 1.45 +++ worldmap.h 14 Sep 2004 22:26:23 -0000 1.46 @@ -26,6 +26,7 @@ #include "math/vector.h" #include "audio/musicref.h" #include "video/screen.h" +#include "statistics.h" extern Menu* worldmap_menu; @@ -159,6 +160,9 @@ std::string title; bool solved; + /** Statistics for level tiles */ + Statistics statistics; + /** Optional flags: */ /** Check if this level should be vertically flipped */ @@ -220,6 +224,12 @@ void get_level_title(SpecialTile& special_tile); void draw_status(DrawingContext& context); + + // to avoid calculating total stats all the time. This way only + // when need, it is calculated. + Statistics total_stats; + void calculate_total_stats(); + public: WorldMap(); ~WorldMap(); Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.174 retrieving revision 1.175 diff -u -d -r1.174 -r1.175 --- gameloop.cpp 14 Sep 2004 10:40:28 -0000 1.174 +++ gameloop.cpp 14 Sep 2004 22:26:08 -0000 1.175 @@ -61,6 +61,7 @@ #include "intro.h" #include "misc.h" #include "camera.h" +#include "statistics.h" GameSession* GameSession::current_ = 0; @@ -150,6 +151,8 @@ levelintro(); } + global_stats.reset(); + time_left.init(true); start_timers(); currentsector->play_music(LEVEL_MUSIC); @@ -785,7 +788,7 @@ { char str[60]; - snprintf(str, 60, " %d", player_status.score); + snprintf(str, 60, " %d", global_stats.get_points(SCORE_STAT)); context.draw_text(white_text, _("SCORE"), Vector(0, 0), LAYER_FOREGROUND1); context.draw_text(gold_text, str, Vector(96, 0), LAYER_FOREGROUND1); @@ -855,7 +858,7 @@ context.draw_text_center(blue_text, _("Result:"), Vector(0, 200), LAYER_FOREGROUND1); - sprintf(str, _("SCORE: %d"), player_status.score); + sprintf(str, _("SCORE: %d"), global_stats.get_points(SCORE_STAT)); context.draw_text_center(gold_text, str, Vector(0, 224), LAYER_FOREGROUND1); sprintf(str, _("COINS: %d"), player_status.distros); |
From: Marek M. <wa...@us...> - 2004-09-14 20:50:16
|
Update of /cvsroot/super-tux/supertux/data In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18011/data Added Files: extro-bonus.txt Log Message: added extro-bonus.txt to HEAD added Torfi's last name to level descriptions --- NEW FILE: extro-bonus.txt --- -Congratulations! You have successfully finished Bonus Island I featuring levels contributed by Jason W. Thompson Torfi Gunnarsson Abednego Matr1x If you didn't clear all levels yet, find your way back home and take another path. There is still more challenge waiting for you! And there is a secret level to be found as well... A big "Thank you" goes out to everyone who contributed to this release. We hope you enjoyed it! |
From: Marek M. <wa...@us...> - 2004-09-14 20:50:16
|
Update of /cvsroot/super-tux/supertux/data/levels/bonus1 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18011/data/levels/bonus1 Modified Files: torfi-level1.stl torfi-level2.stl torfi-level3.stl Log Message: added extro-bonus.txt to HEAD added Torfi's last name to level descriptions Index: torfi-level3.stl =================================================================== RCS file: /cvsroot/super-tux/supertux/data/levels/bonus1/torfi-level3.stl,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- torfi-level3.stl 26 Aug 2004 22:59:22 -0000 1.3 +++ torfi-level3.stl 14 Sep 2004 20:50:02 -0000 1.4 @@ -1,7 +1,7 @@ ;; Generated by Flexlay Editor (supertux-level (version 1) - (author "Torfi") + (author "Torfi Gunnarsson") (name "Still too easy") (width 200) (height 15) Index: torfi-level1.stl =================================================================== RCS file: /cvsroot/super-tux/supertux/data/levels/bonus1/torfi-level1.stl,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- torfi-level1.stl 26 Aug 2004 22:59:22 -0000 1.5 +++ torfi-level1.stl 14 Sep 2004 20:50:02 -0000 1.6 @@ -2,7 +2,7 @@ (supertux-level (version 1) (name "A good start") - (author "Torfi") + (author "Torfi Gunnarsson") (music "Mortimers_chipdisko.mod") (background "arctis.jpg") (particle_system "") Index: torfi-level2.stl =================================================================== RCS file: /cvsroot/super-tux/supertux/data/levels/bonus1/torfi-level2.stl,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- torfi-level2.stl 26 Aug 2004 22:59:22 -0000 1.4 +++ torfi-level2.stl 14 Sep 2004 20:50:02 -0000 1.5 @@ -1,7 +1,7 @@ ;; Generated by Flexlay Editor (supertux-level (version 1) - (author "Torfi") + (author "Torfi Gunnarsson") (name "Too easy") (width 240) (height 15) |
From: Ricardo C. <rm...@us...> - 2004-09-14 10:40:45
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26382/src Modified Files: gameloop.cpp Log Message: When typying 'lifeup' pause is triggered (cause of the last 'p'). Made a work around to fix that. Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.173 retrieving revision 1.174 diff -u -d -r1.173 -r1.174 --- gameloop.cpp 14 Sep 2004 10:27:04 -0000 1.173 +++ gameloop.cpp 14 Sep 2004 10:40:28 -0000 1.174 @@ -407,6 +407,18 @@ { player_status.lives++; last_keys.clear(); + // "lifeup" activates pause cause of the 'p' + // so work around to ignore it + if(game_pause) + { + game_pause = false; + Ticks::pause_stop(); + } + else + { + game_pause = true; + Ticks::pause_start(); + } } if(compare_last(last_keys, "lifedown")) { |
From: Ricardo C. <rm...@us...> - 2004-09-14 10:39:51
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26120/src Modified Files: badguy.cpp Log Message: Mr. Ice Block can now break power up boxes as well as crafts. Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy.cpp,v retrieving revision 1.121 retrieving revision 1.122 diff -u -d -r1.121 -r1.122 --- badguy.cpp 10 Sep 2004 08:54:29 -0000 1.121 +++ badguy.cpp 14 Sep 2004 10:39:32 -0000 1.122 @@ -404,20 +404,27 @@ BadGuy::check_horizontal_bump(bool checkcliff) { float halfheight = base.height / 2; - if (dir == LEFT && issolid( base.x, (int) base.y + halfheight)) + if (dir == LEFT && issolid( base.x, base.y + halfheight)) { if (kind == BAD_MRICEBLOCK && mode == KICK) + { Sector::current()->trybreakbrick(Vector(base.x, base.y + halfheight), false); + Sector::current()->tryemptybox(Vector(base.x, base.y + halfheight), dir); + } dir = RIGHT; physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y()); return; } - if (dir == RIGHT && issolid( base.x + base.width, (int)base.y + halfheight)) + if (dir == RIGHT && issolid( base.x + base.width, base.y + halfheight)) { if (kind == BAD_MRICEBLOCK && mode == KICK) + { Sector::current()->trybreakbrick( - Vector(base.x + base.width, (int) base.y + halfheight), false); + Vector(base.x + base.width, base.y + halfheight), false); + Sector::current()->tryemptybox( + Vector(base.x + base.width, base.y + halfheight), dir); + } dir = LEFT; physic.set_velocity(-physic.get_velocity_x(), physic.get_velocity_y()); |
From: Ricardo C. <rm...@us...> - 2004-09-14 10:27:19
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23438/src Modified Files: gameloop.cpp gameobjs.cpp gameobjs.h resources.cpp resources.h sector.cpp sector.h Log Message: Made code using fireworks sound effect. Also improved Particles: it now has acceleration and knows the difference of X and Y. Index: resources.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/resources.h,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- resources.h 26 Aug 2004 23:05:03 -0000 1.15 +++ resources.h 14 Sep 2004 10:27:05 -0000 1.16 @@ -52,6 +52,7 @@ SND_KICK, SND_EXPLODE, SND_WARP, + SND_FIREWORKS, NUM_SOUNDS }; Index: sector.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sector.h,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- sector.h 13 Sep 2004 22:48:14 -0000 1.12 +++ sector.h 14 Sep 2004 10:27:05 -0000 1.13 @@ -107,7 +107,7 @@ void add_upgrade(const Vector& pos, Direction dir, UpgradeKind kind); bool add_bullet(const Vector& pos, float xm, Direction dir); bool add_smoke_cloud(const Vector& pos); - bool add_particles(const Vector& epicenter, int number, Color color, int size, float velocity, int life_time); + bool add_particles(const Vector& epicenter, const Vector& velocity, const Vector& acceleration, int number, Color color, int size, int life_time); /** Try to grab the coin at the given coordinates */ void trygrabdistro(const Vector& pos, int bounciness); Index: sector.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sector.cpp,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- sector.cpp 13 Sep 2004 22:48:14 -0000 1.23 +++ sector.cpp 14 Sep 2004 10:27:05 -0000 1.24 @@ -737,9 +737,9 @@ } bool -Sector::add_particles(const Vector& epicenter, int number, Color color, int size, float velocity, int life_time) +Sector::add_particles(const Vector& epicenter, const Vector& velocity, const Vector& acceleration, int number, Color color, int size, int life_time) { - add_object(new Particles(epicenter, number, color, size, velocity, life_time)); + add_object(new Particles(epicenter, velocity, acceleration, number, color, size, life_time)); return true; } Index: gameobjs.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.cpp,v retrieving revision 1.48 retrieving revision 1.49 diff -u -d -r1.48 -r1.49 --- gameobjs.cpp 13 Sep 2004 22:48:14 -0000 1.48 +++ gameobjs.cpp 14 Sep 2004 10:27:05 -0000 1.49 @@ -438,8 +438,8 @@ img_smoke_cloud->draw(context, position, LAYER_OBJECTS+1); } -Particles::Particles(const Vector& epicenter, int number, Color color_, int size_, float velocity_, int life_time) - : color(color_), size(size_), velocity(velocity_) +Particles::Particles(const Vector& epicenter, const Vector& velocity, const Vector& acceleration, int number, Color color_, int size_, int life_time) + : color(color_), size(size_), vel(velocity), accel(acceleration) { timer.start(life_time); @@ -464,11 +464,14 @@ void Particles::action(float elapsed_time) { + vel.x += accel.x * elapsed_time; + vel.y += accel.y * elapsed_time; + // update particles for(int p = 0; p < particles.size(); p++) { - particles[p]->pos.x += sin(particles[p]->angle) * velocity * elapsed_time; - particles[p]->pos.y += cos(particles[p]->angle) * velocity * elapsed_time; + particles[p]->pos.x += sin(particles[p]->angle) * vel.x * elapsed_time; + particles[p]->pos.y += cos(particles[p]->angle) * vel.y * elapsed_time; } if(!timer.check()) Index: gameobjs.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.h,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- gameobjs.h 13 Sep 2004 22:48:14 -0000 1.34 +++ gameobjs.h 14 Sep 2004 10:27:05 -0000 1.35 @@ -179,7 +179,7 @@ class Particles : public GameObject { public: - Particles(const Vector& epicenter, int number, Color color, int size, float velocity, int life_time); + Particles(const Vector& epicenter, const Vector& velocity, const Vector& acceleration, int number, Color color, int size, int life_time); ~Particles(); virtual void action(float elapsed_time); @@ -188,7 +188,7 @@ private: Color color; float size; - float velocity; + Vector vel, accel; Timer timer; struct Particle { Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.172 retrieving revision 1.173 diff -u -d -r1.172 -r1.173 --- gameloop.cpp 13 Sep 2004 22:48:50 -0000 1.172 +++ gameloop.cpp 14 Sep 2004 10:27:04 -0000 1.173 @@ -515,7 +515,7 @@ else if(!end_sequence && endtile && endtile->data == 0) { end_sequence = ENDSEQUENCE_RUNNING; - random_timer.start(200); // start 1st fire work + random_timer.start(200); // start 1st firework last_x_pos = -1; SoundManager::get()->play_music(level_end_song, 0); endsequence_timer.start(7000); // 5 seconds until we finish the map @@ -556,18 +556,20 @@ newsector = newspawnpoint = ""; } - // on end sequence make a few fire works + // on end sequence make a few fireworks if(end_sequence == ENDSEQUENCE_RUNNING && !random_timer.check()) { Vector epicenter = currentsector->camera->get_translation(); epicenter.x += screen->w * ((float)rand() / RAND_MAX); epicenter.y += (screen->h/2) * ((float)rand() / RAND_MAX); - int red = rand() % 255; // calculate fire work color + int red = rand() % 255; // calculate firework color int green = rand() % red; - currentsector->add_particles(epicenter, 45, Color(red,green,0), 3, 1.4, 1300); + currentsector->add_particles(epicenter, Vector(1.4,1.4), Vector(0,0), + 45, Color(red,green,0), 3, 1300); - random_timer.start(rand() % 400 + 600); // next fire work + SoundManager::get()->play_sound(IDToSound(SND_FIREWORKS)); + random_timer.start(rand() % 400 + 600); // next firework } } Index: resources.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/resources.cpp,v retrieving revision 1.52 retrieving revision 1.53 diff -u -d -r1.52 -r1.53 --- resources.cpp 8 Sep 2004 11:23:29 -0000 1.52 +++ resources.cpp 14 Sep 2004 10:27:05 -0000 1.53 @@ -75,7 +75,8 @@ "/sounds/stomp.wav", "/sounds/kick.wav", "/sounds/explosion.wav", - "/sounds/warp.wav" + "/sounds/warp.wav", + "/sounds/fireworks.wav" }; |
From: Ricardo C. <rm...@us...> - 2004-09-14 10:25:55
|
Update of /cvsroot/super-tux/supertux/data/sounds In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23224/data/sounds Added Files: fireworks.wav Log Message: Added a fireworks sound effect. It ain't that good, but it's better to have something for someone to replace than nothing. --- NEW FILE: fireworks.wav --- (This appears to be a binary file; contents omitted.) |
From: Ricardo C. <rm...@us...> - 2004-09-13 22:48:59
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10772/src Modified Files: gameloop.cpp gameloop.h Log Message: Added fire works at the end sequence. To do: add sound and tweak it a bit. Index: gameloop.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.h,v retrieving revision 1.58 retrieving revision 1.59 diff -u -d -r1.58 -r1.59 --- gameloop.h 11 Sep 2004 14:22:01 -0000 1.58 +++ gameloop.h 13 Sep 2004 22:48:50 -0000 1.59 @@ -117,6 +117,8 @@ // for cheating std::string last_keys; + // for fire works + Timer random_timer; void restart_level(); Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.171 retrieving revision 1.172 diff -u -d -r1.171 -r1.172 --- gameloop.cpp 13 Sep 2004 18:50:46 -0000 1.171 +++ gameloop.cpp 13 Sep 2004 22:48:50 -0000 1.172 @@ -87,8 +87,9 @@ game_pause = false; fps_fps = 0; - fps_timer.init(true); + fps_timer.init(true); frame_timer.init(true); + random_timer.init(true); frame_rate.set_fps(100); context = new DrawingContext(); @@ -108,6 +109,7 @@ fps_timer.init(true); frame_timer.init(true); + random_timer.init(true); last_keys.clear(); @@ -513,6 +515,7 @@ else if(!end_sequence && endtile && endtile->data == 0) { end_sequence = ENDSEQUENCE_RUNNING; + random_timer.start(200); // start 1st fire work last_x_pos = -1; SoundManager::get()->play_music(level_end_song, 0); endsequence_timer.start(7000); // 5 seconds until we finish the map @@ -552,6 +555,20 @@ currentsector->play_music(LEVEL_MUSIC); newsector = newspawnpoint = ""; } + + // on end sequence make a few fire works + if(end_sequence == ENDSEQUENCE_RUNNING && !random_timer.check()) + { + Vector epicenter = currentsector->camera->get_translation(); + epicenter.x += screen->w * ((float)rand() / RAND_MAX); + epicenter.y += (screen->h/2) * ((float)rand() / RAND_MAX); + + int red = rand() % 255; // calculate fire work color + int green = rand() % red; + currentsector->add_particles(epicenter, 45, Color(red,green,0), 3, 1.4, 1300); + + random_timer.start(rand() % 400 + 600); // next fire work + } } void |
From: Ricardo C. <rm...@us...> - 2004-09-13 22:48:30
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10685/src Modified Files: gameobjs.cpp gameobjs.h sector.cpp sector.h Log Message: Added simple particle system object. I called it Particles cause there is already a ParticleSystem class. Weather would be a better name for that class. This particle system is just a rip off of one that I did for a game of mine. I guess that with more customization it would be pretty good. Index: gameobjs.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.h,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- gameobjs.h 14 Aug 2004 11:33:53 -0000 1.33 +++ gameobjs.h 13 Sep 2004 22:48:14 -0000 1.34 @@ -176,6 +176,28 @@ Vector position; }; +class Particles : public GameObject +{ +public: + Particles(const Vector& epicenter, int number, Color color, int size, float velocity, int life_time); + ~Particles(); + + virtual void action(float elapsed_time); + virtual void draw(DrawingContext& context); + +private: + Color color; + float size; + float velocity; + Timer timer; + + struct Particle { + Vector pos; + float angle; + }; + std::vector <Particle*> particles; +}; + void load_object_gfx(); #endif Index: sector.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sector.h,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- sector.h 13 Sep 2004 18:50:46 -0000 1.11 +++ sector.h 13 Sep 2004 22:48:14 -0000 1.12 @@ -46,6 +46,7 @@ class Upgrade; class Bullet; class SmokeCloud; +class Particles; class BadGuy; class Tile; @@ -106,6 +107,7 @@ void add_upgrade(const Vector& pos, Direction dir, UpgradeKind kind); bool add_bullet(const Vector& pos, float xm, Direction dir); bool add_smoke_cloud(const Vector& pos); + bool add_particles(const Vector& epicenter, int number, Color color, int size, float velocity, int life_time); /** Try to grab the coin at the given coordinates */ void trygrabdistro(const Vector& pos, int bounciness); @@ -159,6 +161,7 @@ std::vector<Upgrade*> upgrades; std::vector<Bullet*> bullets; std::vector<SmokeCloud*> smoke_clouds; + std::vector<Particles*> particles; public: // ugly typedef std::vector<InteractiveObject*> InteractiveObjects; Index: sector.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sector.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- sector.cpp 13 Sep 2004 18:50:46 -0000 1.22 +++ sector.cpp 13 Sep 2004 22:48:14 -0000 1.23 @@ -466,7 +466,13 @@ std::remove(smoke_clouds.begin(), smoke_clouds.end(), smoke_cloud), smoke_clouds.end()); } - + Particles* particle = dynamic_cast<Particles*> (*i); + if(particle) { + particles.erase( + std::remove(particles.begin(), particles.end(), particle), + particles.end()); + } + delete *i; i = gameobjects.erase(i); } else { @@ -500,7 +506,9 @@ SmokeCloud* smoke_cloud = dynamic_cast<SmokeCloud*> (*i); if(smoke_cloud) smoke_clouds.push_back(smoke_cloud); - + Particles* particle = dynamic_cast<Particles*> (*i); + if(particle) + particles.push_back(particle); gameobjects.push_back(*i); } @@ -728,6 +736,13 @@ return true; } +bool +Sector::add_particles(const Vector& epicenter, int number, Color color, int size, float velocity, int life_time) +{ + add_object(new Particles(epicenter, number, color, size, velocity, life_time)); + return true; +} + /* Break a brick: */ bool Sector::trybreakbrick(const Vector& pos, bool small) Index: gameobjs.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.cpp,v retrieving revision 1.47 retrieving revision 1.48 diff -u -d -r1.47 -r1.48 --- gameobjs.cpp 14 Aug 2004 12:00:58 -0000 1.47 +++ gameobjs.cpp 13 Sep 2004 22:48:14 -0000 1.48 @@ -32,6 +32,7 @@ #include "resources.h" #include "sector.h" #include "tilemap.h" +#include "video/drawing_context.h" BouncyDistro::BouncyDistro(const Vector& pos) : position(pos) @@ -437,6 +438,53 @@ img_smoke_cloud->draw(context, position, LAYER_OBJECTS+1); } +Particles::Particles(const Vector& epicenter, int number, Color color_, int size_, float velocity_, int life_time) + : color(color_), size(size_), velocity(velocity_) +{ + timer.start(life_time); + + // create particles + for(int p = 0; p < number; p++) + { + Particle* particle = new Particle; + particle->pos = epicenter; + particle->angle = (rand() % 360) * (M_PI / 180); // in radius + + particles.push_back(particle); + } +} + +Particles::~Particles() +{ + // free particles + for(std::vector<Particle*>::iterator i = particles.begin(); i < particles.end(); i++) + delete (*i); +} + +void +Particles::action(float elapsed_time) +{ + // update particles + for(int p = 0; p < particles.size(); p++) + { + particles[p]->pos.x += sin(particles[p]->angle) * velocity * elapsed_time; + particles[p]->pos.y += cos(particles[p]->angle) * velocity * elapsed_time; + } + + if(!timer.check()) + remove_me(); +} + +void +Particles::draw(DrawingContext& context) +{ + // draw particles + for(int p = 0; p < particles.size(); p++) + { + context.draw_filled_rect(particles[p]->pos, Vector(size,size), color, LAYER_OBJECTS+10); + } +} + void load_object_gfx() { img_trampoline = sprite_manager->load("trampoline"); |
From: Ricardo C. <rm...@us...> - 2004-09-13 22:46:10
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10151/src Modified Files: player.cpp Log Message: Bug fix: on incencible mode, stars were being drawn even when player was in dying sequence (ie. when fall). Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.164 retrieving revision 1.165 diff -u -d -r1.164 -r1.165 --- player.cpp 11 Sep 2004 13:31:37 -0000 1.164 +++ player.cpp 13 Sep 2004 22:45:44 -0000 1.165 @@ -870,7 +870,8 @@ // Draw blinking star overlay if (invincible_timer.started() && - (invincible_timer.get_left() > TUX_INVINCIBLE_TIME_WARNING || global_frame_counter % 3)) + (invincible_timer.get_left() > TUX_INVINCIBLE_TIME_WARNING || global_frame_counter % 3) + && !dying) { if (size == SMALL || duck) smalltux_star->draw(context, pos, LAYER_OBJECTS + 2); |
From: Ricardo C. <rm...@us...> - 2004-09-13 18:52:09
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24891/src Removed Files: button.cpp button.h Log Message: Not used anymore. They were moved to lib/gui. Looks like Tobias forgot to remove these. --- button.h DELETED --- --- button.cpp DELETED --- |
From: Ricardo C. <rm...@us...> - 2004-09-13 18:50:55
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24674/src Modified Files: gameloop.cpp sector.cpp sector.h Log Message: Spawn points should now be working! Index: sector.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sector.h,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- sector.h 5 Aug 2004 10:10:19 -0000 1.10 +++ sector.h 13 Sep 2004 18:50:46 -0000 1.11 @@ -72,6 +72,8 @@ /// activates this sector (change music, intialize player class, ...) void activate(const std::string& spawnpoint = "main"); + /// get best spawn point + Vector get_best_spawn_point(Vector pos); void action(float elapsed_time); void update_game_objects(); Index: sector.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sector.cpp,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- sector.cpp 9 Sep 2004 10:11:56 -0000 1.21 +++ sector.cpp 13 Sep 2004 18:50:46 -0000 1.22 @@ -96,7 +96,7 @@ } else if(token == "background") { background = new Background(reader); add_object(background); - } else if(token == "playerspawn") { + } else if(token == "spawn-points") { SpawnPoint* sp = new SpawnPoint; reader.read_string("name", sp->name); reader.read_float("x", sp->pos.x); @@ -228,7 +228,27 @@ add_object(tilemap); } - // TODO read resetpoints + // read reset-points (now spawn-points) + { + lisp_object_t* cur = 0; + if(reader.read_lisp("reset-points", cur)) { + while(!lisp_nil_p(cur)) { + lisp_object_t* data = lisp_car(cur); + LispReader reader(lisp_cdr(data)); + + Vector sp_pos; + if(reader.read_float("x", sp_pos.x) && reader.read_float("y", sp_pos.y)) + { + SpawnPoint* sp = new SpawnPoint; + sp->name = "main"; + sp->pos = sp_pos; + spawnpoints.push_back(sp); + } + + cur = lisp_cdr(cur); + } + } + } // read objects { @@ -272,11 +292,11 @@ for(SpawnPoints::iterator i = spawnpoints.begin(); i != spawnpoints.end(); ++i) { SpawnPoint* spawn = *i; - writer.start_list("playerspawn"); + writer.start_list("spawn-points"); writer.write_string("name", spawn->name); writer.write_float("x", spawn->pos.x); writer.write_float("y", spawn->pos.y); - writer.end_list("playerspawn"); + writer.end_list("spawn-points"); } // write objects @@ -363,6 +383,22 @@ camera->reset(Vector(player->base.x, player->base.y)); } +Vector +Sector::get_best_spawn_point(Vector pos) +{ +Vector best_reset_point = Vector(-1,-1); + +for(SpawnPoints::iterator i = spawnpoints.begin(); i != spawnpoints.end(); + ++i) { + if((*i)->name != "main") + continue; + if((*i)->pos.x > best_reset_point.x && (*i)->pos.x < pos.x) + best_reset_point = (*i)->pos; + } + +return best_reset_point; +} + void Sector::action(float elapsed_time) { Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.170 retrieving revision 1.171 diff -u -d -r1.170 -r1.171 --- gameloop.cpp 13 Sep 2004 12:08:40 -0000 1.170 +++ gameloop.cpp 13 Sep 2004 18:50:46 -0000 1.171 @@ -60,6 +60,7 @@ #include "worldmap.h" #include "intro.h" #include "misc.h" +#include "camera.h" GameSession* GameSession::current_ = 0; @@ -110,13 +111,11 @@ last_keys.clear(); -#if 0 - float old_x_pos = -1; - if (world) + Vector tux_pos = Vector(-1,-1); + if (currentsector) { // Tux has lost a life, so we try to respawn him at the nearest reset point - old_x_pos = world->get_tux()->base.x; + tux_pos = currentsector->player->base; } -#endif delete level; currentsector = 0; @@ -125,31 +124,24 @@ level->load(levelname); if(flip_level) level->do_vertical_flip(); + currentsector = level->get_sector("main"); if(!currentsector) Termination::abort("Level has no main sector.", ""); currentsector->activate("main"); -#if 0 // TODO // Set Tux to the nearest reset point - if (old_x_pos != -1) + if(tux_pos.x != -1) { - ResetPoint best_reset_point = { -1, -1 }; - for(std::vector<ResetPoint>::iterator i = get_level()->reset_points.begin(); - i != get_level()->reset_points.end(); ++i) - { - if (i->x < old_x_pos && best_reset_point.x < i->x) - best_reset_point = *i; - } - - if (best_reset_point.x != -1) - { - world->get_tux()->base.x = best_reset_point.x; - world->get_tux()->base.y = best_reset_point.y; - } - } -#endif + tux_pos = currentsector->get_best_spawn_point(tux_pos); + currentsector->player->base.x = tux_pos.x; + currentsector->player->base.y = tux_pos.y; + // has to reset camera on swapping + currentsector->camera->reset(Vector(currentsector->player->base.x, + currentsector->player->base.y)); + } + if (st_gl_mode != ST_GL_DEMO_GAME) { if(st_gl_mode == ST_GL_PLAY || st_gl_mode == ST_GL_LOAD_LEVEL_FILE) @@ -377,6 +369,10 @@ } break; default: + break; + } + } + /* Check if chacrater is ASCII */ char ch[2]; if((event.key.keysym.unicode & 0xFF80) == 0) @@ -420,9 +416,7 @@ tux.invincible_timer.start(time_left.get_left()); last_keys.clear(); } - break; - } - } + break; case SDL_JOYAXISMOTION: |
From: Ricardo C. <rm...@us...> - 2004-09-13 12:08:57
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5192/src Modified Files: gameloop.cpp Log Message: Moved cheating code, so that it ain't run every cycle, but only when a new key is pressed. last_keys.clear() shouldn't be needed and would shrink code a lot, but might be better to leave it. Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.169 retrieving revision 1.170 diff -u -d -r1.169 -r1.170 --- gameloop.cpp 12 Sep 2004 16:11:49 -0000 1.169 +++ gameloop.cpp 13 Sep 2004 12:08:40 -0000 1.170 @@ -385,6 +385,41 @@ ch[1] = '\0'; } last_keys.append(ch); // add to cheat keys + + // Cheating words (the goal of this is really for debugging, + // but could be used for some cheating, nothing wrong with that) + if(compare_last(last_keys, "grow")) + { + tux.grow(false); + last_keys.clear(); + } + if(compare_last(last_keys, "fire")) + { + tux.grow(false); + tux.got_power = tux.FIRE_POWER; + last_keys.clear(); + } + if(compare_last(last_keys, "ice")) + { + tux.grow(false); + tux.got_power = tux.ICE_POWER; + last_keys.clear(); + } + if(compare_last(last_keys, "lifeup")) + { + player_status.lives++; + last_keys.clear(); + } + if(compare_last(last_keys, "lifedown")) + { + player_status.lives--; + last_keys.clear(); + } + if(compare_last(last_keys, "invincible")) + { // be invincle for the rest of the level + tux.invincible_timer.start(time_left.get_left()); + last_keys.clear(); + } break; } } @@ -462,46 +497,6 @@ } } /* while */ } - -// Cheating words (the goal of this is really for debugging, but could -// be used for some cheating) -// TODO: this could be implmented in a more elegant and faster way -if(!last_keys.empty()) - { - Player &tux = *currentsector->player; - if(compare_last(last_keys, "grow")) - { - tux.grow(false); - last_keys.clear(); - } - if(compare_last(last_keys, "fire")) - { - tux.grow(false); - tux.got_power = tux.FIRE_POWER; - last_keys.clear(); - } - if(compare_last(last_keys, "ice")) - { - tux.grow(false); - tux.got_power = tux.ICE_POWER; - last_keys.clear(); - } - if(compare_last(last_keys, "lifeup")) - { - player_status.lives++; - last_keys.clear(); - } - if(compare_last(last_keys, "lifedown")) - { - player_status.lives--; - last_keys.clear(); - } - if(compare_last(last_keys, "invincible")) - { // be invincle for the rest of the level - tux.invincible_timer.start(time_left.get_left()); - last_keys.clear(); - } - } } void |
From: Ricardo C. <rm...@us...> - 2004-09-12 16:11:58
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8144/src Modified Files: gameloop.cpp Log Message: I guess this way is faster. Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.168 retrieving revision 1.169 diff -u -d -r1.168 -r1.169 --- gameloop.cpp 11 Sep 2004 14:48:07 -0000 1.168 +++ gameloop.cpp 12 Sep 2004 16:11:49 -0000 1.169 @@ -63,6 +63,19 @@ GameSession* GameSession::current_ = 0; +bool compare_last(std::string& haystack, std::string needle) +{ +int haystack_size = haystack.size(); +int needle_size = needle.size(); + +if(haystack_size < needle_size) + return false; + +if(haystack.compare(haystack_size-needle_size, needle_size, needle) == 0) + return true; +return false; +} + GameSession::GameSession(const std::string& levelname_, int mode, bool flip_level_) : level(0), currentsector(0), st_gl_mode(mode), end_sequence(NO_ENDSEQUENCE), levelname(levelname_), flip_level(flip_level_) @@ -456,34 +469,34 @@ if(!last_keys.empty()) { Player &tux = *currentsector->player; - if(last_keys.find("grow") != std::string::npos) + if(compare_last(last_keys, "grow")) { tux.grow(false); last_keys.clear(); } - if(last_keys.find("fire") != std::string::npos) + if(compare_last(last_keys, "fire")) { tux.grow(false); tux.got_power = tux.FIRE_POWER; last_keys.clear(); } - if(last_keys.find("ice") != std::string::npos) + if(compare_last(last_keys, "ice")) { tux.grow(false); tux.got_power = tux.ICE_POWER; last_keys.clear(); } - if(last_keys.find("lifeup") != std::string::npos) + if(compare_last(last_keys, "lifeup")) { player_status.lives++; last_keys.clear(); } - if(last_keys.find("lifedown") != std::string::npos) + if(compare_last(last_keys, "lifedown")) { player_status.lives--; last_keys.clear(); } - if(last_keys.find("invincible") != std::string::npos) + if(compare_last(last_keys, "invincible")) { // be invincle for the rest of the level tux.invincible_timer.start(time_left.get_left()); last_keys.clear(); |
From: Ricardo C. <rm...@us...> - 2004-09-11 14:48:17
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23155/src Modified Files: gameloop.cpp Log Message: I guess the checking is unnecessary. Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.167 retrieving revision 1.168 diff -u -d -r1.167 -r1.168 --- gameloop.cpp 11 Sep 2004 14:22:00 -0000 1.167 +++ gameloop.cpp 11 Sep 2004 14:48:07 -0000 1.168 @@ -488,8 +488,6 @@ tux.invincible_timer.start(time_left.get_left()); last_keys.clear(); } - if(last_keys.size() > 15) - last_keys.clear(); } } |