From: Matthias Braun Date: Sun, 19 Dec 2004 13:34:12 +0000 (+0000) Subject: -german translation updates X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=7a87271678d68514ae2158c0c7adb383d6002872;p=supertux.git -german translation updates -some cleanups -a first version of grab&carry around code. It doesn't work too good yet but it was lying around too long on my HD... SVN-Revision: 2256 --- diff --git a/data/images/supertux.strf b/data/images/supertux.strf index d29f8712c..f81131fa6 100644 --- a/data/images/supertux.strf +++ b/data/images/supertux.strf @@ -1314,12 +1314,12 @@ (images "tilesets/brick1.png")) ) - (sprite (name "invisibleblock") + (sprite (name "rock") (action - (name "empty") - (images "tilesets/bonus2-d.png")) + (name "default") + (images "tilesets/block11.png")) ) - + ; Stomp (sprite (name "stomp") (action diff --git a/data/levels/test/simple.stl b/data/levels/test/simple.stl index a42a7cb41..dbd263d0e 100644 --- a/data/levels/test/simple.stl +++ b/data/levels/test/simple.stl @@ -13,6 +13,7 @@ (background (image "arctis.jpg") (speed 0.5)) (spawnpoint (name "main") (x 50) (y 200)) + (rock (x 50) (y 50)) (tilemap (layer "background") (solid #f) diff --git a/data/levels/world1/de.po b/data/levels/world1/de.po index 5a64ad41c..53d732925 100644 --- a/data/levels/world1/de.po +++ b/data/levels/world1/de.po @@ -173,7 +173,6 @@ msgid "Grumbel's Sense of Snow" msgstr "Grumbels Schneegespür" #: data/levels/world1/extro.txt:7 -#, fuzzy msgid "" "-Entering Nolok's Throne Room!\n" "\n" @@ -210,13 +209,14 @@ msgid "" "#up. Penny was counting on him." msgstr "" "-In Noloks Thronsaal\n" -"#Tux betrat Noloks Thronsaal und\n" -"#suchte verzweifelt nach seiner Geliebten,\n" -"#leider konnte er weder Penny noch Nolok\n" -"#dort entdecken, stattdessen fand er eine\n" -"#weitere Nachricht.\n" "\n" -"#\"Gut gemaacht mein leiber Tux, sehr gut.\n" +"#Tux betrat Noloks Thronsaal und suchte\n" +"#verzweifelt nach seiner Geliebten. Leider\n" +"#konnte er weder Penny noch Nolok dort\n" +"#entdecken, stattdessen fand er eine\n" +"#weitere Nachricht:\n" +"\n" +"#\"Gut gemacht mein lieber Tux, sehr gut.\n" "#Wenn du dies hier liest, hast du diese\n" "#eisige Festung von mir befreit. Aber wie\n" "#du siehst ist deine geliebte Penny nicht\n" @@ -230,7 +230,7 @@ msgstr "" "#einer weiteren fliehen. Sei nicht dumm,\n" "#es wäre das beste jetzt aufzugeben.\n" "\n" -"#Tux verliess traurig den Sall, als etwas\n" +"#Tux verliess traurig den Saal, als etwas\n" "#unter seinem Fuss raschelte...\n" "#Ein Briefumschlag mit seinem Namen!\n" "#In dem Umschlag war eine grobe Karte,\n" diff --git a/data/levels/world1/level19.stl b/data/levels/world1/level19.stl index eba5cd101..577af4565 100644 --- a/data/levels/world1/level19.stl +++ b/data/levels/world1/level19.stl @@ -8,7 +8,7 @@ (start_pos_x 100) (start_pos_y 170) (background "cave2.jpg") - (music "cave.mod") + (music "cave_remastered.ogg") (bkgd_red_top 150) (bkgd_green_top 150) (bkgd_blue_top 150) diff --git a/data/locale/.cvsignore b/data/locale/.cvsignore index 6394bdd8e..76b6af9af 100644 --- a/data/locale/.cvsignore +++ b/data/locale/.cvsignore @@ -1,2 +1,2 @@ -supertux.pot +messages.pot diff --git a/data/locale/de.po b/data/locale/de.po index c2569763a..eb1b48d05 100644 --- a/data/locale/de.po +++ b/data/locale/de.po @@ -7,7 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: SuperTux 0.1.1\n" -"POT-Creation-Date: 2004-12-05 18:22+0100\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2004-12-15 17:21+0100\n" "PO-Revision-Date: 2004-12-06 18:26+0100\n" "Last-Translator: Matze Braun \n" "Language-Team: German \n" @@ -15,12 +16,141 @@ msgstr "" "Content-Type: text/plain; charset=ISO-8859-1\n" "Content-Transfer-Encoding: 8bit\n" +#: lib/app/setup.cpp:798 +#, c-format +msgid "" +"Usage: %s [OPTIONS] FILENAME\n" +"\n" +msgstr "" +"Aufruf: %s [OPTIONS] FILENAME\n" +"\n" + +#: lib/app/setup.cpp:799 +msgid "" +"Display Options:\n" +" -f, --fullscreen Run in fullscreen mode.\n" +" -w, --window Run in window mode.\n" +" --opengl If OpenGL support was compiled in, this will tell\n" +" SuperTux to make use of it.\n" +" --sdl Use the SDL software graphical renderer\n" +"\n" +"Sound Options:\n" +" --disable-sound If sound support was compiled in, this will\n" +" disable sound for this session of the game.\n" +" --disable-music Like above, but this will disable music.\n" +"\n" +"Misc Options:\n" +" -j, --joystick NUM Use joystick NUM (default: 0)\n" +" --joymap XAXIS:YAXIS:A:B:START\n" +" Define how joystick buttons and axis should be mapped\n" +" --leveleditor Opens the leveleditor in a file.\n" +" --worldmap Opens the specified worldmap file.\n" +" --flip-levels Flip levels upside-down.\n" +" -d, --datadir DIR Load Game data from DIR (default: automatic)\n" +" --debug Enables the debug mode, which is useful for " +"developers.\n" +" --help Display a help message summarizing command-line\n" +" options, license and game controls.\n" +" --usage Display a brief message summarizing command-line " +"options.\n" +" --version Display the version of SuperTux you're running.\n" +"\n" +msgstr "" +"Display Options:\n" +" -f, --fullscreen Im Vollbildmodus starten\n" +" -w, --window Im Fenstermodus starten\n" +" --opengl OpenGL benutzen\n" +" --sdl SDL Software renderer benutzen\n" +"\n" +"Sound Options:\n" +" --disable-sound Sound deaktivieren\n" +" --disable-music Musik deaktivieren\n" +"\n" +"Misc Options:\n" +" -j, --joystick NUM Joystick NUM benutzen (default: 0)\n" +" --joymap XAXIS:YAXIS:A:B:START\n" +" Belegung der Joystick Knöpfe und Axen einstellen\n" +" --leveleditor Startet den Level Editor\n" +" --worldmap Startet im Worldmap Modus\n" +" -d, --datadir DIR Verzeichnis mit Spieldaten (standard: automatisch)\n" +" --debug Debug Modus aktivieren\n" +" --help diese Hilfe anzeigen und beenden\n" +" --usage kurzen Hilfstext über Optionen anzeigen\n" +" --version Versionsinformationen anzeigen\n" +"\n" + +#: lib/app/setup.cpp:858 +#, c-format +msgid "" +"Usage: %s [--fullscreen] [--opengl] [--disable-sound] [--disable-music] [--" +"debug] | [--usage | --help | --version] [--leveleditor] [--worldmap] [--flip-" +"levels] FILENAME\n" +msgstr "" +"Aufruf: %s [--fullscreen] [--opengl] [--disable-sound] [--disable-music] [--" +"debug] | [--usage | --help | --version] [--leveleditor] [--worldmap] [--flip-" +"levels] DATEI\n" + +#: lib/gui/menu.cpp:68 +msgid "Yes" +msgstr "Ja" + +#: lib/gui/menu.cpp:69 +msgid "No" +msgstr "Nein" + +#: lib/gui/menu.cpp:237 +msgid "Up cursor" +msgstr "Nach Oben" + +#: lib/gui/menu.cpp:240 +msgid "Down cursor" +msgstr "Nach Unten" + +#: lib/gui/menu.cpp:243 +msgid "Left cursor" +msgstr "Nach Links" + +#: lib/gui/menu.cpp:246 +msgid "Right cursor" +msgstr "Nach Rechts" + +#: lib/gui/menu.cpp:249 +msgid "Return" +msgstr "Return" + +#: lib/gui/menu.cpp:252 +msgid "Space" +msgstr "Space" + +#: lib/gui/menu.cpp:255 +msgid "Right Shift" +msgstr "Shift Rechts" + +#: lib/gui/menu.cpp:258 +msgid "Left Shift" +msgstr "Shift Links" + +#: lib/gui/menu.cpp:261 +msgid "Right Control" +msgstr "Steuerung Rechts" + +#: lib/gui/menu.cpp:264 +msgid "Left Control" +msgstr "Steuerung Links" + +#: lib/gui/menu.cpp:267 +msgid "Right Alt" +msgstr "Alt Rechts" + +#: lib/gui/menu.cpp:270 +msgid "Left Alt" +msgstr "Alt Links" + #: src/worldmap.cpp:802 msgid "GAMEOVER" msgstr "Game Over" -#: src/worldmap.cpp:805 -#: src/gameloop.cpp:922 +#: src/worldmap.cpp:805 src/gameloop.cpp:922 #, c-format msgid "COINS: %d" msgstr "Münzen: %d" @@ -29,53 +159,44 @@ msgstr "M msgid "Total Statistics" msgstr "Gesamt Statistiken" -#: src/worldmap.cpp:963 -#: src/gameloop.cpp:843 +#: src/worldmap.cpp:963 src/gameloop.cpp:843 msgid "SCORE" msgstr "Punkte" -#: src/worldmap.cpp:967 -#: src/gameloop.cpp:865 -#: src/gameloop.cpp:866 +#: src/worldmap.cpp:967 src/gameloop.cpp:865 src/gameloop.cpp:866 msgid "COINS" msgstr "Münzen" -#: src/worldmap.cpp:988 -#: src/worldmap.cpp:989 -#: src/gameloop.cpp:887 +#: src/worldmap.cpp:988 src/worldmap.cpp:989 src/gameloop.cpp:887 #: src/gameloop.cpp:888 msgid "LIVES" msgstr "Leben" -#: src/title.cpp:124 -#: src/misc.cpp:98 +#: src/title.cpp:124 src/misc.cpp:98 msgid "Contrib Levels" msgstr "Zusatzlevel" -#: src/title.cpp:143 -#: src/title.cpp:216 -#: src/misc.cpp:129 -#: src/misc.cpp:140 -#: src/misc.cpp:153 -#: src/misc.cpp:164 -#: src/leveleditor.cpp:67 +#: src/title.cpp:143 src/title.cpp:216 src/misc.cpp:129 src/misc.cpp:140 +#: src/misc.cpp:153 src/misc.cpp:164 src/leveleditor.cpp:67 #: src/leveleditor.cpp:77 msgid "Back" msgstr "Zurück" -#: src/title.cpp:350 +#: src/title.cpp:351 msgid "" "Copyright (c) 2003 SuperTux Devel Team\n" "This game comes with ABSOLUTELY NO WARRANTY. This is free software, and you\n" -"are welcome to redistribute it under certain conditions; see the file COPYING\n" +"are welcome to redistribute it under certain conditions; see the file " +"COPYING\n" "for details.\n" msgstr "" "Copyright (c) 2003 SuperTux Devel Team\n" "Diese Spiel kommt OHNE GEWÄHRLEISTUNG. Dies ist freie Software und sie\n" -"dürfen sie gerne unter bestimmten Bedingungen weiterverteilen; Details finden\n" +"dürfen sie gerne unter bestimmten Bedingungen weiterverteilen; Details " +"finden\n" "Sie in der Datei COPYING.\n" -#: src/title.cpp:404 +#: src/title.cpp:408 msgid "Are you sure you want to delete slot" msgstr "Sind sie sicher, dass sie den Spielstand löschen wollen?" @@ -164,20 +285,15 @@ msgstr "Max besiegt: %d / %d" msgid "Min time needed: %d / %d" msgstr "Min Zeit benötigt: %d / %d" -#: src/misc.cpp:97 -#: src/misc.cpp:156 +#: src/misc.cpp:97 src/misc.cpp:156 msgid "Start Game" msgstr "Spiel Beginnen" -#: src/misc.cpp:99 -#: src/misc.cpp:104 -#: src/misc.cpp:179 -#: src/misc.cpp:186 +#: src/misc.cpp:99 src/misc.cpp:104 src/misc.cpp:179 src/misc.cpp:186 msgid "Options" msgstr "Einstellungen" -#: src/misc.cpp:100 -#: src/leveleditor.cpp:562 +#: src/misc.cpp:100 src/leveleditor.cpp:562 msgid "Level Editor" msgstr "Level Editor" @@ -201,13 +317,11 @@ msgstr "OpenGL (nicht vorhanden)" msgid "Fullscreen" msgstr "Ganzer Bildschirm" -#: src/misc.cpp:114 -#: src/misc.cpp:119 +#: src/misc.cpp:114 src/misc.cpp:119 msgid "Sound " msgstr "Sound" -#: src/misc.cpp:115 -#: src/misc.cpp:120 +#: src/misc.cpp:115 src/misc.cpp:120 msgid "Music " msgstr "Musik" @@ -267,13 +381,11 @@ msgstr "B Knopf" msgid "Save Game" msgstr "Spiel Speichern" -#: src/misc.cpp:176 -#: src/misc.cpp:183 +#: src/misc.cpp:176 src/misc.cpp:183 msgid "Pause" msgstr "Pause" -#: src/misc.cpp:178 -#: src/misc.cpp:185 +#: src/misc.cpp:178 src/misc.cpp:185 msgid "Continue" msgstr "Fortsetzen" @@ -409,9 +521,7 @@ msgstr "Test Level" msgid "Setup level" msgstr "Level-Einstellungen" -#: src/leveleditor.cpp:237 -#: src/leveleditor.cpp:727 -#: src/leveleditor.cpp:752 +#: src/leveleditor.cpp:237 src/leveleditor.cpp:727 src/leveleditor.cpp:752 #: src/leveleditor.cpp:841 msgid "Level not saved. Wanna to?" msgstr "Level wurde noch nicht gespeichert. Jetzt speichern?" @@ -517,4 +627,3 @@ msgstr "Um fortzufahren beliebige Taste dr #, c-format msgid "New max combo: %d" msgstr "Neue Max Kombination: %d" - diff --git a/src/object/coin.h b/src/object/coin.h index 051d1c045..fd827ed51 100644 --- a/src/object/coin.h +++ b/src/object/coin.h @@ -15,9 +15,9 @@ public: Coin(const Vector& pos); ~Coin(); - virtual HitResponse collision(GameObject& other, const CollisionHit& hit); - virtual void action(float elapsed_time); - virtual void draw(DrawingContext& context); + HitResponse collision(GameObject& other, const CollisionHit& hit); + void action(float elapsed_time); + void draw(DrawingContext& context); void collect(); diff --git a/src/object/player.cpp b/src/object/player.cpp index fcbe65849..ec971654f 100644 --- a/src/object/player.cpp +++ b/src/object/player.cpp @@ -25,6 +25,7 @@ #include "app/globals.h" #include "app/gettext.h" +#include "special/sprite_manager.h" #include "player.h" #include "defines.h" #include "scene.h" @@ -38,6 +39,7 @@ #include "object/tilemap.h" #include "object/camera.h" #include "object/gameobjs.h" +#include "object/portable.h" #include "trigger/trigger_base.h" static const int TILES_FOR_BUTTJUMP = 3; @@ -59,10 +61,6 @@ Surface* growingtux_right[GROWING_FRAMES]; Surface* tux_life = 0; -Sprite* smalltux_gameover = 0; -Sprite* smalltux_star = 0; -Sprite* bigtux_star = 0; - TuxBodyParts* small_tux = 0; TuxBodyParts* big_tux = 0; TuxBodyParts* fire_tux = 0; @@ -123,19 +121,24 @@ TuxBodyParts::draw(DrawingContext& context, const Vector& pos, int layer, } Player::Player() + : grabbed_object(0) { + smalltux_gameover = sprite_manager->create("smalltux-gameover"); + smalltux_star = sprite_manager->create("smalltux-star"); + bigtux_star = sprite_manager->create("bigtux-star"); init(); } Player::~Player() { + delete smalltux_gameover; + delete smalltux_star; + delete bigtux_star; } void Player::init() { - holding_something = false; - bbox.set_size(31.8, 31.8); size = SMALL; @@ -166,6 +169,7 @@ Player::init() flaps_nb = 0; on_ground_flag = false; + grabbed_object = 0; player_input_init(&input); @@ -249,44 +253,32 @@ Player::action(float elapsed_time) return; } - if (input.fire == UP) - holding_something = false; + if(input.fire == UP) + grabbed_object = 0; + if(dying == DYING_NOT) handle_input(); movement = physic.get_movement(elapsed_time); + on_ground_flag = false; #if 0 - // special exception for cases where we're stuck under tiles after - // being ducked. In this case we drift out - if(!duck && on_ground() && old_base.x == base.x && old_base.y == base.y - && collision_object_map(base)) - { - base.x += elapsed_time * WALK_SPEED * (dir ? 1: -1); - previous_base = old_base = base; - } - - /* Reset score multiplier (for multi-hits): */ - if (!invincible_timer.started()) - { - if(player_status.score_multiplier > player_status.max_score_multiplier) - { - player_status.max_score_multiplier = player_status.score_multiplier; - - // show a message - char str[124]; - sprintf(str, _("New max combo: %d"), player_status.max_score_multiplier-1); - Sector::current()->add_floating_text(base, str); - } - player_status.score_multiplier = 1; - } - } - - } + // special exception for cases where we're stuck under tiles after + // being ducked. In this case we drift out + if(!duck && on_ground() && old_base.x == base.x && old_base.y == base.y + && collision_object_map(base)) { + base.x += elapsed_time * WALK_SPEED * (dir ? 1: -1); + previous_base = old_base = base; + } #endif - on_ground_flag = false; + if(grabbed_object != 0) { + Vector pos = get_pos() + + Vector(dir == LEFT ? -16 : 16, + bbox.get_height()*0.66666 - 32); + grabbed_object->grab(*this, pos); + } } bool @@ -342,40 +334,36 @@ Player::handle_horizontal_input() } // changing directions? - if(on_ground() && ((vx < 0 && dirsign >0) || (vx>0 && dirsign<0))) - { - // let's skid! - if(fabs(vx)>SKID_XM && !skidding_timer.started()) - { - skidding_timer.start(SKID_TIME); - SoundManager::get()->play_sound(IDToSound(SND_SKID)); - // dust some partcles - Sector::current()->add_object( - new Particles( - Vector(bbox.p1.x + (dir == RIGHT ? bbox.get_width() : 0), - bbox.p2.y), - dir == RIGHT ? 270+20 : 90-40, dir == RIGHT ? 270+40 : 90-20, - Vector(280,-260), Vector(0,0.030), 3, Color(100,100,100), 3, .8, - LAYER_OBJECTS+1)); - - ax *= 2.5; - } - else - { - ax *= 2; - } + if(on_ground() && ((vx < 0 && dirsign >0) || (vx>0 && dirsign<0))) { + // let's skid! + if(fabs(vx)>SKID_XM && !skidding_timer.started()) { + skidding_timer.start(SKID_TIME); + SoundManager::get()->play_sound(IDToSound(SND_SKID)); + // dust some partcles + Sector::current()->add_object( + new Particles( + Vector(bbox.p1.x + (dir == RIGHT ? bbox.get_width() : 0), + bbox.p2.y), + dir == RIGHT ? 270+20 : 90-40, dir == RIGHT ? 270+40 : 90-20, + Vector(280,-260), Vector(0,0.030), 3, Color(100,100,100), 3, .8, + LAYER_OBJECTS+1)); + + ax *= 2.5; + } else { + ax *= 2; } + } // we get slower when not pressing any keys if(dirsign == 0) { - if(fabs(vx) < WALK_SPEED) { - vx = 0; - ax = 0; - } else if(vx < 0) { - ax = WALK_ACCELERATION_X * 1.5; - } else { - ax = WALK_ACCELERATION_X * -1.5; - } + if(fabs(vx) < WALK_SPEED) { + vx = 0; + ax = 0; + } else if(vx < 0) { + ax = WALK_ACCELERATION_X * 1.5; + } else { + ax = WALK_ACCELERATION_X * -1.5; + } } #if 0 @@ -558,14 +546,6 @@ Player::handle_vertical_input() } } - // Hover - //(disabled by default, use cheat code "hover" to toggle on/off) - //TODO: needs some tweaking, especially when used together with double jump and jumping off badguys - if (enable_hover && input.jump == DOWN && !jumping && !butt_jump && physic.get_velocity_y() <= 0) - { - physic.set_velocity_y(-100); - } - #if 0 /* In case the player has pressed Down while in a certain range of air, enable butt jump action */ @@ -712,11 +692,6 @@ Player::grow(bool animate) } void -Player::grabdistros() -{ -} - -void Player::draw(DrawingContext& context) { TuxBodyParts* tux_body; @@ -799,7 +774,7 @@ Player::draw(DrawingContext& context) } // Tux is holding something - if ((holding_something && physic.get_velocity_y() == 0) || + if ((grabbed_object != 0 && physic.get_velocity_y() == 0) || (shooting_timer.get_timeleft() > 0 && !shooting_timer.check())) { if (duck) @@ -872,6 +847,13 @@ Player::draw(DrawingContext& context) HitResponse Player::collision(GameObject& other, const CollisionHit& hit) { + Portable* portable = dynamic_cast (&other); + if(portable && grabbed_object == 0 && input.fire == DOWN + && fabsf(hit.normal.x) > .9) { + grabbed_object = portable; + return CONTINUE; + } + if(other.get_flags() & FLAG_SOLID) { if(hit.normal.y < 0) { // landed on floor? if (physic.get_velocity_y() < 0) diff --git a/src/object/player.h b/src/object/player.h index be6398cba..0a179a425 100644 --- a/src/object/player.h +++ b/src/object/player.h @@ -19,6 +19,7 @@ #ifndef SUPERTUX_PLAYER_H #define SUPERTUX_PLAYER_H +#include #include "SDL.h" #include "timer.h" @@ -31,6 +32,7 @@ using namespace SuperTux; class BadGuy; +class Portable; /* Times: */ @@ -40,18 +42,10 @@ class BadGuy; #define TUX_FLAPPING_TIME 1 /* How long Tux can flap his wings to gain additional jump height */ #define TIME_WARNING 20 /* When to alert player they're low on time! */ -/* Scores: */ - -#define SCORE_BRICK 5 -#define SCORE_DISTRO 20 - /* Sizes: */ - #define SMALL 0 #define BIG 1 -#include - struct PlayerKeymap { public: @@ -88,9 +82,6 @@ class PlayerStatus; extern Surface* tux_life; -extern Sprite* smalltux_gameover; -extern Sprite* smalltux_star; -extern Sprite* bigtux_star; #define GROWING_TIME 1.0 #define GROWING_FRAMES 7 @@ -137,7 +128,6 @@ public: int got_power; int size; bool duck; - bool holding_something; bool dead; DyingType dying; @@ -183,7 +173,6 @@ public: int key_event(SDLKey key, int state); void level_begin(); void handle_input(); - void grabdistros(); PlayerStatus& get_status(); @@ -196,11 +185,10 @@ public: { return invincible_timer.started(); } + void kill(HurtMode mode); void player_remove_powerups(); void check_bounds(Camera* camera); - bool on_ground(); - bool under_solid(); void grow(bool animate = false); void move(const Vector& vector); @@ -210,15 +198,19 @@ public: { return dead; } private: + bool on_ground(); + void init(); void handle_horizontal_input(); void handle_vertical_input(); void remove_powerups(); + + Portable* grabbed_object; + + Sprite* smalltux_gameover; + Sprite* smalltux_star; + Sprite* bigtux_star; }; #endif /*SUPERTUX_PLAYER_H*/ - -/* Local Variables: */ -/* mode:c++ */ -/* End: */ diff --git a/src/object/portable.h b/src/object/portable.h new file mode 100644 index 000000000..ce678d10d --- /dev/null +++ b/src/object/portable.h @@ -0,0 +1,23 @@ +#ifndef __PORTABLE_H__ +#define __PORTABLE_H__ + +#include "special/moving_object.h" + +using namespace SuperTux; + +/** + * An object that inherits from this object is considered "portable" and can + * be carried around by the player. + * The object has to additionally set the PORTABLE flag (this allows to + * make the object only temporarily portable by resetting the flag) + */ +class Portable +{ +public: + /** + * called each frame when the object has been grabbed. + */ + virtual void grab(MovingObject& object, const Vector& pos) = 0; +}; + +#endif diff --git a/src/object/rock.cpp b/src/object/rock.cpp new file mode 100644 index 000000000..2b45e609d --- /dev/null +++ b/src/object/rock.cpp @@ -0,0 +1,75 @@ +#include + +#include "rock.h" +#include "special/sprite.h" +#include "special/sprite_manager.h" +#include "lisp/writer.h" +#include "video/drawing_context.h" +#include "resources.h" + +Rock::Rock(const lisp::Lisp& reader) +{ + reader.get("x", bbox.p1.x); + reader.get("y", bbox.p1.y); + bbox.set_size(31.8, 31.8); + sprite = sprite_manager->create("rock"); + grabbed = false; + flags |= FLAG_SOLID; +} + +Rock::~Rock() +{ + delete sprite; +} + +void +Rock::write(lisp::Writer& writer) +{ + writer.start_list("rock"); + + writer.write_float("x", bbox.p1.x); + writer.write_float("y", bbox.p1.y); + + writer.end_list("rock"); +} + +void +Rock::draw(DrawingContext& context) +{ + + sprite->draw(context, get_pos(), LAYER_OBJECTS); +} + +void +Rock::action(float elapsed_time) +{ + if(!grabbed) { + flags |= FLAG_SOLID; + flags &= ~FLAG_NO_COLLDET; + movement = physic.get_movement(elapsed_time); + } else { + physic.set_velocity(0, 0); + flags &= ~FLAG_SOLID; + flags |= FLAG_NO_COLLDET; + } + + grabbed = false; +} + +HitResponse +Rock::collision(GameObject& , const CollisionHit& ) +{ + if(grabbed) + return FORCE_MOVE; + + physic.set_velocity(0, 0); + return CONTINUE; +} + +void +Rock::grab(MovingObject& , const Vector& pos) +{ + movement = pos - get_pos(); + grabbed = true; +} + diff --git a/src/object/rock.h b/src/object/rock.h new file mode 100644 index 000000000..12615afce --- /dev/null +++ b/src/object/rock.h @@ -0,0 +1,33 @@ +#ifndef __ROCK_H__ +#define __ROCK_H__ + +#include "special/moving_object.h" +#include "math/physic.h" +#include "lisp/lisp.h" +#include "portable.h" +#include "serializable.h" + +namespace SuperTux { + class Sprite; +} + +class Rock : public MovingObject, public Portable, public Serializable +{ +public: + Rock(const lisp::Lisp& reader); + virtual ~Rock(); + + HitResponse collision(GameObject& other, const CollisionHit& hit); + void action(float elapsed_time); + void draw(DrawingContext& context); + void write(lisp::Writer& writer); + + void grab(MovingObject& object, const Vector& pos); + +private: + bool grabbed; + Sprite* sprite; + Physic physic; +}; + +#endif diff --git a/src/resources.cpp b/src/resources.cpp index 07e0b0471..c5b084246 100644 --- a/src/resources.cpp +++ b/src/resources.cpp @@ -30,14 +30,6 @@ #include "object/gameobjs.h" #include "object/player.h" -Surface* img_waves[3]; -Surface* img_water; -Surface* img_pole; -Surface* img_poletop; -Surface* img_flag[2]; -Surface* img_cloud[2][4]; -Surface* img_distro[4]; - Menu* main_menu = 0; Menu* game_menu = 0; Menu* options_menu = 0; @@ -91,7 +83,6 @@ Font* white_big_text; /* Load graphics/sounds shared between all levels: */ void loadshared() { - /* Load global images: */ gold_text = new Font(datadir + "/images/fonts/gold.png", Font::TEXT, 16,18); blue_text = new Font(datadir + "/images/fonts/blue.png", Font::TEXT, 16,18,3); @@ -121,10 +112,6 @@ void loadshared() tile_manager = new TileManager("/images/tilesets/supertux.stgt"); /* Tuxes: */ - smalltux_star = sprite_manager->create("smalltux-star"); - bigtux_star = sprite_manager->create("bigtux-star"); - smalltux_gameover = sprite_manager->create("smalltux-gameover"); - char img_name[1024]; for (int i = 0; i < GROWING_FRAMES; i++) { @@ -159,96 +146,17 @@ void loadshared() ice_tux->arms = sprite_manager->create("big-tux-arms"); ice_tux->feet = sprite_manager->create("big-tux-feet"); - /* Water: */ - img_water = new Surface(datadir + "/images/shared/water.png", false); - - img_waves[0] = new Surface(datadir + "/images/shared/waves-0.png", - true); - - img_waves[1] = new Surface(datadir + "/images/shared/waves-1.png", - true); - - - img_waves[2] = new Surface(datadir + "/images/shared/waves-2.png", - true); - - - /* Pole: */ - - img_pole = new Surface(datadir + "/images/shared/pole.png", true); - img_poletop = new Surface(datadir + "/images/shared/poletop.png", - true); - - - /* Flag: */ - - img_flag[0] = new Surface(datadir + "/images/shared/flag-0.png", - true); - img_flag[1] = new Surface(datadir + "/images/shared/flag-1.png", - true); - - - /* Cloud: */ - - img_cloud[0][0] = new Surface(datadir + "/images/shared/cloud-00.png", - true); - - img_cloud[0][1] = new Surface(datadir + "/images/shared/cloud-01.png", - true); - - img_cloud[0][2] = new Surface(datadir + "/images/shared/cloud-02.png", - true); - - img_cloud[0][3] = new Surface(datadir + "/images/shared/cloud-03.png", - true); - - - img_cloud[1][0] = new Surface(datadir + "/images/shared/cloud-10.png", - true); - - img_cloud[1][1] = new Surface(datadir + "/images/shared/cloud-11.png", - true); - - img_cloud[1][2] = new Surface(datadir + "/images/shared/cloud-12.png", - true); - - img_cloud[1][3] = new Surface(datadir + "/images/shared/cloud-13.png", - true); - /* Objects */ load_object_gfx(); - /* Distros: */ - img_distro[0] = new Surface(datadir + "/images/tilesets/coin1.png", - true); - - img_distro[1] = new Surface(datadir + "/images/tilesets/coin2.png", - true); - - img_distro[2] = new Surface(datadir + "/images/tilesets/coin3.png", - true); - - img_distro[3] = new Surface(datadir + "/images/tilesets/coin2.png", - true); - - /* Tux life: */ - tux_life = new Surface(datadir + "/images/shared/tux-life.png", true); /* Sound effects: */ - /* if (use_sound) // this will introduce SERIOUS bugs here ! because "load_sound" - // initialize sounds[i] with the correct pointer's value: - // NULL or something else. And it will be dangerous to - // play with not-initialized pointers. - // This is also true with if (use_music) - Send a mail to me: neoneurone@users.sf.net, if you have another opinion. :) - */ for (i = 0; i < NUM_SOUNDS; i++) - SoundManager::get - ()->add_sound(SoundManager::get + SoundManager::get()->add_sound(SoundManager::get ()->load_sound(datadir + soundfilenames[i]),i); /* Herring song */ @@ -261,10 +169,6 @@ void loadshared() /* Free shared data: */ void unloadshared(void) { - delete smalltux_star; - delete bigtux_star; - delete smalltux_gameover; - /* Free global images: */ delete gold_text; delete white_text; @@ -276,22 +180,6 @@ void unloadshared(void) free_object_gfx(); - delete img_water; - for (int i = 0; i < 3; i++) - delete img_waves[i]; - - delete img_pole; - delete img_poletop; - - for (int i = 0; i < 2; i++) - delete img_flag[i]; - - for (int i = 0; i < 4; i++) { - delete img_distro[i]; - delete img_cloud[0][i]; - delete img_cloud[1][i]; - } - delete tux_life; delete small_tux; diff --git a/src/resources.h b/src/resources.h index c152f0cee..dee4ee003 100644 --- a/src/resources.h +++ b/src/resources.h @@ -62,13 +62,6 @@ enum { extern char* soundfilenames[NUM_SOUNDS]; -extern Surface* img_waves[3]; -extern Surface* img_water; -extern Surface* img_pole; -extern Surface* img_poletop; -extern Surface* img_flag[2]; -extern Surface* img_cloud[2][4]; - extern Surface* img_super_bkgd; extern MusicRef herring_song; @@ -96,12 +89,14 @@ extern Font* white_small_text; extern Font* white_big_text; extern Font* yellow_nums; -// maps a virtual resource path to a real path (ie. levels/bla is mapped to -// $DATADIR/levels/bla or $HOME/.supertux/levels/bla) +/** maps a virtual resource path to a real path (ie. levels/bla is mapped to + * $DATADIR/levels/bla or $HOME/.supertux/levels/bla) + * All paths inside the game should be handled in as virtual paths and then + * expanded with this function just before the call to fopen or std::ifstream. + */ std::string get_resource_filename(const std::string& resource); void loadshared(); void unloadshared(); #endif - diff --git a/src/sector.cpp b/src/sector.cpp index 063772e53..d3e751496 100644 --- a/src/sector.cpp +++ b/src/sector.cpp @@ -52,6 +52,7 @@ #include "object/invisible_block.h" #include "object/platform.h" #include "object/bullet.h" +#include "object/rock.h" #include "badguy/jumpy.h" #include "badguy/snowball.h" #include "badguy/bouncing_snowball.h" @@ -149,6 +150,8 @@ Sector::parse_object(const std::string& name, const lisp::Lisp& reader) return new Spiky(reader); } else if(name == "nolok_01") { return new Nolok_01(reader); + } else if(name == "rock") { + return new Rock(reader); } std::cerr << "Unknown object type '" << name << "'.\n";