super-tux-commit Mailing List for Super Tux (Page 30)
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: Benjamin P. J. <lit...@us...> - 2004-10-04 12:15:45
|
Update of /cvsroot/super-tux/supertux/data/images/shared/smalltux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6822/data/images/shared/smalltux Added Files: __smalltux.xcf Log Message: Added the source XCF of the small tux's body parts. --- NEW FILE: __smalltux.xcf --- (This appears to be a binary file; contents omitted.) |
From: Benjamin P. J. <lit...@us...> - 2004-10-04 12:02:04
|
Update of /cvsroot/super-tux/supertux/data/images/fonts In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4144/data/images/fonts Added Files: __font.xcf Log Message: Added the sources for the current hand-written Super Tux fonts. That might come in handy if someone wishes to extend the current charset and doesn't know how the original fonts have been done... --- NEW FILE: __font.xcf --- (This appears to be a binary file; contents omitted.) |
From: Marek M. <wa...@us...> - 2004-10-03 10:58:35
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16931/src Modified Files: player.cpp Log Message: -made flapping less powerful by reducing speed and height -updated testing parcours accordingly TODO: The sliding glitch (see test/level13) sometimes happens happens here, too, after climbing onto an edge by flapping. Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.178 retrieving revision 1.179 diff -u -d -r1.178 -r1.179 --- player.cpp 23 Sep 2004 19:40:31 -0000 1.178 +++ player.cpp 3 Oct 2004 10:58:04 -0000 1.179 @@ -581,11 +581,13 @@ can_flap = false; falling_from_flap = true; } + if (physic.get_velocity_x() > 0) {physic.set_velocity_x(WALK_SPEED);} + else if (physic.get_velocity_x() < 0) {physic.set_velocity_x(WALK_SPEED * (-1));} jumping = true; flapping = true; if (flapping_timer.get_gone() <= TUX_FLAPPING_TIME) { - physic.set_velocity_y((float)flapping_timer.get_gone()/450); + physic.set_velocity_y((float)flapping_timer.get_gone()/700); } } |
From: Matze B. <mat...@us...> - 2004-09-24 21:34:11
|
Update of /cvsroot/super-tux/supertux/lib/special In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4097/special Modified Files: game_object.h Log Message: removed outdated comment Index: game_object.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/game_object.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- game_object.h 21 Jul 2004 16:51:52 -0000 1.2 +++ game_object.h 24 Sep 2004 21:33:59 -0000 1.3 @@ -39,7 +39,7 @@ * Most GameObjects will also implement the DrawableObject interface so that * they can actually be drawn on screen. */ - class GameObject // TODO rename this once the game has been converted + class GameObject { public: GameObject(); |
From: Matze B. <mat...@us...> - 2004-09-24 21:19:35
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1477 Modified Files: level.cpp level.h Log Message: removed unused function whcih caused compile errors Index: level.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.cpp,v retrieving revision 1.103 retrieving revision 1.104 diff -u -d -r1.103 -r1.104 --- level.cpp 24 Sep 2004 15:10:10 -0000 1.103 +++ level.cpp 24 Sep 2004 21:19:25 -0000 1.104 @@ -158,18 +158,6 @@ return i->second; } -const std::string& -Level::get_sector_name(const Sector* sector) -{ - for(Sectors::iterator i = sectors.begin(); i != sectors.end(); ++i) - { - if(i->second == sector) - return i->first; - } - std::cerr << "Warning: Sector not found on level\n"; - return ""; -} - Sector* Level::get_next_sector(const Sector* sector) { Index: level.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.h,v retrieving revision 1.64 retrieving revision 1.65 diff -u -d -r1.64 -r1.65 --- level.h 24 Sep 2004 15:10:10 -0000 1.64 +++ level.h 24 Sep 2004 21:19:25 -0000 1.65 @@ -64,8 +64,6 @@ Sector* get_next_sector(const Sector* sector); Sector* get_previous_sector(const Sector* sector); - const std::string& get_sector_name(const Sector* sector); - int get_total_sectors(); int get_total_badguys(); |
From: Ricardo C. <rm...@us...> - 2004-09-24 18:13:36
|
Update of /cvsroot/super-tux/supertux/lib/video In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2023/lib/video Modified Files: drawing_context.cpp drawing_context.h Log Message: Added a function to draw text on center of screen for comodity. Index: drawing_context.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/drawing_context.cpp,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- drawing_context.cpp 24 Sep 2004 18:00:39 -0000 1.8 +++ drawing_context.cpp 24 Sep 2004 18:13:27 -0000 1.9 @@ -104,6 +104,14 @@ } void +DrawingContext::draw_center_text(Font* font, const std::string& text, + const Vector& position, int layer, Uint32 drawing_effect) +{ +draw_text(font, text, Vector(position.x + screen->w/2, position.y), + CENTER_ALLIGN, layer, drawing_effect); +} + +void DrawingContext::draw_gradient(Color top, Color bottom, int layer) { DrawingRequest request; Index: drawing_context.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/drawing_context.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- drawing_context.h 24 Sep 2004 18:00:46 -0000 1.9 +++ drawing_context.h 24 Sep 2004 18:13:27 -0000 1.10 @@ -69,6 +69,13 @@ void draw_text(Font* font, const std::string& text, const Vector& position, int allignment, int layer, Uint32 drawing_effect = NONE_EFFECT); + + /// Draws text on screen center (feed Vector.x with a 0). + /// This is the same as draw_text() with a screen->w/2 position and + /// allignment set to LEFT_ALLIGN + void draw_center_text(Font* font, const std::string& text, + const Vector& position, int layer, + Uint32 drawing_effect = NONE_EFFECT); /// Draws a color gradient onto the whole screen */ void draw_gradient(Color from, Color to, int layer); /// Fills a rectangle. |
From: Ricardo C. <rm...@us...> - 2004-09-24 18:01:56
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32247/src Modified Files: statistics.cpp gameobjs.cpp Log Message: Made changes to reflect change of way that alpha applied is handled. Index: gameobjs.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.cpp,v retrieving revision 1.53 retrieving revision 1.54 diff -u -d -r1.53 -r1.54 --- gameobjs.cpp 23 Sep 2004 17:47:49 -0000 1.53 +++ gameobjs.cpp 24 Sep 2004 18:01:42 -0000 1.54 @@ -155,7 +155,12 @@ else alpha = 255; - context.draw_text(gold_text, text, position, LEFT_ALLIGN, LAYER_OBJECTS, NONE_EFFECT, alpha); + context.push_transform(); + context.set_alpha(alpha); + + context.draw_text(gold_text, text, position, LEFT_ALLIGN, LAYER_OBJECTS+1); + + context.pop_transform(); } /* Trampoline */ Index: statistics.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/statistics.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- statistics.cpp 20 Sep 2004 19:04:02 -0000 1.11 +++ statistics.cpp 24 Sep 2004 18:01:42 -0000 1.12 @@ -108,14 +108,6 @@ 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]; context.draw_text(white_small_text, _("- Best Level Statistics -"), @@ -130,6 +122,17 @@ // draw other small info + 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; + + context.push_transform(); + context.set_alpha(alpha); + if(display_stat == COINS_COLLECTED_STAT) sprintf(str, _("Max coins collected:")); else if(display_stat == BADGUYS_KILLED_STAT) @@ -137,7 +140,7 @@ else// if(display_stat == TIME_NEEDED_STAT) sprintf(str, _("Min time needed:")); - context.draw_text(white_small_text, str, Vector(WMAP_INFO_LEFT_X, 508), LEFT_ALLIGN, LAYER_GUI, NONE_EFFECT, alpha); + context.draw_text(white_small_text, str, Vector(WMAP_INFO_LEFT_X, 508), LEFT_ALLIGN, LAYER_GUI); if(display_stat == COINS_COLLECTED_STAT) sprintf(str, "%d/%d", stats[COINS_COLLECTED_STAT][SPLAYER], @@ -149,7 +152,9 @@ sprintf(str, "%d/%d", stats[TIME_NEEDED_STAT][SPLAYER], stats[TIME_NEEDED_STAT][STOTAL]); - context.draw_text(white_small_text, str, Vector(WMAP_INFO_RIGHT_X, 508), RIGHT_ALLIGN, LAYER_GUI, NONE_EFFECT, alpha); + context.draw_text(white_small_text, str, Vector(WMAP_INFO_RIGHT_X, 508), RIGHT_ALLIGN, LAYER_GUI); + + context.pop_transform(); } void |
From: Ricardo C. <rm...@us...> - 2004-09-24 18:00:56
|
Update of /cvsroot/super-tux/supertux/lib/video In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31982/lib/video Modified Files: drawing_context.cpp drawing_context.h Log Message: Added an alpha parameter for transformation and got rid of ugly alpha draw_font() parameter. Index: drawing_context.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/drawing_context.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- drawing_context.cpp 24 Sep 2004 15:07:22 -0000 1.7 +++ drawing_context.cpp 24 Sep 2004 18:00:39 -0000 1.8 @@ -31,6 +31,7 @@ { transform.draw_effect = NONE_EFFECT; transform.zoom = 1; +transform.alpha = 255; } DrawingContext::~DrawingContext() @@ -52,6 +53,7 @@ request.drawing_effect = drawing_effect; request.drawing_effect = transform.draw_effect | drawing_effect; request.zoom = transform.zoom; + request.alpha = transform.alpha; drawingrequests.push_back(request); } @@ -68,6 +70,7 @@ request.layer = layer; request.pos = transform.apply(dest); request.drawing_effect = drawing_effect; + request.alpha = transform.alpha; SurfacePartRequest* surfacepartrequest = new SurfacePartRequest(); surfacepartrequest->size = size; @@ -81,7 +84,7 @@ void DrawingContext::draw_text(Font* font, const std::string& text, const Vector& position, int allignment, int layer, - Uint32 drawing_effect, int alpha) + Uint32 drawing_effect) { DrawingRequest request; @@ -89,12 +92,12 @@ request.layer = layer; request.pos = transform.apply(position); request.drawing_effect = drawing_effect; + request.alpha = transform.alpha; TextRequest* textrequest = new TextRequest; textrequest->font = font; textrequest->text = text; textrequest->allignment = allignment; - textrequest->alpha = alpha; request.request_data = textrequest; drawingrequests.push_back(request); @@ -144,7 +147,7 @@ surfacepartrequest->surface->impl->draw_part( surfacepartrequest->source.x, surfacepartrequest->source.y, request.pos.x, request.pos.y, - surfacepartrequest->size.x, surfacepartrequest->size.y, 255, + surfacepartrequest->size.x, surfacepartrequest->size.y, request.alpha, request.drawing_effect); delete surfacepartrequest; @@ -201,7 +204,7 @@ { TextRequest* textrequest = (TextRequest*) request.request_data; - textrequest->font->draw(textrequest->text, request.pos, textrequest->allignment, request.drawing_effect, textrequest->alpha); + textrequest->font->draw(textrequest->text, request.pos, textrequest->allignment, request.drawing_effect, request.alpha); delete textrequest; } @@ -295,9 +298,9 @@ if(i->zoom != 1.0) surface->impl->draw_stretched(i->pos.x * i->zoom, i->pos.y * i->zoom, (int)(surface->w * i->zoom), (int)(surface->h * i->zoom), - 255, i->drawing_effect); + i->alpha, i->drawing_effect); else - surface->impl->draw(i->pos.x, i->pos.y, 255, i->drawing_effect); + surface->impl->draw(i->pos.x, i->pos.y, i->alpha, i->drawing_effect); break; } case SURFACE_PART: @@ -350,3 +353,9 @@ { transform.zoom = zoom; } + +void +DrawingContext::set_alpha(int alpha) +{ + transform.alpha = alpha; +} Index: drawing_context.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/drawing_context.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- drawing_context.h 24 Sep 2004 15:07:22 -0000 1.8 +++ drawing_context.h 24 Sep 2004 18:00:46 -0000 1.9 @@ -68,7 +68,7 @@ /// Draws a text. void draw_text(Font* font, const std::string& text, const Vector& position, int allignment, int layer, - Uint32 drawing_effect = NONE_EFFECT, int alpha = 255); + Uint32 drawing_effect = NONE_EFFECT); /// Draws a color gradient onto the whole screen */ void draw_gradient(Color from, Color to, int layer); /// Fills a rectangle. @@ -93,6 +93,8 @@ void set_drawing_effect(int effect); /// apply that zoom in the next draws */ void set_zooming(float zoom); + /// apply that alpha in the next draws */ + void set_alpha(int alpha); private: class Transform @@ -107,6 +109,7 @@ Uint32 draw_effect; float zoom; + int alpha; }; /// the transform stack @@ -130,7 +133,6 @@ Font* font; std::string text; int allignment; - int alpha; }; struct GradientRequest @@ -150,6 +152,7 @@ int layer; Uint32 drawing_effect; float zoom; + int alpha; RequestType type; Vector pos; |
From: Ricardo C. <rm...@us...> - 2004-09-24 17:32:24
|
Update of /cvsroot/super-tux/supertux/data/images/leveleditor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25757/data/images/leveleditor Added Files: background.png foreground.png interactive.png next-level.png next-sector.png previous-level.png previous-sector.png rubber.png save-level.png setup-level.png test-level.png Removed Files: select.png Log Message: Ooops, forgot to upload level editor images! --- NEW FILE: test-level.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: foreground.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: save-level.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: previous-sector.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: previous-level.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: next-sector.png --- (This appears to be a binary file; contents omitted.) --- select.png DELETED --- --- NEW FILE: next-level.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: rubber.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: interactive.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: setup-level.png --- (This appears to be a binary file; contents omitted.) --- NEW FILE: background.png --- (This appears to be a binary file; contents omitted.) |
From: Ricardo C. <rm...@us...> - 2004-09-24 15:10:22
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28188/src Modified Files: level_subset.h level_subset.cpp leveleditor.h level.h level.cpp title.cpp leveleditor.cpp Log Message: Uploading the level editor I was working on - It isn't still usable, but it was only getting dust and getting obsolete due to changes on API. Also, made the necessary changes on other stuff. Some bugs were introduced (others were already there :)). Index: level_subset.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level_subset.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- level_subset.cpp 6 Aug 2004 11:43:09 -0000 1.10 +++ level_subset.cpp 24 Sep 2004 15:10:10 -0000 1.11 @@ -76,7 +76,7 @@ lisp_free(root_obj); } -void LevelSubset::load(const char* subset) +void LevelSubset::load(const std::string& subset) { name = subset; @@ -170,6 +170,7 @@ { assert(num < levels.size()); +std::cerr << "levels[" << num << "]: " << levels[num] << std::endl; return directory + levels[num]; } Index: level.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.h,v retrieving revision 1.63 retrieving revision 1.64 diff -u -d -r1.63 -r1.64 --- level.h 17 Sep 2004 12:22:40 -0000 1.63 +++ level.h 24 Sep 2004 15:10:10 -0000 1.64 @@ -61,6 +61,13 @@ Sector* get_sector(const std::string& name); + Sector* get_next_sector(const Sector* sector); + Sector* get_previous_sector(const Sector* sector); + + const std::string& get_sector_name(const Sector* sector); + + int get_total_sectors(); + int get_total_badguys(); int get_total_coins(); Index: level_subset.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level_subset.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- level_subset.h 21 Jul 2004 16:51:53 -0000 1.4 +++ level_subset.h 24 Sep 2004 15:10:10 -0000 1.5 @@ -48,7 +48,7 @@ ~LevelSubset(); static void create(const std::string& subset_name); - void load(const char* subset); + void load(const std::string& filename); void save(); void add_level(const std::string& name); Index: title.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/title.cpp,v retrieving revision 1.119 retrieving revision 1.120 diff -u -d -r1.119 -r1.120 --- title.cpp 18 Sep 2004 12:13:09 -0000 1.119 +++ title.cpp 24 Sep 2004 15:10:10 -0000 1.120 @@ -114,7 +114,7 @@ for (std::set<std::string>::iterator it = level_subsets.begin(); it != level_subsets.end(); ++it) { LevelSubset* subset = new LevelSubset(); - subset->load((*it).c_str()); + subset->load(*it); contrib_menu->additem(MN_GOTO, subset->title, 0, contrib_subset_menu, i); contrib_subsets.push_back(subset); ++i; Index: leveleditor.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.cpp,v retrieving revision 1.150 retrieving revision 1.151 diff -u -d -r1.150 -r1.151 --- leveleditor.cpp 16 Sep 2004 15:04:17 -0000 1.150 +++ leveleditor.cpp 24 Sep 2004 15:10:10 -0000 1.151 @@ -1,1808 +1,967 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2003 Ricardo Cruz <ri...@ae...> -// Copyright (C) 2003 Tobias Glaesser <tob...@gm...> -// -// 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. -// [...2549 lines suppressed...] - - done_ = 0; - - while(done_ == 0) - { - done_ = wait_for_event(event); - SDL_Delay(50); - } + done = wait_for_event(event); + SDL_Delay(50); } + } - show_selections = true; - le_show_grid = tmp_show_grid; - le_selection_mode = temp_le_selection_mode; - le_help_shown = false; +show_grid = show_grid_t; +mouse_cursor->set_state(MC_NORMAL); } Index: level.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.cpp,v retrieving revision 1.102 retrieving revision 1.103 diff -u -d -r1.102 -r1.103 --- level.cpp 21 Sep 2004 22:03:32 -0000 1.102 +++ level.cpp 24 Sep 2004 15:10:10 -0000 1.103 @@ -158,6 +158,58 @@ return i->second; } +const std::string& +Level::get_sector_name(const Sector* sector) +{ + for(Sectors::iterator i = sectors.begin(); i != sectors.end(); ++i) + { + if(i->second == sector) + return i->first; + } + std::cerr << "Warning: Sector not found on level\n"; + return ""; +} + +Sector* +Level::get_next_sector(const Sector* sector) +{ + for(Sectors::iterator i = sectors.begin(); i != sectors.end(); ++i) + { + if(i->second == sector) + { + i++; + if(i == sectors.end()) + return NULL; + return i->second; + } + } + std::cerr << "Warning: Sector not found on level\n"; + return NULL; +} + +Sector* +Level::get_previous_sector(const Sector* sector) +{ + for(Sectors::iterator i = sectors.begin(); i != sectors.end(); ++i) + { + if(i->second == sector) + { + if(i == sectors.begin()) + return NULL; + i--; + return i->second; + } + } + std::cerr << "Warning: Sector not found on level\n"; + return NULL; +} + +int +Level::get_total_sectors() +{ +return sectors.size(); +} + int Level::get_total_badguys() { Index: leveleditor.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/leveleditor.h,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- leveleditor.h 27 Jul 2004 19:31:39 -0000 1.18 +++ leveleditor.h 24 Sep 2004 15:10:10 -0000 1.19 @@ -1,203 +1,149 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2003 Ricardo Cruz <ri...@ae...> -// Copyright (C) 2003 Tobias Glaesser <tob...@gm...> -// -// 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. +/*************************************************************************** + leveleditor.h - built'in level editor + ------------------- + begin : June, 23 2004 + copyright : (C) 2004 by Ricardo Cruz + email : ri...@ae... + ***************************************************************************/ -/* leveleditor.h - A built-in level editor for SuperTux */ +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ #ifndef SUPERTUX_LEVELEDITOR_H #define SUPERTUX_LEVELEDITOR_H +#include "SDL.h" + +#include <set> +#include <string> + #include "video/drawing_context.h" -#include "special/game_object.h" -#include "video/surface.h" +#include "special/timer.h" #include "level.h" #include "level_subset.h" -#include "special/moving_object.h" -#include "gui/button.h" -#include "gui/menu.h" using namespace SuperTux; -enum LevelEditorMainMenuIDs { - MNID_RETURNLEVELEDITOR, - MNID_SUBSETSETTINGS, - MNID_QUITLEVELEDITOR - }; +namespace SuperTux { +class ButtonGroup; +class Menu; +class Surface; +} + +class Sector; +class TileMap; + +enum { + MN_ID_RETURN, + MN_ID_LOAD_SUBSET, + MN_ID_QUIT, + + // settings menu ids: + MN_ID_NAME, + MN_ID_AUTHOR, + MN_ID_WIDTH, + MN_ID_HEIGHT, + MN_ID_APPLY_SETTINGS, -enum LevelEditorSubsetSettingsIDs { - MNID_SUBSETTITLE, - MNID_SUBSETDESCRIPTION, - MNID_SUBSETSAVECHANGES + // creating subset menu ids: + MN_ID_FILENAME_SUBSET, + MN_ID_TITLE_SUBSET, + MN_ID_DESCRIPTION_SUBSET, + MN_ID_CREATE_SUBSET }; - -enum LevelEditorSubsetNewIDs { - MNID_SUBSETNAME, - MNID_CREATESUBSET -}; -enum LevelEditorSettingsMenuIDs { - MNID_NAME, - MNID_AUTHOR, - MNID_SONG, - MNID_BGIMG, - MNID_PARTICLE, - MNID_LENGTH, - MNID_HEIGHT, - MNID_TIME, - MNID_GRAVITY, - MNID_BGSPEED, - MNID_TopRed, - MNID_TopGreen, - MNID_TopBlue, - MNID_BottomRed, - MNID_BottomGreen, - MNID_BottomBlue, - MNID_APPLY +enum { + BT_LEVEL_SAVE, + BT_LEVEL_TEST, + BT_LEVEL_SETUP, + + BT_NEXT_LEVEL, + BT_PREVIOUS_LEVEL, + BT_NEXT_SECTOR, + BT_PREVIOUS_SECTOR + }; + +enum { + OBJ_TRAMPOLINE = -100, + OBJ_FLYING_PLATFORM = -101, + OBJ_DOOR = -102 }; - class LevelEditor { public: LevelEditor(); ~LevelEditor(); - int run(char* filename = NULL); + void run(const std::string filename = ""); private: + void events(); + void action(); + void draw(DrawingContext& context); -// Functions -void newlevel(void); -void selectlevel(void); -void savelevel(); -void editlevel(void); -void testlevel(void); -void checkevents(void); -void unload_level(); + void load_level_subset(std::string filename); + void load_level(std::string filename); + void load_level(int nb); + void load_sector(std::string name); + void load_sector(Sector* sector); -/* own declerations */ -/* crutial ones (main loop) */ -void init_menus(); -int load_level_subset(const char *filename); -void drawlevel(DrawingContext& context); -void drawinterface(DrawingContext& context); -void change(float x, float y, int tm, unsigned int c); -void showhelp(); -void set_defaults(void); -void activate_bad_guys(void); -void goto_level(int levelnb); -void highlight_selection(); + void save_level(); + void test_level(); + void setup_level(); -void drawminimap(); + void show_help(); -void apply_level_settings_menu(); -void update_subset_settings_menu(); -void save_subset_settings_menu(); -void update_level_settings_menu(); -void change_object_properties(GameObject *pobj); + void change(int x, int y, int newtile, int layer); -// structs -struct TileOrObject -{ - TileOrObject() : tile(0), obj(NULL) { is_tile = true; }; + void load_buttons_gfx(); + void free_buttons_gfx(); - void Tile(unsigned int set_to) { tile = set_to; is_tile = true; } - void Object(GameObject* pobj) { obj = pobj; is_tile = false; } - //Returns true for a tile - bool IsTile() { return is_tile; }; - //Returns true for a GameObject - bool IsObject() { return !is_tile; }; + Level level; + std::string level_filename; + Sector* sector; // current sector + TileMap *solids, *foregrounds, *backgrounds; + std::string sector_name; - void Init() { tile = 0; obj = NULL; is_tile = true; }; + std::set<std::string> level_subsets; + LevelSubset level_subset; + int level_nb; - bool is_tile; //true for tile (false for object) - unsigned int tile; - GameObject* obj; -}; + Menu* main_menu; + Menu* subset_menu; + Menu* create_subset_menu; + Menu* settings_menu; -struct square -{ - int x1, y1, x2, y2; -}; + bool left_button, middle_button; + bool done; + bool show_grid; -/* selection modes */ -enum SelectionMode { CURSOR, SQUARE, NONE }; + Vector scroll; + float zoom; -// variables -/* leveleditor internals */ -std::set<std::string> level_subsets; -bool le_level_changed; /* if changes, ask for saving, when quiting*/ -bool show_minimap; -bool show_selections; -bool le_help_shown; -int pos_x, pos_y, cursor_x, cursor_y; -int le_levelnb; -Level* le_level; -LevelSubset* le_level_subset; -int le_show_grid; -int le_frame; -Surface* le_selection; -int done; -TileOrObject le_current; -bool le_mouse_pressed[2]; -bool le_mouse_clicked[2]; -Button* le_save_level_bt; -Button* le_exit_bt; -Button* le_test_level_bt; -Button* le_next_level_bt; -Button* le_previous_level_bt; -Button* le_move_right_bt; -Button* le_move_left_bt; -Button* le_move_up_bt; -Button* le_move_down_bt; -Button* le_rubber_bt; -Button* le_select_mode_one_bt; -Button* le_select_mode_two_bt; -Button* le_settings_bt; -Button* le_tilegroup_bt; -Button* le_objects_bt; -Button* le_object_select_bt; -Button* le_object_properties_bt; -ButtonPanel* le_tilemap_panel; -int active_tm; -Menu* leveleditor_menu; -Menu* subset_load_menu; -Menu* subset_new_menu; -Menu* subset_settings_menu; -Menu* level_settings_menu; -Menu* select_tilegroup_menu; -Menu* select_objects_menu; -Timer select_tilegroup_menu_effect; -Timer select_objects_menu_effect; -Timer display_level_info; -typedef std::map<std::string, ButtonPanel*> ButtonPanelMap; -ButtonPanelMap tilegroups_map; -ButtonPanelMap objects_map; -std::string cur_tilegroup; -std::string cur_objects; -MouseCursor* mouse_select_object; -MovingObject* selected_game_object; + SDL_Event event; + Timer frame_timer; + Timer level_name_timer; -square selection; -SelectionMode le_selection_mode; -SDL_Event event; + Surface *img_background_bt, *img_foreground_bt, *img_interactive_bt; + Surface *img_save_level_bt, *img_setup_level_bt, *img_test_level_bt; + Surface *img_rubber_bt; + Surface *img_previous_level_bt, *img_next_level_bt, *img_previous_sector_bt, *img_next_sector_bt; + + ButtonGroup *tiles_board, *tiles_layer, *level_options; + int cur_layer; + + std::vector <std::vector <int> > selection; + Vector selection_ini, selection_end; + + bool level_changed; }; -#endif /*SUPERTUX_LEVELEDITOR_H*/ +#endif |
From: Ricardo C. <rm...@us...> - 2004-09-24 15:08:15
|
Update of /cvsroot/super-tux/supertux/lib/gui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27920/lib/gui Modified Files: button.h button.cpp Log Message: Completely re-written from scratch of buttons code. Index: button.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/gui/button.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- button.h 26 Jul 2004 15:48:37 -0000 1.5 +++ button.h 24 Sep 2004 15:08:04 -0000 1.6 @@ -1,145 +1,92 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2004 Tobias Glaesser <tob...@gm...> -// -// 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. +/*************************************************************************** + button.h - graphical buttons + ------------------- + begin : June, 23 2004 + copyright : (C) 2004 by Ricardo Cruz + email : ri...@ae... + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ #ifndef SUPERTUX_BUTTON_H #define SUPERTUX_BUTTON_H #include <vector> +#include <string> -#include "../video/surface.h" -#include "../video/font.h" -#include "../special/timer.h" +#include "../math/vector.h" +#include "../video/drawing_context.h" namespace SuperTux { +class Surface; +class ButtonGroup; - /// Possible states of a button. - enum ButtonState { - BUTTON_NONE = -1, - BUTTON_CLICKED, - BUTTON_PRESSED, - BUTTON_HOVER, - BUTTON_WHEELUP, - BUTTON_WHEELDOWN, - BUTTON_DEACTIVE +enum { + BT_NONE, + BT_HOVER, + BT_SELECTED, + BT_SHOW_INFO }; - class ButtonPanel; +class Button +{ +public: + Button(Surface* image_, std::string info_, SDLKey binding_); + ~Button(); + + void draw(DrawingContext& context, bool selected); + int event(SDL_Event& event, int x_offset = 0, int y_offset = 0); - /// Button - /** Buttons can be placed on the screen and used like any other - simple button known from desktop applications. */ - class Button - { - friend class ButtonPanel; + static Font* info_font; - public: - /// Constructor - Button(Surface* button_image, const std::string& ninfo, - SDLKey nshortcut, int x, int y, int mw = -1, int mh = -1); - Button(const std::string& imagefilename, const std::string& ninfo, - SDLKey nshortcut, int x, int y, int mw = -1, int mh = -1); +private: + friend class ButtonGroup; - ~Button(); + Vector pos, size; - /// Apply SDL_Event on button. - void event(SDL_Event& event); - /// Draw button. - void draw(DrawingContext& context); - /// Get button state. - int get_state(); - /// Activate/Deactivate button. - void set_active(bool active) - { active ? state = BUTTON_NONE : state = BUTTON_DEACTIVE; }; - /// Add an icon - /** The last added icon is the last one, which gets drawn. */ - void add_icon(const std::string& imagefile, int mw, int mh); - /// Get position of the button on screen. - /** Returns a SDL_Rect. */ - SDL_Rect get_pos() - { return rect; } - /// Get tag of the button - /** Useable for button identification etc. */ - int get_tag() - { return tag; } - // void set_drawable(Drawable* newdrawable) - // { drawable = newdrawable; } + Surface* image; + SDLKey binding; - static Font* info_font; - - private: - static Timer popup_timer; - // Drawable* drawable; - std::vector<Surface*> icon; - std::string info; - SDLKey shortcut; - SDL_Rect rect; - bool show_info; - ButtonState state; - int tag; - }; + int id; + int state; + std::string info; +}; - /// Panel of buttons - /** A ButtonPanel manages buttons inside - its scope. It also dispatches events - and draws the buttons it contains. */ - class ButtonPanel - { - public: - /// Constructor. - /** Expects X,Y coordinates and the width and height values - of the ButtonPanel. */ - ButtonPanel(int x, int y, int w, int h); - /// Constructor. - /** SDL_Rect version of above. */ - ButtonPanel(const SDL_Rect& rect); +class ButtonGroup +{ +public: + ButtonGroup(Vector pos_, Vector size_, Vector button_box_); + ~ButtonGroup(); - ~ButtonPanel(); - /// Draw the panel and its buttons. - void draw(DrawingContext& context); - /// Dispatch button events. - Button* event(SDL_Event &event); - /// Add a button to the panel. - /** @param tag: Can be used to identify a button. */ - void additem(Button* pbutton, int tag); - /// Set the default size of contained buttons. - void set_button_size(int w, int h); - /// Manipulate a button. - Button* manipulate_button(int i); - /// Set if the last clicked/used item, should be drawn highlighted. - void highlight_last(bool b); - /// Set the last clicked/used button. - /** Set which button is internally the last clicked/used and - therefore drawn highlighted in case button highlighting - is enabled for the ButtonPanel. */ - void set_last_clicked(unsigned int last); + void draw(DrawingContext& context); + bool event(SDL_Event& event); - private: - int bw, bh; - bool hlast; - bool hidden; - SDL_Rect rect; - std::vector<Button*> item; - std::vector<Button*>::iterator last_clicked; - }; + void add_button(Button button, int id, bool select = false); + void add_pair_of_buttons(Button button1, int id1, Button button2, int id2); + + int selected_id(); + void set_unselected(); + bool is_hover(); -} // namespace SuperTux +private: + Vector pos, buttons_size, buttons_box; + typedef std::vector <Button> Buttons; + Buttons buttons; -#endif /*SUPERTUX_BUTTON_H*/ + int button_selected, row; + bool mouse_hover, mouse_left_button; + + int buttons_pair_nb; +}; + +} //namespace SuperTux + +#endif Index: button.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/gui/button.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- button.cpp 16 Sep 2004 15:04:15 -0000 1.6 +++ button.cpp 24 Sep 2004 15:08:04 -0000 1.7 @@ -1,343 +1,253 @@ -// $Id$ -// -// SuperTux -// Copyright (C) 2004 Tobias Glaesser <tob...@gm...> -// -// 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. +/*************************************************************************** + button.cpp - graphical buttons + ------------------- + begin : June, 23 2004 + copyright : (C) 2004 by Ricardo Cruz + email : ri...@ae... + ***************************************************************************/ -#include <cstring> -#include <cstdlib> +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include "SDL.h" +#include <iostream> -#include "../app/setup.h" -#include "../video/screen.h" -#include "../video/drawing_context.h" -#include "../app/globals.h" #include "../gui/button.h" +#include "../gui/mousecursor.h" +#include "../app/globals.h" +#include "../video/font.h" using namespace SuperTux; -Timer Button::popup_timer; Font* Button::info_font = 0; -Button::Button(Surface* button_image, const std::string& ninfo, - SDLKey nshortcut, int x, int y, int mw, int mh) -{ - popup_timer.init(false); - - if(button_image) - icon.push_back(button_image); - - info = ninfo; - - shortcut = nshortcut; - - rect.x = x; - rect.y = y; - rect.w = icon[0]->w; - rect.h = icon[0]->h; - tag = -1; - state = BUTTON_NONE; - show_info = false; -} +/* Buttons */ -Button::Button(const std::string& imagefilename, const std::string& ninfo, - SDLKey nshortcut, int x, int y, int mw, int mh) +Button::Button(Surface* image_, std::string info_, SDLKey binding_) + : binding(binding_) { - popup_timer.init(false); - - add_icon(imagefilename, mw, mh); - - info = ninfo; - - shortcut = nshortcut; - - rect.x = x; - rect.y = y; - rect.w = icon[0]->w; - rect.h = icon[0]->h; - tag = -1; - state = BUTTON_NONE; - show_info = false; +image = image_; +size = Vector(image->w, image->h); +id = 0; +info = info_; } -void Button::add_icon(const std::string& icon_file, int mw, int mh) +Button::~Button() { - char filename[1024]; - - if(!icon_file.empty()) - { - snprintf(filename, 1024, "%s/%s", datadir.c_str(), icon_file.c_str()); - if(!FileSystem::faccessible(filename)) - snprintf(filename, 1024, "%s/images/icons/default-icon.png", datadir.c_str()); - } - else - { - snprintf(filename, 1024, "%s/images/icons/default-icon.png", datadir.c_str()); - } - - if(mw != -1 || mh != -1) - { - icon.push_back(new Surface(filename,true)); - icon.back()->resize(mw,mh); - } - else - icon.push_back(new Surface(filename,true)); - } -void Button::draw(DrawingContext& context) +void Button::draw(DrawingContext &context, bool selected) { - if(state == BUTTON_HOVER) - if(!popup_timer.check()) - show_info = true; - - fillrect(rect.x,rect.y,rect.w,rect.h,75,75,75,200); - fillrect(rect.x+1,rect.y+1,rect.w-2,rect.h-2,175,175,175,200); - - for(std::vector<Surface*>::iterator it = icon.begin(); it != icon.end(); ++it) - context.draw_surface(*it, Vector(rect.x,rect.y), LAYER_GUI); - - /* if(drawable) - { - Camera viewport; - viewport.set_translation(Vector(rect.x, rect.y)); - drawable->draw(viewport, 0); - }*/ - - if(show_info) - { - char str[80]; - int i = -32; - - if(0 > rect.x - info_font->get_text_width(info)) - i = rect.w + (int)info_font->get_text_width(info); +if(selected) + context.draw_filled_rect(pos, size, Color (200,240,220), LAYER_GUI); +else + context.draw_filled_rect(pos, size, Color (200,200,220), LAYER_GUI); - if(!info.empty()) - context.draw_text(info_font, info, Vector(i + rect.x - info_font->get_text_width(info), rect.y), LEFT_ALLIGN, LAYER_GUI); - sprintf(str,"(%s)", SDL_GetKeyName(shortcut)); - context.draw_text(info_font, str, Vector(i + rect.x - info_font->get_text_width(str), rect.y + info_font->get_height()+2), LEFT_ALLIGN, LAYER_GUI); - } - if(state == BUTTON_PRESSED || state == BUTTON_DEACTIVE) - fillrect(rect.x,rect.y,rect.w,rect.h,75,75,75,200); - else if(state == BUTTON_HOVER) - fillrect(rect.x,rect.y,rect.w,rect.h,150,150,150,128); -} +Vector tanslation = -context.get_translation(); +if(state == BT_SHOW_INFO) + { + Vector offset; + if(pos.x + tanslation.x < 100 && pos.y + tanslation.y > screen->h - 20) + offset = Vector(size.x, - 10); + else if(pos.x + tanslation.x < 100) + offset = Vector(size.x, 0); + else + offset = Vector(-30, -size.y/2); + context.draw_text(info_font, info, pos + offset, LEFT_ALLIGN, LAYER_GUI+2); + if(binding != 0) + context.draw_text(info_font, "(" + std::string(SDL_GetKeyName(binding)) + + ")", pos + offset + Vector(0,12), + LEFT_ALLIGN, LAYER_GUI+2); + } -Button::~Button() -{ - for(std::vector<Surface*>::iterator it = icon.begin(); it != icon.end(); ++it) - delete (*it); - icon.clear(); - // FIXME TODO XXX: commenting this out fixes the leveleditor quit crash - // probably should be deleted somehow, though - //delete drawable; +context.draw_surface_part(image, Vector(0,0), size, pos, LAYER_GUI+1); } -void Button::event(SDL_Event &event) +int Button::event(SDL_Event &event, int x_offset, int y_offset) { - if(state == BUTTON_DEACTIVE) - return; - - SDLKey key = event.key.keysym.sym; - - if(event.type == SDL_MOUSEBUTTONDOWN || event.type == SDL_MOUSEBUTTONUP) - { - if(event.button.x < rect.x || event.button.x >= rect.x + rect.w || - event.button.y < rect.y || event.button.y >= rect.y + rect.h) - return; - +state = BT_NONE; +switch(event.type) + { + case SDL_MOUSEBUTTONDOWN: + if(event.button.x > pos.x + x_offset && event.button.x < pos.x + x_offset + size.x && + event.button.y > pos.y + y_offset && event.button.y < pos.y + y_offset + size.y) + { if(event.button.button == SDL_BUTTON_RIGHT) - { - show_info = true; - return; - } - else if(event.type == SDL_MOUSEBUTTONUP && event.button.button == 4) /* Mouse wheel up. */ - { - state = BUTTON_WHEELUP; - return; - } - else if(event.type == SDL_MOUSEBUTTONUP && event.button.button == 5) /* Mouse wheel down. */ - { - state = BUTTON_WHEELDOWN; - return; - } - + state = BT_SHOW_INFO; + } + break; + case SDL_MOUSEBUTTONUP: + if(event.button.x > pos.x + x_offset && event.button.x < pos.x + x_offset + size.x && + event.button.y > pos.y + y_offset && event.button.y < pos.y + y_offset + size.y) + { if(event.button.button == SDL_BUTTON_LEFT) - if(event.type == SDL_MOUSEBUTTONDOWN) - state = BUTTON_PRESSED; - else - state = BUTTON_CLICKED; - } - else if(event.type == SDL_MOUSEMOTION) - { - if(event.motion.x < rect.x || event.motion.x >= rect.x + rect.w || - event.motion.y < rect.y || event.motion.y >= rect.y + rect.h) - { - state = BUTTON_NONE; - } - else - { - state = BUTTON_HOVER; - popup_timer.start(1500); - } - - if(show_info) - { - show_info = false; - } - } - else if(event.type == SDL_KEYDOWN) - { - if(key == shortcut) - state = BUTTON_PRESSED; - } - else if(event.type == SDL_KEYUP) - { - if(state == BUTTON_PRESSED && key == shortcut) - state = BUTTON_CLICKED; - } + state = BT_SELECTED; + } + break; + case SDL_KEYDOWN: // key pressed + if(event.key.keysym.sym == binding) + state = BT_SELECTED; + break; + default: + break; + } +return state; } -int Button::get_state() -{ - int rstate; - switch(state) - { - case BUTTON_CLICKED: - case BUTTON_WHEELUP: - case BUTTON_WHEELDOWN: - rstate = state; - state = BUTTON_NONE; - return rstate; - default: - return state; - } -} +/* Group of buttons */ -ButtonPanel::ButtonPanel(const SDL_Rect& rect) +ButtonGroup::ButtonGroup(Vector pos_, Vector buttons_size_, Vector buttons_box_) + : pos(pos_), buttons_size(buttons_size_), buttons_box(buttons_box_) { - ButtonPanel(rect.x, rect.y, rect.w, rect.h); +buttons.clear(); +row = 0; +button_selected = -1; +mouse_hover = false; +mouse_left_button = false; +buttons_pair_nb = 0; } -ButtonPanel::ButtonPanel(int x, int y, int w, int h) +ButtonGroup::~ButtonGroup() { - bw = 32; - bh = 32; - rect.x = x; - rect.y = y; - rect.w = w; - rect.h = h; - hidden = false; - hlast = false; } -Button* ButtonPanel::event(SDL_Event& event) +void ButtonGroup::add_button(Button button, int id, bool select) { - if(!hidden) - { - Button* ret = NULL; - for(std::vector<Button*>::iterator it = item.begin(); it != item.end(); ++it) - { - (*it)->event(event); - if((*it)->state != BUTTON_NONE) - { - if(hlast && (*it)->state == BUTTON_CLICKED) - last_clicked = it; - ret = (*it); - } - } - return ret; - } - else - { - return NULL; - } +button.pos.x = ((buttons.size()-buttons_pair_nb) % (int)buttons_box.x) * buttons_size.x; +button.pos.y = ((int)((buttons.size()-buttons_pair_nb) / buttons_box.x)) * buttons_size.y; +button.size = buttons_size; +button.id = id; +if(select) + button_selected = id; + +buttons.push_back(button); } -ButtonPanel::~ButtonPanel() +void ButtonGroup::add_pair_of_buttons(Button button1, int id1, Button button2, int id2) { - for(std::vector<Button*>::iterator it = item.begin(); it != item.end(); ++it) - { - delete (*it); - } - item.clear(); +button1.pos.x = button2.pos.x = ((buttons.size()-buttons_pair_nb) % (int)buttons_box.x) * buttons_size.x; +button1.pos.y = button2.pos.y = ((int)((buttons.size()-buttons_pair_nb) / buttons_box.x)) * buttons_size.y; +button1.size.x = button2.size.x = buttons_size.x; +button1.size.y = button2.size.y = buttons_size.y / 2; +button2.pos.y += buttons_size.y / 2; +button1.id = id1; +button2.id = id2; + +buttons_pair_nb++; +buttons.push_back(button1); +buttons.push_back(button2); } -void ButtonPanel::draw(DrawingContext& context) +void ButtonGroup::draw(DrawingContext &context) { +context.draw_filled_rect(pos - Vector(12,4), + Vector(buttons_size.x*buttons_box.x + 16, buttons_size.y*buttons_box.y + 8), + Color (0,0,0, 128), LAYER_GUI-1); - if(hidden == false) - { - fillrect(rect.x,rect.y,rect.w,rect.h,100,100,100,200); - for(std::vector<Button*>::iterator it = item.begin(); it != item.end(); ++it) - { - (*it)->draw(context); - if(hlast && it == last_clicked) - { - fillrect((*it)->get_pos().x,(*it)->get_pos().y,(*it)->get_pos().w,(*it)->get_pos().h,100,100,100,128); - } - } - } +context.push_transform(); +context.set_translation(Vector(-pos.x, -pos.y + buttons_size.y*row)); +for(Buttons::iterator i = buttons.begin(); i != buttons.end(); ++i) + { + if(i->pos.y < row*buttons_size.y || + i->pos.y + i->size.y > (row + buttons_box.y) * buttons_size.y) + continue; + + i->draw(context, i->id == button_selected ? true : false); + } +context.pop_transform(); } -void ButtonPanel::additem(Button* pbutton, int tag) +bool ButtonGroup::event(SDL_Event &event) { - int max_cols, row, col; +bool caught_event = false; - item.push_back(pbutton); +switch(event.type) + { + case SDL_MOUSEMOTION: + mouse_hover = false; - /* A button_panel takes control of the buttons it contains and arranges them */ + if(mouse_left_button) + { + pos.x += event.motion.xrel; + pos.y += event.motion.yrel; + caught_event = true; + } + if(event.button.x > pos.x-12 && event.button.x < pos.x+16 + buttons_box.x*buttons_size.x && + event.button.y > pos.y-4 && event.button.y < pos.y+8 + buttons_box.y*buttons_size.y) + mouse_hover = true; + break; + case SDL_MOUSEBUTTONDOWN: + if(event.button.x < pos.x-12 || event.button.x > pos.x+16 + + buttons_box.x*buttons_size.x || event.button.y < pos.y-4 || + event.button.y > pos.y+8 + buttons_box.y*buttons_size.y) + break; - max_cols = rect.w / bw; + caught_event = true; - row = (item.size()-1) / max_cols; - col = (item.size()-1) % max_cols; + if(event.button.button == SDL_BUTTON_WHEELUP) + { + row--; + if(row < 0) + row = 0; + } + else if(event.button.button == SDL_BUTTON_WHEELDOWN) + { + row++; + if(row > (int)((buttons.size()-buttons_pair_nb)/buttons_box.x) - (int)buttons_box.y + + ((int)(buttons.size()-buttons_pair_nb)%(int)buttons_box.x != 0 ? 1 : 0)) + row = (int)((buttons.size()-buttons_pair_nb)/buttons_box.x) - (int)buttons_box.y + + ((int)(buttons.size()-buttons_pair_nb)%(int)buttons_box.x != 0 ? 1 : 0); + } + else if(event.button.button == SDL_BUTTON_LEFT) + mouse_left_button = true; + else + caught_event = false; + break; + case SDL_MOUSEBUTTONUP: + mouse_left_button = false; + break; + default: + break; + } - item[item.size()-1]->rect.x = rect.x + col * bw; - item[item.size()-1]->rect.y = rect.y + row * bh; - item[item.size()-1]->tag = tag; +if(caught_event) + return true; -} +for(Buttons::iterator i = buttons.begin(); i != buttons.end(); ++i) + { + if(i->pos.y < row*buttons_size.y || + i->pos.y + i->size.y > (row + buttons_box.y) * buttons_size.y) + continue; -void ButtonPanel::set_button_size(int w, int h) -{ - bw = w; - bh = h; + if(i->event(event, (int)pos.x, + (int)pos.y - row*(int)buttons_size.y) == BT_SELECTED) + { + button_selected = i->id; + caught_event = true; + break; + } + } + +return caught_event; } -Button* ButtonPanel::manipulate_button(int i) +int ButtonGroup::selected_id() { - if(int(item.size())-1 < i) - return item[item.size()-1]; - else - return item[i]; +return button_selected; } -void ButtonPanel::highlight_last(bool b) +void ButtonGroup::set_unselected() { - hlast = b; +button_selected = -1; } -void ButtonPanel::set_last_clicked(unsigned int last) +bool ButtonGroup::is_hover() { - if(hlast) - { - if(item.size() >= last) - { - last_clicked = item.begin() + last; - } - } +return mouse_hover; } |
From: Ricardo C. <rm...@us...> - 2004-09-24 15:07:32
|
Update of /cvsroot/super-tux/supertux/lib/video In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27770/lib/video Modified Files: drawing_context.cpp drawing_context.h Log Message: Tweaks. Index: drawing_context.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/drawing_context.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- drawing_context.cpp 16 Sep 2004 15:04:16 -0000 1.6 +++ drawing_context.cpp 24 Sep 2004 15:07:22 -0000 1.7 @@ -30,6 +30,7 @@ DrawingContext::DrawingContext() { transform.draw_effect = NONE_EFFECT; +transform.zoom = 1; } DrawingContext::~DrawingContext() @@ -50,6 +51,7 @@ request.pos = transform.apply(position); request.drawing_effect = drawing_effect; request.drawing_effect = transform.draw_effect | drawing_effect; + request.zoom = transform.zoom; drawingrequests.push_back(request); } @@ -289,7 +291,13 @@ case SURFACE: { const Surface* surface = (const Surface*) i->request_data; - surface->impl->draw(i->pos.x, i->pos.y, 255, i->drawing_effect); + + if(i->zoom != 1.0) + surface->impl->draw_stretched(i->pos.x * i->zoom, i->pos.y * i->zoom, + (int)(surface->w * i->zoom), (int)(surface->h * i->zoom), + 255, i->drawing_effect); + else + surface->impl->draw(i->pos.x, i->pos.y, 255, i->drawing_effect); break; } case SURFACE_PART: @@ -336,3 +344,9 @@ { transform.draw_effect = effect; } + +void +DrawingContext::set_zooming(float zoom) +{ + transform.zoom = zoom; +} Index: drawing_context.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/drawing_context.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- drawing_context.h 16 Sep 2004 15:04:16 -0000 1.7 +++ drawing_context.h 24 Sep 2004 15:07:22 -0000 1.8 @@ -79,19 +79,20 @@ void do_drawing(); const Vector& get_translation() const - { - return transform.translation; - } + { return transform.translation; } + Uint32 get_drawing_effect() const + { return transform.draw_effect; } + void set_translation(const Vector& newtranslation) - { - transform.translation = newtranslation; - } + { transform.translation = newtranslation; } void push_transform(); void pop_transform(); /// Apply that effect in the next draws (effects are listed on surface.h). void set_drawing_effect(int effect); + /// apply that zoom in the next draws */ + void set_zooming(float zoom); private: class Transform @@ -104,7 +105,8 @@ return v - translation; } - int draw_effect; + Uint32 draw_effect; + float zoom; }; /// the transform stack @@ -147,6 +149,7 @@ { int layer; Uint32 drawing_effect; + float zoom; RequestType type; Vector pos; |
From: Marek M. <wa...@us...> - 2004-09-23 19:40:58
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27468/src Modified Files: player.cpp Log Message: custom messages for combos, depending on how many badguys were killed FIXME: Messages are currently generated in method "bounce" - should be moved out of there, but I didn't know how, sorry :) Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.177 retrieving revision 1.178 diff -u -d -r1.177 -r1.178 --- player.cpp 23 Sep 2004 17:47:49 -0000 1.177 +++ player.cpp 23 Sep 2004 19:40:31 -0000 1.178 @@ -336,12 +336,12 @@ /* Reset score multiplier (for multi-hits): */ if (!invincible_timer.started()) { - if(player_status.score_multiplier > 2) + /*if(player_status.score_multiplier > 2) { // show a message char str[124]; sprintf(str, _("%d bad guys in a row!"), player_status.score_multiplier-1); Sector::current()->add_floating_text(base, str); - } + }*/ player_status.score_multiplier = 1; } } @@ -1169,7 +1169,19 @@ //Make sure we stopped flapping flapping = false; falling_from_flap = false; - + + if(player_status.score_multiplier > 1) + { // show a message + char str[124]; + if (player_status.score_multiplier <= 4) {sprintf(str, _("Combo x%d"), player_status.score_multiplier);} + else if (player_status.score_multiplier == 5) {sprintf(str, _("Good! x%d"), player_status.score_multiplier);} + else if (player_status.score_multiplier == 6) {sprintf(str, _("Great! x%d"), player_status.score_multiplier);} + else if (player_status.score_multiplier == 7) {sprintf(str, _("Awesome! x%d"), player_status.score_multiplier);} + else if (player_status.score_multiplier == 8) {sprintf(str, _("Incredible! x%d"), player_status.score_multiplier);} + else if (player_status.score_multiplier == 9) {sprintf(str, _("Godlike! ;-) x%d"), player_status.score_multiplier);} + else {sprintf(str, _("Unbelievable!! x%d"), player_status.score_multiplier);} + Sector::current()->add_floating_text(base, str); + } if (input.up) physic.set_velocity_y(5.2); else |
From: Ricardo C. <rm...@us...> - 2004-09-23 17:48:01
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2393/src Modified Files: sector.h sector.cpp gameobjs.h gameobjs.cpp player.cpp Log Message: Show a message when more than one bad guys is killed in a row. Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.176 retrieving revision 1.177 diff -u -d -r1.176 -r1.177 --- player.cpp 20 Sep 2004 19:30:30 -0000 1.176 +++ player.cpp 23 Sep 2004 17:47:49 -0000 1.177 @@ -22,6 +22,7 @@ #include <cassert> #include "app/globals.h" +#include "app/gettext.h" #include "player.h" #include "defines.h" #include "scene.h" @@ -334,7 +335,15 @@ physic.enable_gravity(false); /* Reset score multiplier (for multi-hits): */ if (!invincible_timer.started()) + { + if(player_status.score_multiplier > 2) + { // show a message + char str[124]; + sprintf(str, _("%d bad guys in a row!"), player_status.score_multiplier-1); + Sector::current()->add_floating_text(base, str); + } player_status.score_multiplier = 1; + } } if(jumped_in_solid) Index: gameobjs.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.cpp,v retrieving revision 1.52 retrieving revision 1.53 diff -u -d -r1.52 -r1.53 --- gameobjs.cpp 20 Sep 2004 19:17:29 -0000 1.52 +++ gameobjs.cpp 23 Sep 2004 17:47:49 -0000 1.53 @@ -114,7 +114,7 @@ draw_tile(context, shape.id, position + Vector(0, offset), LAYER_TILES+1); } -FloatingText::FloatingText(const Vector& pos, std::string& text_) +FloatingText::FloatingText(const Vector& pos, const std::string& text_) : position(pos), text(text_) { timer.start(1000); Index: sector.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sector.h,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- sector.h 17 Sep 2004 12:22:40 -0000 1.15 +++ sector.h 23 Sep 2004 17:47:46 -0000 1.16 @@ -113,6 +113,7 @@ bool add_bullet(const Vector& pos, float xm, Direction dir); bool add_smoke_cloud(const Vector& pos); bool add_particles(const Vector& epicenter, const Vector& velocity, const Vector& acceleration, int number, Color color, int size, int life_time); + void add_floating_text(const Vector& pos, const std::string& text); /** Try to grab the coin at the given coordinates */ void trygrabdistro(const Vector& pos, int bounciness); @@ -190,7 +191,7 @@ int distro_counter; bool counting_distros; - int currentmusic; + int currentmusic; }; #endif Index: gameobjs.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.h,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- gameobjs.h 20 Sep 2004 19:17:29 -0000 1.37 +++ gameobjs.h 23 Sep 2004 17:47:49 -0000 1.38 @@ -94,7 +94,7 @@ class FloatingText : public GameObject { public: - FloatingText(const Vector& pos, std::string& text_); + FloatingText(const Vector& pos, const std::string& text_); FloatingText(const Vector& pos, int s); // use this for score, for instance virtual void action(float elapsed_time); Index: sector.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sector.cpp,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- sector.cpp 21 Sep 2004 22:03:32 -0000 1.31 +++ sector.cpp 23 Sep 2004 17:47:49 -0000 1.32 @@ -756,6 +756,12 @@ return true; } +void +Sector::add_floating_text(const Vector& pos, const std::string& text) +{ + add_object(new FloatingText(pos, text)); +} + /* Break a brick: */ bool Sector::trybreakbrick(const Vector& pos, bool small) |
From: Ryan F. <sik...@us...> - 2004-09-22 17:04:31
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15187/src Modified Files: worldmap.cpp Log Message: - newgame player status bugfix Index: worldmap.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v retrieving revision 1.121 retrieving revision 1.122 diff -u -d -r1.121 -r1.122 --- worldmap.cpp 18 Sep 2004 12:13:09 -0000 1.121 +++ worldmap.cpp 22 Sep 2004 17:04:22 -0000 1.122 @@ -1258,6 +1258,9 @@ if (access(filename.c_str(), F_OK) != 0) { load_map(); + + player_status.reset(); + return; } |
From: Ryan F. <sik...@us...> - 2004-09-21 22:03:43
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4330 Modified Files: sector.cpp level.cpp Log Message: - fixed warnings pointed out by Frank Index: level.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/level.cpp,v retrieving revision 1.101 retrieving revision 1.102 diff -u -d -r1.101 -r1.102 --- level.cpp 17 Sep 2004 12:22:40 -0000 1.101 +++ level.cpp 21 Sep 2004 22:03:32 -0000 1.102 @@ -172,8 +172,8 @@ { int total_coins = 0; for(Sectors::iterator it = sectors.begin(); it != sectors.end(); ++it) - for(int x = 0; x < it->second->solids->get_width(); x++) - for(int y = 0; y < it->second->solids->get_height(); y++) + for(int x = 0; static_cast<unsigned int>(x) < it->second->solids->get_width(); x++) + for(int y = 0; static_cast<unsigned int>(y) < it->second->solids->get_height(); y++) if(it->second->solids->get_tile(x,y)->attributes & Tile::COIN) total_coins++; return total_coins; Index: sector.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sector.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- sector.cpp 20 Sep 2004 19:57:47 -0000 1.30 +++ sector.cpp 21 Sep 2004 22:03:32 -0000 1.31 @@ -45,8 +45,9 @@ Sector* Sector::_current = 0; Sector::Sector() - : gravity(10), player(0), solids(0), background(0), camera(0), - end_sequence_animation_type(NONE_ENDSEQ_ANIM), currentmusic(LEVEL_MUSIC) + : end_sequence_animation_type(NONE_ENDSEQ_ANIM), + gravity(10), player(0), solids(0), background(0), camera(0), + currentmusic(LEVEL_MUSIC) { song_title = "Mortimers_chipdisko.mod"; player = new Player(); |
From: Matze B. <mat...@us...> - 2004-09-21 11:13:18
|
Update of /cvsroot/super-tux/supertux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28487 Modified Files: configure.ac Log Message: fixed some more buggy AC_ENABLE usage Index: configure.ac =================================================================== RCS file: /cvsroot/super-tux/supertux/configure.ac,v retrieving revision 1.34 retrieving revision 1.35 diff -u -d -r1.34 -r1.35 --- configure.ac 21 Sep 2004 11:04:01 -0000 1.34 +++ configure.ac 21 Sep 2004 11:13:09 -0000 1.35 @@ -38,8 +38,9 @@ AC_MSG_CHECKING(for gprof mode) AC_ARG_ENABLE(gprof, - AC_HELP_STRING([--enable-gprof], [enable GNU profiling support]),, enable_gprof="no") -if test "x${enable_gprof}" != "xno"; then + AC_HELP_STRING([--enable-gprof], [enable GNU profiling support]), + [enable_gprof=$enableval], [enable_gprof=no]) +if test "$enable_gprof" = "no"; then CXXFLAGS="$CXXFLAGS -pg" AC_MSG_RESULT([enabled]) else @@ -59,8 +60,9 @@ AC_MSG_CHECKING(wether OpenGL should be used) AC_ARG_ENABLE(opengl, - AC_HELP_STRING([--disable-opengl], [disable OpenGL support]),, enable_opengl="yes") -if test "x${enable_opengl}" != "xno"; then + AC_HELP_STRING([--disable-opengl], [disable OpenGL support]), + [enable_opengl=$enableval], enable_opengl=yes) +if test "$enable_opengl" = "yes"; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) @@ -85,12 +87,12 @@ AC_CHECK_LIB(SDL_image, IMG_Load,, AC_MSG_ERROR([SDL_image library required])) -if test "x${enable_opengl}" != "xno"; then +if test "$enable_opengl" = "yes"; then AX_CHECK_GL fi -if test "x$no_gl" = "xyes" -o "x$enable_opengl" = "xno"; then +if test "$no_gl" = "yes" -o "$enable_opengl" = "no"; then CXXFLAGS="$CXXFLAGS -DNOOPENGL" - enable_opengl="no" + enable_opengl=no else CFLAGS="$CFLAGS $GL_CFLAGS" CXXFLAGS="$CXXFLAGS $GL_CFLAGS" |
From: Matze B. <mat...@us...> - 2004-09-21 11:04:24
|
Update of /cvsroot/super-tux/supertux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26579 Modified Files: configure.ac Log Message: fix check for debug flag Index: configure.ac =================================================================== RCS file: /cvsroot/super-tux/supertux/configure.ac,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- configure.ac 8 Sep 2004 20:21:47 -0000 1.33 +++ configure.ac 21 Sep 2004 11:04:01 -0000 1.34 @@ -48,9 +48,10 @@ AC_MSG_CHECKING(for debug mode) AC_ARG_ENABLE(debug, - AC_HELP_STRING([--enable-debug], [enable debugging mode]),, enable_debug="no") -if test "x${enable_debug}" != "xno"; then - CXXFLAGS="$CXXFLAGS -Wall -Werror -DDEBUG -O3 -g" + AC_HELP_STRING([--enable-debug], [enable debugging mode]), + [enable_debug=$enableval], [enable_debug=no]) +if test "$enable_debug" = "yes"; then + CXXFLAGS="$CXXFLAGS -Wall -Werror -DDEBUG -O0 -g3" AC_MSG_RESULT([enabled]) else AC_MSG_RESULT([disabled]) |
From: Ryan F. <sik...@us...> - 2004-09-20 19:57:56
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21358 Modified Files: sector.cpp Log Message: - fixed bug reported by Frank van der Loo Index: sector.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sector.cpp,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- sector.cpp 20 Sep 2004 19:17:29 -0000 1.29 +++ sector.cpp 20 Sep 2004 19:57:47 -0000 1.30 @@ -46,7 +46,7 @@ Sector::Sector() : gravity(10), player(0), solids(0), background(0), camera(0), - currentmusic(LEVEL_MUSIC), end_sequence_animation_type(NONE_ENDSEQ_ANIM) + end_sequence_animation_type(NONE_ENDSEQ_ANIM), currentmusic(LEVEL_MUSIC) { song_title = "Mortimers_chipdisko.mod"; player = new Player(); |
From: Ricardo C. <rm...@us...> - 2004-09-20 19:30:45
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15915/src Modified Files: player.cpp Log Message: Bugfix: Don't kill badguys when they are already dying or in a certain mode (bombs exploding or ticking). Reported by Frank van der Loo. Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.175 retrieving revision 1.176 diff -u -d -r1.175 -r1.176 --- player.cpp 18 Sep 2004 16:58:16 -0000 1.175 +++ player.cpp 20 Sep 2004 19:30:30 -0000 1.176 @@ -21,7 +21,6 @@ #include <iostream> #include <cassert> -#include "gameloop.h" #include "app/globals.h" #include "player.h" #include "defines.h" @@ -36,6 +35,7 @@ #include "interactive_object.h" #include "video/screen.h" #include "statistics.h" +#include "gameloop.h" // behavior definitions: #define TILES_FOR_BUTTJUMP 3 @@ -628,12 +628,16 @@ BadGuy* badguy = dynamic_cast<BadGuy*> (*i); if(badguy) { - - if (fabsf(base.x - badguy->base.x) < 150 && - fabsf(base.y - badguy->base.y) < 60 && - (issolid(badguy->base.x + 1, badguy->base.y + badguy->base.height) || - issolid(badguy->base.x + badguy->base.width - 1, badguy->base.y + badguy->base.height))) - badguy->kill_me(25); + // don't kill when badguys are already dying or in a certain mode + if(badguy->dying == DYING_NOT && badguy->mode != BadGuy::BOMB_TICKING && + badguy->mode != BadGuy::BOMB_EXPLODE) + { + if (fabsf(base.x - badguy->base.x) < 150 && + fabsf(base.y - badguy->base.y) < 60 && + (issolid(badguy->base.x + 1, badguy->base.y + badguy->base.height) || + issolid(badguy->base.x + badguy->base.width - 1, badguy->base.y + badguy->base.height))) + badguy->kill_me(25); + } } } } |
From: Ricardo C. <rm...@us...> - 2004-09-20 19:17:39
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13237/src Modified Files: gameobjs.cpp gameobjs.h sector.cpp Log Message: Changed FloatingScore to support text (changed name to FloatingText). I guess this could be usefull for some stuff, saying "Bonus" and whatever. Also made a fading animation when disapearing. Index: gameobjs.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.cpp,v retrieving revision 1.51 retrieving revision 1.52 diff -u -d -r1.51 -r1.52 --- gameobjs.cpp 17 Sep 2004 12:41:50 -0000 1.51 +++ gameobjs.cpp 20 Sep 2004 19:17:29 -0000 1.52 @@ -114,27 +114,48 @@ draw_tile(context, shape.id, position + Vector(0, offset), LAYER_TILES+1); } -FloatingScore::FloatingScore(const Vector& pos, int score) +FloatingText::FloatingText(const Vector& pos, std::string& text_) + : position(pos), text(text_) +{ + timer.start(1000); + position.x -= text.size() * 8; +} + +FloatingText::FloatingText(const Vector& pos, int score) : position(pos) { timer.start(1000); + + // turn int into a string + char str[10]; snprintf(str, 10, "%d", score); - position.x -= strlen(str) * 8; + text = str; + + position.x -= text.size() * 8; } void -FloatingScore::action(float elapsed_time) +FloatingText::action(float elapsed_time) { - position.y -= 2 * elapsed_time; + position.y -= 1.4 * elapsed_time; if(!timer.check()) remove_me(); } +#define FADING_TIME 350 + void -FloatingScore::draw(DrawingContext& context) +FloatingText::draw(DrawingContext& context) { - context.draw_text(gold_text, str, position, LEFT_ALLIGN, LAYER_OBJECTS); + // make an alpha animation when disapearing + int alpha; + if(timer.get_left() < FADING_TIME) + alpha = timer.get_left() * 255 / FADING_TIME; + else + alpha = 255; + + context.draw_text(gold_text, text, position, LEFT_ALLIGN, LAYER_OBJECTS, NONE_EFFECT, alpha); } /* Trampoline */ Index: gameobjs.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameobjs.h,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- gameobjs.h 17 Sep 2004 12:41:52 -0000 1.36 +++ gameobjs.h 20 Sep 2004 19:17:29 -0000 1.37 @@ -91,17 +91,18 @@ TileId& shape; }; -class FloatingScore : public GameObject +class FloatingText : public GameObject { public: - FloatingScore(const Vector& pos, int s); + FloatingText(const Vector& pos, std::string& text_); + FloatingText(const Vector& pos, int s); // use this for score, for instance virtual void action(float elapsed_time); virtual void draw(DrawingContext& context); private: Vector position; - char str[10]; + std::string text; Timer timer; }; Index: sector.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sector.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- sector.cpp 17 Sep 2004 12:22:40 -0000 1.28 +++ sector.cpp 20 Sep 2004 19:17:29 -0000 1.29 @@ -667,7 +667,7 @@ { global_stats.add_points(SCORE_STAT, s); - add_object(new FloatingScore(pos, s)); + add_object(new FloatingText(pos, s)); } void |
From: Ricardo C. <rm...@us...> - 2004-09-20 19:04:12
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10402/src Modified Files: statistics.cpp Log Message: Fixed layout on worldmap message. Fixed displaying on level/game over messages. Index: statistics.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/statistics.cpp,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- statistics.cpp 17 Sep 2004 19:04:04 -0000 1.10 +++ statistics.cpp 20 Sep 2004 19:04:02 -0000 1.11 @@ -19,11 +19,11 @@ #include "utils/lispreader.h" #include "utils/lispwriter.h" -#include "statistics.h" #include "video/drawing_context.h" #include "app/gettext.h" #include "app/globals.h" #include "resources.h" +#include "statistics.h" Statistics global_stats; @@ -91,8 +91,8 @@ #define TOTAL_DISPLAY_TIME 3400 #define FADING_TIME 600 -#define WMAP_INFO_LEFT_X 540 -#define WMAP_INFO_RIGHT_X 720 +#define WMAP_INFO_LEFT_X 520 +#define WMAP_INFO_RIGHT_X 740 void Statistics::draw_worldmap_info(DrawingContext& context) @@ -118,15 +118,15 @@ char str[128]; - context.draw_text(white_small_text, _("Best Level Statistics"), - Vector((WMAP_INFO_LEFT_X + WMAP_INFO_RIGHT_X) / 2, 490), + context.draw_text(white_small_text, _("- Best Level Statistics -"), + Vector((WMAP_INFO_LEFT_X + WMAP_INFO_RIGHT_X) / 2, 470), CENTER_ALLIGN, LAYER_GUI); sprintf(str, _("Max score:")); - context.draw_text(white_small_text, str, Vector(WMAP_INFO_LEFT_X, 506), LEFT_ALLIGN, LAYER_GUI); + context.draw_text(white_small_text, str, Vector(WMAP_INFO_LEFT_X, 490), LEFT_ALLIGN, LAYER_GUI); sprintf(str, "%d", stats[SCORE_STAT][SPLAYER]); - context.draw_text(white_small_text, str, Vector(WMAP_INFO_RIGHT_X, 506), RIGHT_ALLIGN, LAYER_GUI); + context.draw_text(white_small_text, str, Vector(WMAP_INFO_RIGHT_X, 490), RIGHT_ALLIGN, LAYER_GUI); // draw other small info @@ -137,7 +137,7 @@ else// if(display_stat == TIME_NEEDED_STAT) sprintf(str, _("Min time needed:")); - context.draw_text(white_small_text, str, Vector(WMAP_INFO_LEFT_X, 522), LEFT_ALLIGN, LAYER_GUI, NONE_EFFECT, alpha); + context.draw_text(white_small_text, str, Vector(WMAP_INFO_LEFT_X, 508), LEFT_ALLIGN, LAYER_GUI, NONE_EFFECT, alpha); if(display_stat == COINS_COLLECTED_STAT) sprintf(str, "%d/%d", stats[COINS_COLLECTED_STAT][SPLAYER], @@ -149,7 +149,7 @@ sprintf(str, "%d/%d", stats[TIME_NEEDED_STAT][SPLAYER], stats[TIME_NEEDED_STAT][STOTAL]); - context.draw_text(white_small_text, str, Vector(WMAP_INFO_RIGHT_X, 522), RIGHT_ALLIGN, LAYER_GUI, NONE_EFFECT, alpha); + context.draw_text(white_small_text, str, Vector(WMAP_INFO_RIGHT_X, 508), RIGHT_ALLIGN, LAYER_GUI, NONE_EFFECT, alpha); } void @@ -162,20 +162,24 @@ char str[128]; - sprintf(str, _( "Max score: %d"), stats[SCORE_STAT][SPLAYER]); + sprintf(str, _( "Max score: %d"), stats[SCORE_STAT][SPLAYER]); context.draw_text(white_text, str, Vector(screen->w/2, 450), CENTER_ALLIGN, LAYER_GUI); for(int i = 1; i < NUM_STATS; i++) { if(i == COINS_COLLECTED_STAT) - sprintf(str, _("Max coins collected: %d"), ((float)stats[COINS_COLLECTED_STAT][SPLAYER] / - (float)stats[COINS_COLLECTED_STAT][STOTAL]) * 100); + sprintf(str, _("Max coins collected: %d / %d"), + stats[COINS_COLLECTED_STAT][SPLAYER], + stats[COINS_COLLECTED_STAT][STOTAL]); else if(i == BADGUYS_KILLED_STAT) - sprintf(str, _("Max fragging: %d"), ((float)stats[BADGUYS_KILLED_STAT][SPLAYER] / - (float)stats[BADGUYS_KILLED_STAT][STOTAL]) * 100); + sprintf(str, _("Max fragging: %d / %d"), + stats[BADGUYS_KILLED_STAT][SPLAYER], + stats[BADGUYS_KILLED_STAT][STOTAL]); else// if(i == TIME_NEEDED_STAT) - sprintf(str, _("Min time needed: %d"), ((float)stats[TIME_NEEDED_STAT][SPLAYER] / - (float)stats[TIME_NEEDED_STAT][STOTAL]) * 100); + sprintf(str, _("Min time needed: %d / %d"), + stats[TIME_NEEDED_STAT][SPLAYER], + stats[TIME_NEEDED_STAT][STOTAL]); + context.draw_text(white_small_text, str, Vector(screen->w/2, 462 + i*18), CENTER_ALLIGN, LAYER_GUI); } |
From: Ricardo C. <rm...@us...> - 2004-09-20 19:02:56
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10052/src Modified Files: gameloop.cpp gameloop.h Log Message: When swap keep statistics so far. (not tested - I'd appreaciate if someone would test this) Also, when you go to some swap, you'll always stay there, even if you die before it - requested by various players. Index: gameloop.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.h,v retrieving revision 1.61 retrieving revision 1.62 diff -u -d -r1.61 -r1.62 --- gameloop.h 15 Sep 2004 21:59:30 -0000 1.61 +++ gameloop.h 20 Sep 2004 19:02:46 -0000 1.62 @@ -25,6 +25,7 @@ #include "special/timer.h" #include "special/base.h" #include "special/frame_rate.h" +#include "statistics.h" using namespace SuperTux; @@ -122,6 +123,12 @@ // for fire works Timer random_timer; + // swap points + Vector last_swap_point; + Statistics last_swap_stats; + + Statistics* best_level_statistics; + void restart_level(); void check_end_conditions(); @@ -135,8 +142,6 @@ void on_escape_press(); void process_menu(); - - Statistics* best_level_statistics; }; std::string slotinfo(int slot); Index: gameloop.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/gameloop.cpp,v retrieving revision 1.185 retrieving revision 1.186 diff -u -d -r1.185 -r1.186 --- gameloop.cpp 17 Sep 2004 12:22:40 -0000 1.185 +++ gameloop.cpp 20 Sep 2004 19:02:46 -0000 1.186 @@ -99,6 +99,9 @@ if(flip_levels_mode) flip_level = true; + last_swap_point = Vector(-1, -1); + last_swap_stats.reset(); + restart_level(); } @@ -143,9 +146,19 @@ if(tux_pos.x != -1) { tux_pos = currentsector->get_best_spawn_point(tux_pos); + + if(last_swap_point.x > tux_pos.x) + tux_pos = last_swap_point; + else // new swap point + { + last_swap_point = tux_pos; + + last_swap_stats += global_stats; + } + 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)); @@ -543,6 +556,7 @@ if(end_sequence && !endsequence_timer.check()) { exit_status = ES_LEVEL_FINISHED; + global_stats += last_swap_stats; // add swap points stats return; } else if(end_sequence == ENDSEQUENCE_RUNNING && endtile && endtile->data >= 1) |
From: Marek M. <wa...@us...> - 2004-09-18 16:58:25
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32160/src Modified Files: player.cpp Log Message: Tux can now flap after bouncing off an enemy Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.174 retrieving revision 1.175 diff -u -d -r1.174 -r1.175 --- player.cpp 18 Sep 2004 16:39:41 -0000 1.174 +++ player.cpp 18 Sep 2004 16:58:16 -0000 1.175 @@ -1153,6 +1153,10 @@ void Player::bounce(BadGuy* badguy) { + //Make sure we stopped flapping + flapping = false; + falling_from_flap = false; + if (input.up) physic.set_velocity_y(5.2); else |
From: Marek M. <wa...@us...> - 2004-09-18 16:39:49
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28644/src Modified Files: player.cpp Log Message: fixed "flapping key not responding"-problem Index: player.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/player.cpp,v retrieving revision 1.173 retrieving revision 1.174 diff -u -d -r1.173 -r1.174 --- player.cpp 17 Sep 2004 23:14:23 -0000 1.173 +++ player.cpp 18 Sep 2004 16:39:41 -0000 1.174 @@ -563,7 +563,10 @@ // Flapping if (input.up == DOWN && can_flap) { - if (!flapping_timer.started()) {flapping_timer.start(TUX_FLAPPING_TIME);} + if (!flapping_timer.started()) + { + flapping_timer.start(TUX_FLAPPING_TIME); + } if (!flapping_timer.check()) { can_flap = false; @@ -651,6 +654,7 @@ jumping = false; flapping = false; falling_from_flap = false; + if (flapping_timer.started()) {flapping_timer.stop();} } input.old_up = input.up; |