super-tux-commit Mailing List for Super Tux (Page 13)
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: Matze B. <mat...@us...> - 2004-11-29 16:04:18
|
Update of /cvsroot/super-tux/supertux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18135 Modified Files: TODO Log Message: started work on a collision grid class to speedup collision detection. Doesn't work for moving objects yet, but brings speed in area42 from 5fps back to 100fps on my box (still I get 300-400fps in other levels) Index: TODO =================================================================== RCS file: /cvsroot/super-tux/supertux/TODO,v retrieving revision 1.96 retrieving revision 1.97 diff -u -d -r1.96 -r1.97 --- TODO 29 Nov 2004 00:12:23 -0000 1.96 +++ TODO 29 Nov 2004 16:03:25 -0000 1.97 @@ -117,6 +117,8 @@ - New forest tileset - Badguy sprites - Tux's buttjump animation +[M] after picking up a star the salcon music isn't played anymore, but the + levelmusic restarts. [M] Save score on per-level basis to make high-score [M] Save time on per-level basis to make low-time-score |
From: Matze B. <mat...@us...> - 2004-11-29 16:04:17
|
Update of /cvsroot/super-tux/supertux/lib/special In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18135/lib/special Modified Files: moving_object.h Log Message: started work on a collision grid class to speedup collision detection. Doesn't work for moving objects yet, but brings speed in area42 from 5fps back to 100fps on my box (still I get 300-400fps in other levels) Index: moving_object.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/moving_object.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- moving_object.h 27 Nov 2004 14:42:37 -0000 1.5 +++ moving_object.h 29 Nov 2004 16:03:29 -0000 1.6 @@ -26,6 +26,7 @@ #include "math/rectangle.h" class Sector; +class CollisionGrid; namespace SuperTux { |
From: Matze B. <mat...@us...> - 2004-11-29 15:09:04
|
Update of /cvsroot/super-tux/supertux/data/levels/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1469/data/levels/test Modified Files: bonusblock.stl Log Message: TODO update Index: bonusblock.stl =================================================================== RCS file: /cvsroot/super-tux/supertux/data/levels/test/bonusblock.stl,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- bonusblock.stl 28 Nov 2004 14:56:46 -0000 1.12 +++ bonusblock.stl 29 Nov 2004 15:08:55 -0000 1.13 @@ -9,6 +9,7 @@ (gravity 10.000000) (background (image "arctis.jpg") (speed 0.5)) + (music "supertux-2.ogg") (spawnpoint (name "main") (x 100) |
From: Matze B. <mat...@us...> - 2004-11-29 14:57:41
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31496 Modified Files: supertux.cpp Log Message: forgot to remove exception block Index: supertux.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/supertux.cpp,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- supertux.cpp 29 Nov 2004 00:22:35 -0000 1.36 +++ supertux.cpp 29 Nov 2004 14:57:31 -0000 1.37 @@ -98,8 +98,6 @@ #endif Termination::shutdown(); #ifndef DEBUG // we want to see the backtrace in gdb when in debug mode - } catch (SuperTuxException &e) { - std::cerr << "Unhandled SuperTux exception:\n " << e.what_file() << ":" << e.what_line() << ": " << e.what() << std::endl; } catch (std::exception &e) { std:: cerr << "Unhandled exception: " << e.what() << std::endl; } |
From: Matze B. <mat...@us...> - 2004-11-29 14:54:15
|
Update of /cvsroot/super-tux/supertux/src/object In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30750/object Modified Files: coin.cpp Log Message: update statistics again if coins are collected Index: coin.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/object/coin.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- coin.cpp 24 Nov 2004 23:10:07 -0000 1.3 +++ coin.cpp 29 Nov 2004 14:54:05 -0000 1.4 @@ -8,6 +8,7 @@ #include "sector.h" #include "scene.h" #include "gameobjs.h" +#include "statistics.h" Coin::Coin(const Vector& pos) { @@ -37,6 +38,7 @@ { Sector::current()->player->get_status().incCoins(); Sector::current()->add_object(new BouncyCoin(get_pos())); + global_stats.add_points(COINS_COLLECTED_STAT, 1); remove_me(); } |
From: Matze B. <mat...@us...> - 2004-11-29 14:50:28
|
Update of /cvsroot/super-tux/supertux/lib/app In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30097/lib/app Modified Files: gettext.h Log Message: try to fix ngettext redefined problems Index: gettext.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/app/gettext.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- gettext.h 23 Nov 2004 22:21:46 -0000 1.3 +++ gettext.h 29 Nov 2004 14:50:19 -0000 1.4 @@ -21,7 +21,7 @@ #define _(String) \ SuperTux::dictionary_manager.get_dictionary().translate(String).c_str() -#define ngettext(id, id2, num) \ +#define N_(id, id2, num) \ SuperTux::dictionary_manager.get_dictionary().translate(id, di2, num).c_str() #endif /* _LIBGETTEXT_H */ |
From: Matze B. <mat...@us...> - 2004-11-29 14:46:46
|
Update of /cvsroot/super-tux/supertux/lib/lisp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29130 Modified Files: parser.cpp Log Message: add missing assert include Index: parser.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/lisp/parser.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- parser.cpp 28 Nov 2004 14:57:45 -0000 1.1 +++ parser.cpp 29 Nov 2004 14:46:36 -0000 1.2 @@ -22,6 +22,7 @@ #include <sstream> #include <stdexcept> #include <fstream> +#include <cassert> #include "parser.h" #include "lisp.h" |
From: Matze B. <mat...@us...> - 2004-11-29 00:22:44
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8696 Modified Files: supertux.cpp Log Message: fix for last commit Index: supertux.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/supertux.cpp,v retrieving revision 1.35 retrieving revision 1.36 diff -u -d -r1.35 -r1.36 --- supertux.cpp 28 Nov 2004 14:56:49 -0000 1.35 +++ supertux.cpp 29 Nov 2004 00:22:35 -0000 1.36 @@ -25,7 +25,6 @@ #include <exception> #include <locale.h> -#include "utils/exceptions.h" #include "defines.h" #include "app/globals.h" #include "app/setup.h" |
From: Matze B. <mat...@us...> - 2004-11-29 00:21:21
|
Update of /cvsroot/super-tux/supertux/lib/utils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8466 Removed Files: exceptions.h Log Message: old files --- exceptions.h DELETED --- |
From: Matze B. <mat...@us...> - 2004-11-29 00:16:22
|
Update of /cvsroot/super-tux/supertux/lib/utils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6910 Removed Files: lispreader.cpp lispreader.h lispwriter.cpp lispwriter.h Log Message: old files --- lispwriter.cpp DELETED --- --- lispwriter.h DELETED --- --- lispreader.cpp DELETED --- --- lispreader.h DELETED --- |
From: Matze B. <mat...@us...> - 2004-11-29 00:12:38
|
Update of /cvsroot/super-tux/supertux/src/badguy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6159/src/badguy Modified Files: badguy.cpp bomb.cpp bomb.h bouncing_snowball.cpp bouncing_snowball.h jumpy.cpp jumpy.h mrbomb.cpp mrbomb.h mriceblock.cpp mriceblock.h snowball.cpp snowball.h spiky.cpp spiky.h Log Message: make badguys bounce of each other again, make bombs and kicked mriceblocks kill other enemies, make kicked mriceblock open bonusblocks and destroy bricks Index: badguy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/badguy.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- badguy.cpp 26 Nov 2004 14:45:41 -0000 1.7 +++ badguy.cpp 29 Nov 2004 00:12:24 -0000 1.8 @@ -97,7 +97,7 @@ return collision_solid(other, hit); BadGuy* badguy = dynamic_cast<BadGuy*> (&other); - if(badguy) + if(badguy && badguy->state == STATE_ACTIVE) return collision_badguy(*badguy, hit); Player* player = dynamic_cast<Player*> (&other); Index: snowball.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/snowball.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- snowball.h 28 Nov 2004 14:56:51 -0000 1.4 +++ snowball.h 29 Nov 2004 00:12:24 -0000 1.5 @@ -12,6 +12,7 @@ void activate(); void write(lisp::Writer& writer); HitResponse collision_solid(GameObject& other, const CollisionHit& hit); + HitResponse collision_badguy(BadGuy& other, const CollisionHit& hit); protected: bool collision_squished(Player& player); Index: spiky.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/spiky.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- spiky.h 28 Nov 2004 14:56:51 -0000 1.2 +++ spiky.h 29 Nov 2004 00:12:24 -0000 1.3 @@ -11,6 +11,7 @@ void activate(); void write(lisp::Writer& writer); HitResponse collision_solid(GameObject& other, const CollisionHit& hit); + HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit); }; #endif Index: bomb.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/bomb.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- bomb.h 28 Nov 2004 14:56:50 -0000 1.2 +++ bomb.h 29 Nov 2004 00:12:24 -0000 1.3 @@ -11,6 +11,7 @@ void write(lisp::Writer& writer); HitResponse collision_solid(GameObject& other, const CollisionHit& hit); HitResponse collision_player(Player& player, const CollisionHit& hit); + HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit); void active_action(float elapsed_time); void kill_fall(); Index: mriceblock.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/mriceblock.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- mriceblock.cpp 28 Nov 2004 14:56:51 -0000 1.5 +++ mriceblock.cpp 29 Nov 2004 00:12:24 -0000 1.6 @@ -1,6 +1,7 @@ #include <config.h> #include "mriceblock.h" +#include "object/block.h" static const float WALKSPEED = 80; static const float KICKSPEED = 500; @@ -59,7 +60,7 @@ } HitResponse -MrIceBlock::collision_solid(GameObject& , const CollisionHit& hit) +MrIceBlock::collision_solid(GameObject& object, const CollisionHit& hit) { if(fabsf(hit.normal.y) > .5) { // floor or roof physic.set_velocity_y(0); @@ -72,13 +73,23 @@ sprite->set_action(dir == LEFT ? "left" : "right"); physic.set_velocity_x(-physic.get_velocity_x()); break; - case ICESTATE_KICKED: + case ICESTATE_KICKED: { + BonusBlock* bonusblock = dynamic_cast<BonusBlock*> (&object); + if(bonusblock) { + bonusblock->try_open(); + } + Brick* brick = dynamic_cast<Brick*> (&object); + if(brick) { + brick->try_break(); + } + dir = dir == LEFT ? RIGHT : LEFT; sprite->set_action(dir == LEFT ? "flat-left" : "flat-right"); physic.set_velocity_x(-physic.get_velocity_x()); SoundManager::get()->play_sound(IDToSound(SND_RICOCHET), get_pos(), Sector::current()->player->get_pos()); break; + } case ICESTATE_FLAT: physic.set_velocity_x(0); break; @@ -87,6 +98,29 @@ return CONTINUE; } +HitResponse +MrIceBlock::collision_badguy(BadGuy& badguy, const CollisionHit& hit) +{ + switch(ice_state) { + case ICESTATE_NORMAL: + if(fabsf(hit.normal.x) > .8) { + dir = dir == LEFT ? RIGHT : LEFT; + sprite->set_action(dir == LEFT ? "left" : "right"); + physic.set_velocity_x(-physic.get_velocity_x()); + } + return CONTINUE; + case ICESTATE_FLAT: + return FORCE_MOVE; + case ICESTATE_KICKED: + badguy.kill_fall(); + return FORCE_MOVE; + default: + assert(false); + } + + return ABORT_MOVE; +} + bool MrIceBlock::collision_squished(Player& player) { Index: bouncing_snowball.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/bouncing_snowball.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- bouncing_snowball.h 28 Nov 2004 14:56:50 -0000 1.4 +++ bouncing_snowball.h 29 Nov 2004 00:12:24 -0000 1.5 @@ -12,6 +12,7 @@ void activate(); void write(lisp::Writer& writer); HitResponse collision_solid(GameObject& other, const CollisionHit& hit); + HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit); protected: bool collision_squished(Player& player); Index: jumpy.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/jumpy.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- jumpy.cpp 28 Nov 2004 14:56:51 -0000 1.4 +++ jumpy.cpp 29 Nov 2004 00:12:24 -0000 1.5 @@ -24,15 +24,26 @@ } HitResponse -Jumpy::collision_solid(GameObject& , const CollisionHit& hit) +Jumpy::collision_solid(GameObject& , const CollisionHit& chit) +{ + return hit(chit); +} + +HitResponse +Jumpy::collision_badguy(BadGuy& , const CollisionHit& chit) +{ + return hit(chit); +} + +HitResponse +Jumpy::hit(const CollisionHit& chit) { // hit floor? - if(hit.normal.y < -.5) { + if(chit.normal.y < -.5) { physic.set_velocity_y(JUMPSPEED); - } else if(hit.normal.y < .5) { // bumped on roof + } else if(chit.normal.y < .5) { // bumped on roof physic.set_velocity_y(0); } return CONTINUE; } - Index: jumpy.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/jumpy.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- jumpy.h 28 Nov 2004 14:56:51 -0000 1.2 +++ jumpy.h 29 Nov 2004 00:12:24 -0000 1.3 @@ -8,10 +8,13 @@ public: Jumpy(const lisp::Lisp& reader); - virtual HitResponse collision_solid(GameObject& other, - const CollisionHit& hit); + HitResponse collision_solid(GameObject& other, const CollisionHit& hit); + HitResponse collision_badguy(BadGuy& other, const CollisionHit& hit); - virtual void write(lisp::Writer& writer); + void write(lisp::Writer& writer); + +private: + HitResponse hit(const CollisionHit& hit); }; #endif Index: bouncing_snowball.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/bouncing_snowball.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- bouncing_snowball.cpp 28 Nov 2004 14:56:50 -0000 1.6 +++ bouncing_snowball.cpp 29 Nov 2004 00:12:24 -0000 1.7 @@ -67,3 +67,17 @@ return CONTINUE; } +HitResponse +BouncingSnowball::collision_badguy(BadGuy& , const CollisionHit& hit) +{ + if(fabsf(hit.normal.x) > .8) { // left/right? + dir = dir == LEFT ? RIGHT : LEFT; + sprite->set_action(dir == LEFT ? "left" : "right"); + physic.set_velocity_x(-physic.get_velocity_x()); + } else if(hit.normal.y < -.8) { // grounf + physic.set_velocity_y(JUMPSPEED); + } + + return CONTINUE; +} + Index: spiky.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/spiky.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- spiky.cpp 28 Nov 2004 14:56:51 -0000 1.4 +++ spiky.cpp 29 Nov 2004 00:12:24 -0000 1.5 @@ -44,3 +44,15 @@ return CONTINUE; } +HitResponse +Spiky::collision_badguy(BadGuy& , const CollisionHit& hit) +{ + if(fabsf(hit.normal.x) > .8) { // left or right + dir = dir == LEFT ? RIGHT : LEFT; + sprite->set_action(dir == LEFT ? "left" : "right"); + physic.set_velocity_x(-physic.get_velocity_x()); + } + + return CONTINUE; +} + Index: mriceblock.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/mriceblock.h,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- mriceblock.h 28 Nov 2004 14:56:51 -0000 1.3 +++ mriceblock.h 29 Nov 2004 00:12:24 -0000 1.4 @@ -11,7 +11,8 @@ void activate(); void write(lisp::Writer& writer); - HitResponse collision_solid(GameObject& other, const CollisionHit& hit); + HitResponse collision_solid(GameObject& object, const CollisionHit& hit); + HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit); void active_action(float elapsed_time); Index: mrbomb.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/mrbomb.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- mrbomb.cpp 28 Nov 2004 14:56:51 -0000 1.7 +++ mrbomb.cpp 29 Nov 2004 00:12:24 -0000 1.8 @@ -66,3 +66,14 @@ return CONTINUE; } +HitResponse +MrBomb::collision_badguy(BadGuy& , const CollisionHit& hit) +{ + if(fabsf(hit.normal.x) > .8) { // left or right + dir = dir == LEFT ? RIGHT : LEFT; + sprite->set_action(dir == LEFT ? "left" : "right"); + physic.set_velocity_x(-physic.get_velocity_x()); + } + + return CONTINUE; +} Index: snowball.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/snowball.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- snowball.cpp 28 Nov 2004 14:56:51 -0000 1.6 +++ snowball.cpp 29 Nov 2004 00:12:24 -0000 1.7 @@ -64,3 +64,15 @@ return CONTINUE; } +HitResponse +SnowBall::collision_badguy(BadGuy& , const CollisionHit& hit) +{ + if(fabsf(hit.normal.x) > .8) { // left or right hit + dir = dir == LEFT ? RIGHT : LEFT; + sprite->set_action(dir == LEFT ? "left" : "right"); + physic.set_velocity_x(-physic.get_velocity_x()); + } + + return CONTINUE; +} + Index: bomb.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/bomb.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- bomb.cpp 28 Nov 2004 14:56:50 -0000 1.4 +++ bomb.cpp 29 Nov 2004 00:12:24 -0000 1.5 @@ -41,6 +41,13 @@ return ABORT_MOVE; } +HitResponse +Bomb::collision_badguy(BadGuy& badguy, const CollisionHit& ) +{ + badguy.kill_fall(); + return ABORT_MOVE; +} + void Bomb::active_action(float ) { Index: mrbomb.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/badguy/mrbomb.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- mrbomb.h 28 Nov 2004 14:56:51 -0000 1.4 +++ mrbomb.h 29 Nov 2004 00:12:24 -0000 1.5 @@ -12,6 +12,7 @@ void activate(); void write(lisp::Writer& writer); HitResponse collision_solid(GameObject& other, const CollisionHit& hit); + HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit); protected: bool collision_squished(Player& player); |
From: Matze B. <mat...@us...> - 2004-11-29 00:12:35
|
Update of /cvsroot/super-tux/supertux/src/object In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6159/src/object Modified Files: block.cpp block.h Log Message: make badguys bounce of each other again, make bombs and kicked mriceblocks kill other enemies, make kicked mriceblock open bonusblocks and destroy bricks Index: block.h =================================================================== RCS file: /cvsroot/super-tux/supertux/src/object/block.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- block.h 22 Nov 2004 23:47:51 -0000 1.2 +++ block.h 29 Nov 2004 00:12:25 -0000 1.3 @@ -36,6 +36,8 @@ public: BonusBlock(const Vector& pos, int data); + void try_open(); + protected: virtual void hit(Player& player); @@ -48,6 +50,8 @@ public: Brick(const Vector& pos, int data); + void try_break(bool playerhit = false); + protected: virtual void hit(Player& player); Index: block.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/object/block.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- block.cpp 24 Nov 2004 23:10:05 -0000 1.6 +++ block.cpp 29 Nov 2004 00:12:25 -0000 1.7 @@ -101,7 +101,13 @@ } void -BonusBlock::hit(Player& player) +BonusBlock::hit(Player& ) +{ + try_open(); +} + +void +BonusBlock::try_open() { if(sprite->get_action_name() == "empty") { SoundManager::get()->play_sound(IDToSound(SND_BRICK)); @@ -109,6 +115,7 @@ } Sector* sector = Sector::current(); + Player& player = *(sector->player); switch(data) { case 1: // coin Sector::current()->add_object(new BouncyCoin(get_pos())); @@ -170,13 +177,23 @@ } void -Brick::hit(Player& player) +Brick::hit(Player& ) +{ + if(sprite->get_action_name() == "empty") + return; + + try_break(true); +} + +void +Brick::try_break(bool playerhit) { if(sprite->get_action_name() == "empty") return; SoundManager::get()->play_sound(IDToSound(SND_BRICK)); Sector* sector = Sector::current(); + Player& player = *(sector->player); if(coin_counter > 0) { sector->add_object(new BouncyCoin(get_pos())); coin_counter--; @@ -185,7 +202,7 @@ sprite->set_action("empty"); start_bounce(); } else if(breakable) { - if(player.size == SMALL) { + if(playerhit && player.size == SMALL) { start_bounce(); return; } |
From: Matze B. <mat...@us...> - 2004-11-29 00:12:32
|
Update of /cvsroot/super-tux/supertux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6159 Modified Files: TODO Log Message: make badguys bounce of each other again, make bombs and kicked mriceblocks kill other enemies, make kicked mriceblock open bonusblocks and destroy bricks Index: TODO =================================================================== RCS file: /cvsroot/super-tux/supertux/TODO,v retrieving revision 1.95 retrieving revision 1.96 diff -u -d -r1.95 -r1.96 --- TODO 28 Nov 2004 14:56:46 -0000 1.95 +++ TODO 29 Nov 2004 00:12:23 -0000 1.96 @@ -45,8 +45,6 @@ - implement wingling - implement tree (really?) - bring back stay on platform flag - - make enemies bounce of upon each other again - - make enemies fall again - ok ** implement ability to cary mriceblock (and other objects) around - delayed for after big commit... * smoke clouds are too fast |
From: Matze B. <mat...@us...> - 2004-11-28 17:20:24
|
Update of /cvsroot/super-tux/supertux/lib/special In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10294/lib/special Modified Files: sprite_manager.cpp Log Message: remove debug printf Index: sprite_manager.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/sprite_manager.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- sprite_manager.cpp 28 Nov 2004 14:56:48 -0000 1.6 +++ sprite_manager.cpp 28 Nov 2004 17:20:12 -0000 1.7 @@ -60,7 +60,6 @@ if(iter.item() == "sprite") { SpriteData* spritedata = new SpriteData(iter.lisp()); - printf("Spr: %s.\n", spritedata->get_name().c_str()); Sprites::iterator i = sprites.find(spritedata->get_name()); if (i == sprites.end()) { sprites[spritedata->get_name()] = spritedata; |
From: Matze B. <mat...@us...> - 2004-11-28 17:19:38
|
Update of /cvsroot/super-tux/supertux/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10031/src Modified Files: sector.cpp Log Message: remove invisible tile object as it's not needed Index: sector.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/src/sector.cpp,v retrieving revision 1.55 retrieving revision 1.56 diff -u -d -r1.55 -r1.56 --- sector.cpp 28 Nov 2004 14:56:49 -0000 1.55 +++ sector.cpp 28 Nov 2004 17:19:25 -0000 1.56 @@ -48,7 +48,6 @@ #include "object/coin.h" #include "object/block.h" #include "object/invisible_block.h" -#include "object/invisible_tile.h" #include "object/platform.h" #include "object/bullet.h" #include "badguy/jumpy.h" @@ -329,9 +328,6 @@ if(tile->getID() == 112) { add_object(new InvisibleBlock(pos)); solids->change(x, y, 0); - } else if(tile->getID() == 1311) { - add_object(new InvisibleTile(pos)); - solids->change(x, y, 0); } else if(tile->getID() == 295) { add_object(new Spike(pos, Spike::NORTH)); solids->change(x, y, 0); |
From: Matze B. <mat...@us...> - 2004-11-28 17:19:36
|
Update of /cvsroot/super-tux/supertux/src/object In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10031/src/object Removed Files: invisible_tile.cpp invisible_tile.h Log Message: remove invisible tile object as it's not needed --- invisible_tile.h DELETED --- --- invisible_tile.cpp DELETED --- |
From: Ingo R. <gr...@us...> - 2004-11-28 15:40:55
|
Update of /cvsroot/super-tux/supertux/data/images/tilesets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22123 Modified Files: supertux.stgt Log Message: added paralax snow group Index: supertux.stgt =================================================================== RCS file: /cvsroot/super-tux/supertux/data/images/tilesets/supertux.stgt,v retrieving revision 1.65 retrieving revision 1.66 diff -u -d -r1.65 -r1.66 --- supertux.stgt 28 Nov 2004 15:23:51 -0000 1.65 +++ supertux.stgt 28 Nov 2004 15:40:44 -0000 1.66 @@ -4,6 +4,16 @@ (name "Snow") (tiles 7 8 9 202 13 14 15 204 10 11 12 206 16 17 18 205 22 21 19 203 23 20 207 208 31 30 114 113 115 116 122 123 117 118 124 125 33 32 34 209 35 37 39 210 38 36 43 0 40 41 42 0 119 121 120 0) ) + +(tilegroup + (name "Snow (Paralax Background)") + (tiles 149 160 151 158 + 152 153 154 159 + 155 156 157 0 + 161 162 163 170 + 164 165 166 171 + 167 168 169 0 )) + (tilegroup (name "Forest (Foreground)") (tiles 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 0 1060 1061 0 1063 1064 1065 1066 1067 1068 1069 1070 1045 1046 1051 1052 1047 1048 1053 1054 1049 1050 1055 1056 1042 1043 1057 1058 1034 1035 1029 1030 1041 1040 1031 1032 1036 1037 0 1038 1020 1021 1022 1044 1023 1024 1025 1033 1026 1027 1028 1039) |
From: Matze B. <mat...@us...> - 2004-11-28 15:24:05
|
Update of /cvsroot/super-tux/supertux/data/images/tilesets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18643/data/images/tilesets Modified Files: supertux.stgt Log Message: restore old tilesets Index: supertux.stgt =================================================================== RCS file: /cvsroot/super-tux/supertux/data/images/tilesets/supertux.stgt,v retrieving revision 1.64 retrieving revision 1.65 diff -u -d -r1.64 -r1.65 --- supertux.stgt 28 Nov 2004 04:55:42 -0000 1.64 +++ supertux.stgt 28 Nov 2004 15:23:51 -0000 1.65 @@ -2,15 +2,15 @@ (supertux-tiles (tilegroup (name "Snow") - (tiles 7 8 9 202 13 14 15 204 10 11 12 206 16 17 18 205 22 21 19 203 23 20 207 208 31 30 114 113 115 116 122 123 117 118 124 125 33 32 34 209 35 37 39 210 38 36 43 0 40 41 42 119 121 120) + (tiles 7 8 9 202 13 14 15 204 10 11 12 206 16 17 18 205 22 21 19 203 23 20 207 208 31 30 114 113 115 116 122 123 117 118 124 125 33 32 34 209 35 37 39 210 38 36 43 0 40 41 42 0 119 121 120 0) ) (tilegroup (name "Forest (Foreground)") - (tiles 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 0 1060 1061 1063 1064 1065 1066 1067 1068 1069 1070 1045 1046 1051 1052 1047 1048 1053 1054 1049 1050 1055 1056 1042 1043 1057 1058 1034 1035 1029 1030 1041 1040 1031 1032 1036 1037 1038 1020 1021 1022 1044 1023 1024 1025 1033 1026 1027 1028 1039) + (tiles 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 0 1060 1061 0 1063 1064 1065 1066 1067 1068 1069 1070 1045 1046 1051 1052 1047 1048 1053 1054 1049 1050 1055 1056 1042 1043 1057 1058 1034 1035 1029 1030 1041 1040 1031 1032 1036 1037 0 1038 1020 1021 1022 1044 1023 1024 1025 1033 1026 1027 1028 1039) ) (tilegroup (name "Forest (Background)") - (tiles 0 1073 1074 1081 1082 1088 1089 1090 1095 1096 1097 1098 1103 1104 1105 1106 1111 1112 1113 1114 1119 1120 1121 1122 1127 1128 1129 1130 1137 1138 1145 1146 1153 1154 1161 1162 1075 1083 1084 1091 1092 1099 1100 1101 1107 1108 1109 1110 1115 1116 1117 1118 1123 1124 1125 1126 1131 1132 1133 1134 1139 1140 1141 1147 1148 1155 1156 1163 1164 1168 1169 1170 1174 1175 1176 1179 1180 1181 1182 1185 1186 1187 1188 1191 1192 1193 1194 1197 1198 1199 1200 1203 1204 1205 1206 1209 1210 1211 1212 1177 1219 1220 1183 1225 1226 1189 1190 1217 1218 1195 1223 1224 1201 1229 1230 1235 1236 1202 1207 1213 1214 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1303 1304 1289 1290 1305 1306 1291 1292 1307 1308 1293 1294 1309 1310 1295 1296 1297 1298 1299 1300 1301 1302 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457) + (tiles 0 0 1073 1074 0 0 1081 1082 0 1088 1089 1090 1095 1096 1097 1098 1103 1104 1105 1106 1111 1112 1113 1114 1119 1120 1121 1122 1127 1128 1129 1130 0 0 1137 1138 0 0 1145 1146 0 0 1153 1154 0 0 1161 1162 1075 0 0 0 1083 1084 0 0 1091 1092 0 0 1099 1100 1101 0 1107 1108 1109 1110 1115 1116 1117 1118 1123 1124 1125 1126 1131 1132 1133 1134 1139 1140 1141 0 1147 1148 0 0 1155 1156 0 0 1163 1164 0 0 0 1168 1169 1170 0 1174 1175 1176 1179 1180 1181 1182 1185 1186 1187 1188 1191 1192 1193 1194 1197 1198 1199 1200 1191 1192 1193 1194 1197 1198 1199 1200 1203 1204 1205 1206 1209 1210 1211 1212 1177 0 1219 1220 1183 0 1225 1226 1189 1190 1217 1218 1195 0 1223 1224 1201 1190 1229 1230 1195 0 1235 1236 1201 1202 0 0 1207 0 0 0 1213 1214 0 0 0 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1303 1304 1289 1290 1305 1306 1291 1292 1307 1308 1293 1294 1309 1310 1295 1296 0 0 1297 1298 0 0 1299 1300 0 0 1301 1302 0 0 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457) ) (tilegroup (name "Block") @@ -30,7 +30,7 @@ ) (tilegroup (name "Pipe") - (tiles 53 55 0 54 56 57 58 59 60) + (tiles 53 55 0 0 54 56 0 0 57 58 0 0 59 60 0 0) ) (tilegroup (name "Grey") @@ -46,7 +46,7 @@ ) (tilegroup (name "Jungle") - (tiles 301 302 303 312 304 305 306 0 307 308 309 310 311) + (tiles 301 302 303 312 304 305 306 0 307 308 309 0 310 311 0 0) ) (tilegroup (name "Slopes") @@ -1136,65 +1136,150 @@ ) (solid #t) ) - - (tile (id 149) - (images (region "snow-para-1.png" 0 0 32 32))) - (tile (id 150) - (images (region "snow-para-1.png" 32 0 32 32))) - (tile (id 151) - (images (region "snow-para-1.png" 64 0 32 32))) - - (tile (id 152) - (images (region "snow-para-1.png" 0 32 32 32))) - (tile (id 153) - (images (region "snow-para-1.png" 32 32 32 32))) - (tile (id 154) - (images (region "snow-para-1.png" 64 32 32 32))) - - (tile (id 155) - (images (region "snow-para-1.png" 0 64 32 32))) - (tile (id 156) - (images (region "snow-para-1.png" 32 64 32 32))) - (tile (id 157) - (images (region "snow-para-1.png" 64 64 32 32))) - - (tile (id 158) - (images (region "snow-para-1.png" 96 0 32 32))) - (tile (id 159) - (images (region "snow-para-1.png" 96 32 32 32))) - (tile (id 160) - (images (region "snow-para-1.png" 96 64 32 32))) - - - (tile (id 161) - (images (region "snow-para-2.png" 0 0 32 32))) - (tile (id 162) - (images (region "snow-para-2.png" 32 0 32 32))) - (tile (id 163) - (images (region "snow-para-2.png" 64 0 32 32))) - - (tile (id 164) - (images (region "snow-para-2.png" 0 32 32 32))) - (tile (id 165) - (images (region "snow-para-2.png" 32 32 32 32))) - (tile (id 166) - (images (region "snow-para-2.png" 64 32 32 32))) - - (tile (id 167) - (images (region "snow-para-2.png" 0 64 32 32))) - (tile (id 168) - (images (region "snow-para-2.png" 32 64 32 32))) - (tile (id 169) - (images (region "snow-para-2.png" 64 64 32 32))) - - (tile (id 170) - (images (region "snow-para-2.png" 96 0 32 32))) - (tile (id 171) - (images (region "snow-para-2.png" 96 32 32 32))) - (tile (id 172) - (images (region "snow-para-2.png" 96 64 32 32))) - - + (tile + (id 149) + (images + (region "snow-para-1.png" 0 0 32 32) + ) + ) + (tile + (id 150) + (images + (region "snow-para-1.png" 32 0 32 32) + ) + ) + (tile + (id 151) + (images + (region "snow-para-1.png" 64 0 32 32) + ) + ) + (tile + (id 152) + (images + (region "snow-para-1.png" 0 32 32 32) + ) + ) + (tile + (id 153) + (images + (region "snow-para-1.png" 32 32 32 32) + ) + ) + (tile + (id 154) + (images + (region "snow-para-1.png" 64 32 32 32) + ) + ) + (tile + (id 155) + (images + (region "snow-para-1.png" 0 64 32 32) + ) + ) + (tile + (id 156) + (images + (region "snow-para-1.png" 32 64 32 32) + ) + ) + (tile + (id 157) + (images + (region "snow-para-1.png" 64 64 32 32) + ) + ) + (tile + (id 158) + (images + (region "snow-para-1.png" 96 0 32 32) + ) + ) + (tile + (id 159) + (images + (region "snow-para-1.png" 96 32 32 32) + ) + ) + (tile + (id 160) + (images + (region "snow-para-1.png" 96 64 32 32) + ) + ) + (tile + (id 161) + (images + (region "snow-para-2.png" 0 0 32 32) + ) + ) + (tile + (id 162) + (images + (region "snow-para-2.png" 32 0 32 32) + ) + ) + (tile + (id 163) + (images + (region "snow-para-2.png" 64 0 32 32) + ) + ) + (tile + (id 164) + (images + (region "snow-para-2.png" 0 32 32 32) + ) + ) + (tile + (id 165) + (images + (region "snow-para-2.png" 32 32 32 32) + ) + ) + (tile + (id 166) + (images + (region "snow-para-2.png" 64 32 32 32) + ) + ) + (tile + (id 167) + (images + (region "snow-para-2.png" 0 64 32 32) + ) + ) + (tile + (id 168) + (images + (region "snow-para-2.png" 32 64 32 32) + ) + ) + (tile + (id 169) + (images + (region "snow-para-2.png" 64 64 32 32) + ) + ) + (tile + (id 170) + (images + (region "snow-para-2.png" 96 0 32 32) + ) + ) + (tile + (id 171) + (images + (region "snow-para-2.png" 96 32 32 32) + ) + ) + (tile + (id 172) + (images + (region "snow-para-2.png" 96 64 32 32) + ) + ) (tile (id 173) (images |
From: Matze B. <mat...@us...> - 2004-11-28 15:18:03
|
Update of /cvsroot/super-tux/supertux/contrib/tilemanager In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17607 Modified Files: TileSet.cs Log Message: tilegroups are not sets but should be used in a 4-column grid it seems... Index: TileSet.cs =================================================================== RCS file: /cvsroot/super-tux/supertux/contrib/tilemanager/TileSet.cs,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- TileSet.cs 23 Nov 2004 16:47:23 -0000 1.3 +++ TileSet.cs 28 Nov 2004 15:17:50 -0000 1.4 @@ -30,8 +30,7 @@ break; case "tiles": do { - if(!Tiles.Contains(parser.IntegerValue)) - Tiles.Add(parser.IntegerValue); + Tiles.Add(parser.IntegerValue); } while(parser.Parse() && parser.Type == Parser.LispType.INTEGER); break; |
Update of /cvsroot/super-tux/supertux/lib/lisp In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13781/lib/lisp Added Files: lexer.cpp lexer.h lisp.cpp lisp.h list_iterator.cpp list_iterator.h parser.cpp parser.h writer.cpp writer.h Log Message: move over rewritten lispreader from tuxkart (with additional fixes), generalized TileManager and Tile classes and use them for the worldmap too --- NEW FILE: lisp.h --- // $Id: lisp.h,v 1.1 2004/11/28 14:57:45 matzebraun Exp $ // // TuxKart - a fun racing game with go-kart // Copyright (C) 2004 Matthias Braun <ma...@br...> // code in this file based on lispreader from Mark Probst // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef __LISPREADER_H__ #define __LISPREADER_H__ #include <string> #include <vector> namespace lisp { class Lisp { public: ~Lisp(); enum LispType { TYPE_CONS, TYPE_SYMBOL, TYPE_INTEGER, TYPE_STRING, TYPE_REAL, TYPE_BOOLEAN }; LispType get_type() const { return type; } Lisp* get_car() const { return v.cons.car; } Lisp* get_cdr() const { return v.cons.cdr; } bool get(std::string& val) const { if(type != TYPE_STRING && type != TYPE_SYMBOL) return false; val = v.string; return true; } bool get(unsigned int& val) const { if(type != TYPE_INTEGER) return false; val = v.integer; return true; } bool get(int& val) const { if(type != TYPE_INTEGER) return false; val = v.integer; return true; } bool get(float& val) const { if(type != TYPE_REAL) { if(type == TYPE_INTEGER) { val = v.integer; return true; } return false; } val = v.real; return true; } bool get(bool& val) const { if(type != TYPE_BOOLEAN) return false; val = v.boolean; return true; } /* conveniance functions which traverse the list until a child with a * specified name is found. The value part is then interpreted in a specific * way. The functions return true, if a child was found and could be * interpreted correctly, otherwise false is returned and the variable value * is not changed. * (Please note that searching the lisp structure is O(n) so these functions * are no good idea for performance critical areas) */ template<class T> bool get(const char* name, T& val) const { const Lisp* lisp = get_lisp(name); if(!lisp) return false; if(lisp->get_type() != TYPE_CONS) return false; lisp = lisp->get_car(); if(!lisp) return false; return lisp->get(val); } template<class T> bool get_vector(const char* name, std::vector<T>& vec) const { vec.clear(); const Lisp* child = get_lisp(name); if(!child) return false; for( ; child != 0; child = child->get_cdr()) { T val; if(!child->get_car()) continue; if(child->get_car()->get(val)) { vec.push_back(val); } } return true; } Lisp* get_lisp(const char* name) const; Lisp* get_lisp(const std::string& name) const { return get_lisp(name.c_str()); } // for debugging void print(int indent = 0) const; private: friend class Parser; Lisp(LispType newtype); LispType type; union { struct { Lisp* car; Lisp* cdr; } cons; char* string; int integer; bool boolean; float real; } v; }; } // end of namespace lisp #endif --- NEW FILE: list_iterator.cpp --- #include <config.h> #include "list_iterator.h" #include <stdexcept> namespace lisp { ListIterator::ListIterator(const lisp::Lisp* newlisp) : current_lisp(0), cur(newlisp) { } bool ListIterator::next() { if(cur == 0) return false; const lisp::Lisp* child = cur->get_car(); if(!child) throw new std::runtime_error("child is 0 in list entry"); if(child->get_type() != lisp::Lisp::TYPE_CONS) throw new std::runtime_error("Expected CONS"); const lisp::Lisp* name = child->get_car(); if(!name || name->get_type() != lisp::Lisp::TYPE_SYMBOL) throw new std::runtime_error("Expected symbol"); name->get(current_item); current_lisp = child->get_cdr(); cur = cur->get_cdr(); return true; } } --- NEW FILE: writer.cpp --- // $Id: writer.cpp,v 1.1 2004/11/28 14:57:45 matzebraun Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2004 Matthias Braun <ma...@br... // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <config.h> #include <iostream> #include "writer.h" namespace lisp { Writer::Writer(std::ostream& newout) : out(newout), indent_depth(0) { } Writer::~Writer() { if(lists.size() > 0) { std::cerr << "Warning: Not all sections closed in lispwriter!\n"; } } void Writer::write_comment(const std::string& comment) { out << "; " << comment << "\n"; } void Writer::start_list(const std::string& listname) { indent(); out << '(' << listname << '\n'; indent_depth += 2; lists.push_back(listname); } void Writer::end_list(const std::string& listname) { if(lists.size() == 0) { std::cerr << "Trying to close list '" << listname << "', which is not open.\n"; return; } if(lists.back() != listname) { std::cerr << "Warning: trying to close list '" << listname << "' while list '" << lists.back() << "' is open.\n"; return; } lists.pop_back(); indent_depth -= 2; indent(); out << ")\n"; } void Writer::write_int(const std::string& name, int value) { indent(); out << '(' << name << ' ' << value << ")\n"; } void Writer::write_float(const std::string& name, float value) { indent(); out << '(' << name << ' ' << value << ")\n"; } void Writer::write_string(const std::string& name, const std::string& value) { indent(); out << '(' << name << " \"" << value << "\")\n"; } void Writer::write_bool(const std::string& name, bool value) { indent(); out << '(' << name << ' ' << (value ? "#t" : "#f") << ")\n"; } void Writer::write_int_vector(const std::string& name, const std::vector<int>& value) { indent(); out << '(' << name; for(std::vector<int>::const_iterator i = value.begin(); i != value.end(); ++i) out << " " << *i; out << ")\n"; } void Writer::write_int_vector(const std::string& name, const std::vector<unsigned int>& value) { indent(); out << '(' << name; for(std::vector<unsigned int>::const_iterator i = value.begin(); i != value.end(); ++i) out << " " << *i; out << ")\n"; } void Writer::indent() { for(int i = 0; i<indent_depth; ++i) out << ' '; } } // end of namespace lisp --- NEW FILE: parser.h --- // $Id: parser.h,v 1.1 2004/11/28 14:57:45 matzebraun Exp $ // // TuxKart - a fun racing game with go-kart // Copyright (C) 2004 Matthias Braun <ma...@br...> // code in this file based on lispreader from Mark Probst // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef __LISPPARSER_H__ #define __LISPPARSER_H__ #include <string> #include "lexer.h" namespace lisp { class Lisp; class Parser { public: Parser(); ~Parser(); Lisp* parse(const std::string& filename); Lisp* parse(std::istream& stream); private: Lisp* read(); Lexer* lexer; Lexer::TokenType token; }; } // end of namespace lisp #endif --- NEW FILE: list_iterator.h --- #ifndef __LISP_ITERATOR_H__ #define __LISP_ITERATOR_H__ #include "lisp/lisp.h" namespace lisp { /** * Small and a bit hacky helper class that helps parsing lisp lists where all * entries are lists again themselves */ class ListIterator { public: ListIterator(const lisp::Lisp* cur); const std::string& item() const { return current_item; } lisp::Lisp* lisp() const { return current_lisp; } lisp::Lisp* value() const { return current_lisp->get_car(); } bool next(); private: std::string current_item; lisp::Lisp* current_lisp; const lisp::Lisp* cur; }; } #endif --- NEW FILE: lexer.h --- // $Id: lexer.h,v 1.1 2004/11/28 14:57:45 matzebraun Exp $ // // Copyright (C) 2004 Matthias Braun <ma...@br...> // code in this file based on lispreader from Mark Probst // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef __LISPLEXER_H__ #define __LISPLEXER_H__ namespace lisp { class Lexer { public: enum TokenType { TOKEN_EOF, TOKEN_OPEN_PAREN, TOKEN_CLOSE_PAREN, TOKEN_SYMBOL, TOKEN_STRING, TOKEN_INTEGER, TOKEN_REAL, TOKEN_TRUE, TOKEN_FALSE }; Lexer(std::istream& stream); ~Lexer(); TokenType getNextToken(); const char* getString() const { return token_string; } int getLineNumber() const { return linenumber; } private: enum { MAX_TOKEN_LENGTH = 16384, BUFFER_SIZE = 1024 }; inline void nextChar(); std::istream& stream; bool eof; int linenumber; char buffer[BUFFER_SIZE+1]; char* bufend; char* c; char token_string[MAX_TOKEN_LENGTH + 1]; int token_length; }; } // end of namespace lisp #endif --- NEW FILE: writer.h --- // $Id: writer.h,v 1.1 2004/11/28 14:57:45 matzebraun Exp $ // // SuperTux - A Jump'n Run // Copyright (C) 2004 Matthias Braun <ma...@br... // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef SUPERTUX_LISPWRITER_H #define SUPERTUX_LISPWRITER_H #include <iostream> #include <string> #include <vector> namespace lisp { class Writer { public: Writer(std::ostream& out); ~Writer(); void write_comment(const std::string& comment); void start_list(const std::string& listname); void write_int(const std::string& name, int value); void write_float(const std::string& name, float value); void write_string(const std::string& name, const std::string& value); void write_bool(const std::string& name, bool value); void write_int_vector(const std::string& name, const std::vector<int>& value); void write_int_vector(const std::string& name, const std::vector<unsigned int>& value); // add more write-functions when needed... void end_list(const std::string& listname); private: void indent(); std::ostream& out; int indent_depth; std::vector<std::string> lists; }; } //namespace lisp #endif //SUPERTUX_LISPWRITER_H --- NEW FILE: parser.cpp --- // $Id: parser.cpp,v 1.1 2004/11/28 14:57:45 matzebraun Exp $ // // TuxKart - a fun racing game with go-kart // Copyright (C) 2004 Matthias Braun <ma...@br...> // code in this file based on lispreader from Mark Probst // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <config.h> #include <sstream> #include <stdexcept> #include <fstream> #include "parser.h" #include "lisp.h" namespace lisp { Parser::Parser() : lexer(0) { } Parser::~Parser() { delete lexer; } Lisp* Parser::parse(const std::string& filename) { std::ifstream in(filename.c_str()); if(!in.good()) { std::stringstream msg; msg << "Parser problem: Couldn't open file '" << filename << "'."; throw std::runtime_error(msg.str()); } return parse(in); } Lisp* Parser::parse(std::istream& stream) { delete lexer; lexer = new Lexer(stream); token = lexer->getNextToken(); Lisp* result = new Lisp(Lisp::TYPE_CONS); result->v.cons.car = read(); result->v.cons.cdr = 0; delete lexer; lexer = 0; return result; } Lisp* Parser::read() { Lisp* result; switch(token) { case Lexer::TOKEN_EOF: { std::stringstream msg; msg << "Parse Error at line " << lexer->getLineNumber() << ": " << "Unexpected EOF."; throw std::runtime_error(msg.str()); } case Lexer::TOKEN_CLOSE_PAREN: { std::stringstream msg; msg << "Parse Error at line " << lexer->getLineNumber() << ": " << "Unexpected ')'."; throw std::runtime_error(msg.str()); } case Lexer::TOKEN_OPEN_PAREN: { result = new Lisp(Lisp::TYPE_CONS); token = lexer->getNextToken(); if(token == Lexer::TOKEN_CLOSE_PAREN) { result->v.cons.car = 0; result->v.cons.cdr = 0; break; } Lisp* cur = result; do { cur->v.cons.car = read(); if(token == Lexer::TOKEN_CLOSE_PAREN) { cur->v.cons.cdr = 0; break; } cur->v.cons.cdr = new Lisp(Lisp::TYPE_CONS); cur = cur->v.cons.cdr; } while(1); break; } case Lexer::TOKEN_SYMBOL: { result = new Lisp(Lisp::TYPE_SYMBOL); size_t len = strlen(lexer->getString()) + 1; result->v.string = new char[len]; memcpy(result->v.string, lexer->getString(), len); break; } case Lexer::TOKEN_STRING: { result = new Lisp(Lisp::TYPE_STRING); size_t len = strlen(lexer->getString()) + 1; result->v.string = new char[len]; memcpy(result->v.string, lexer->getString(), len); break; } case Lexer::TOKEN_INTEGER: result = new Lisp(Lisp::TYPE_INTEGER); sscanf(lexer->getString(), "%d", &result->v.integer); break; case Lexer::TOKEN_REAL: result = new Lisp(Lisp::TYPE_REAL); sscanf(lexer->getString(), "%f", &result->v.real); break; case Lexer::TOKEN_TRUE: result = new Lisp(Lisp::TYPE_BOOLEAN); result->v.boolean = true; break; case Lexer::TOKEN_FALSE: result = new Lisp(Lisp::TYPE_BOOLEAN); result->v.boolean = false; break; default: // this should never happen assert(false); } token = lexer->getNextToken(); return result; } } // end of namespace lisp --- NEW FILE: lexer.cpp --- // $Id: lexer.cpp,v 1.1 2004/11/28 14:57:45 matzebraun Exp $ // // Copyright (C) 2004 Matthias Braun <ma...@br...> // code in this file based on lispreader from Mark Probst // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <config.h> #include <sstream> #include <stdexcept> #include "lexer.h" namespace lisp { class EOFException { }; Lexer::Lexer(std::istream& newstream) : stream(newstream), eof(false), linenumber(0) { try { // trigger a refill of the buffer c = 0; bufend = c + 1; nextChar(); } catch(EOFException& e) { } } Lexer::~Lexer() { } void Lexer::nextChar() { ++c; if(c >= bufend) { if(eof) throw EOFException(); std::streamsize n = stream.readsome(buffer, BUFFER_SIZE); c = buffer; bufend = buffer + n; // the following is a hack that appends an additional ' ' at the end of // the file to avoid problems when parsing symbols/elements and a sudden // EOF. This is faster than relying on unget and IMO also nicer. if(n == 0 || stream.eof()) { eof = true; *bufend = ' '; ++bufend; } } } Lexer::TokenType Lexer::getNextToken() { static const char* delims = "\"();"; try { while(isspace(*c)) { if(*c == '\n') ++linenumber; nextChar(); }; token_length = 0; switch(*c) { case ';': // comment while(!stream.eof()) { nextChar(); if(*c == '\n') { ++linenumber; break; } } return getNextToken(); // and again case '(': nextChar(); return TOKEN_OPEN_PAREN; case ')': nextChar(); return TOKEN_CLOSE_PAREN; case '"': { // string int startline = linenumber; try { while(1) { if(stream.eof()) { std::stringstream msg; msg << "Parse Error in line " << startline << ": " << "Couldn't find end of string."; throw std::runtime_error(msg.str()); } nextChar(); if(*c == '"') break; else if(*c == '\n') linenumber++; else if(*c == '\\') { nextChar(); switch(*c) { case 'n': *c = '\n'; break; case 't': *c = '\t'; break; } } if(token_length < MAX_TOKEN_LENGTH) token_string[token_length++] = *c; } token_string[token_length] = 0; } catch(EOFException& ) { std::stringstream msg; msg << "Parse error in line " << startline << ": " << "EOF while parsing string."; throw std::runtime_error(msg.str()); } nextChar(); return TOKEN_STRING; } case '#': // constant try { nextChar(); while(isalnum(*c) || *c == '_') { if(token_length < MAX_TOKEN_LENGTH) token_string[token_length++] = *c; nextChar(); } token_string[token_length] = 0; } catch(EOFException& ) { std::stringstream msg; msg << "Parse Error in line " << linenumber << ": " << "EOF while parsing constant."; throw std::runtime_error(msg.str()); } if(strcmp(token_string, "t") == 0) return TOKEN_TRUE; if(strcmp(token_string, "f") == 0) return TOKEN_FALSE; // we only handle #t and #f constants at the moment... { std::stringstream msg; msg << "Parse Error in line " << linenumber << ": " << "Unknown constant '" << token_string << "'."; throw std::runtime_error(msg.str()); } default: if(isdigit(*c) || *c == '-') { bool have_nondigits = false; bool have_digits = false; int have_floating_point = 0; do { if(isdigit(*c)) have_digits = true; else if(*c == '.') ++have_floating_point; else if(isalnum(*c) || *c == '_') have_nondigits = true; if(token_length < MAX_TOKEN_LENGTH) token_string[token_length++] = *c; nextChar(); } while(!isspace(*c) && !strchr(delims, *c)); token_string[token_length] = 0; // no nextChar if(have_nondigits || !have_digits || have_floating_point > 1) return TOKEN_SYMBOL; else if(have_floating_point == 1) return TOKEN_REAL; else return TOKEN_INTEGER; } else { do { if(token_length < MAX_TOKEN_LENGTH) token_string[token_length++] = *c; nextChar(); } while(!isspace(*c) && !strchr(delims, *c)); token_string[token_length] = 0; // no nextChar return TOKEN_SYMBOL; } } } catch(EOFException& ) { return TOKEN_EOF; } } } // end of namespace lisp --- NEW FILE: lisp.cpp --- // $Id: lisp.cpp,v 1.1 2004/11/28 14:57:45 matzebraun Exp $ // // TuxKart - a fun racing game with go-kart // Copyright (C) 2004 Matthias Braun <ma...@br...> // code in this file based on lispreader from Mark Probst // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include <config.h> #include "lisp.h" namespace lisp { Lisp::Lisp(LispType newtype) : type(newtype) { } Lisp::~Lisp() { if(type == TYPE_SYMBOL || type == TYPE_STRING) delete[] v.string; if(type == TYPE_CONS) { delete v.cons.cdr; delete v.cons.car; } } Lisp* Lisp::get_lisp(const char* name) const { for(const Lisp* p = this; p != 0; p = p->get_cdr()) { Lisp* child = p->get_car(); if(!child || child->get_type() != TYPE_CONS) continue; Lisp* childname = child->get_car(); if(!childname) continue; std::string childName; if(!childname->get(childName)) continue; if(childName == name) { return child->get_cdr(); } } return 0; } void Lisp::print(int indent) const { for(int i = 0; i < indent; ++i) printf(" "); if(type == TYPE_CONS) { printf("(\n"); const Lisp* lisp = this; while(lisp) { if(lisp->v.cons.car) lisp->v.cons.car->print(indent + 1); lisp = lisp->v.cons.cdr; } for(int i = 0; i < indent; ++i) printf(" "); printf(")"); } if(type == TYPE_STRING) { printf("'%s' ", v.string); } if(type == TYPE_INTEGER) { printf("%d", v.integer); } if(type == TYPE_REAL) { printf("%f", v.real); } if(type == TYPE_SYMBOL) { printf("%s ", v.string); } if(type == TYPE_BOOLEAN) { printf("%s ", v.boolean ? "true" : "false"); } printf("\n"); } } // end of namespace lisp |
From: Matze B. <mat...@us...> - 2004-11-28 14:57:48
|
Update of /cvsroot/super-tux/supertux In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13367 Modified Files: TODO Log Message: move over rewritten lispreader from tuxkart (with additional fixes), generalized TileManager and Tile classes and use them for the worldmap too Index: TODO =================================================================== RCS file: /cvsroot/super-tux/supertux/TODO,v retrieving revision 1.94 retrieving revision 1.95 diff -u -d -r1.94 -r1.95 --- TODO 26 Nov 2004 17:26:58 -0000 1.94 +++ TODO 28 Nov 2004 14:56:46 -0000 1.95 @@ -68,7 +68,6 @@ [L] rename gameloop.* files to gamesession.* [L] rename GameObject::action to GameObject::update() [L] use physfs for loading files -[L] eventually move over new lispreader code from tuxkart [L] change physics class y-velocity-coordinate to be like all other y-coordinates again (positive y to go down) [M] harmonize to 1 single gameloop that switches between title, worldmap, |
From: Matze B. <mat...@us...> - 2004-11-28 14:57:43
|
Update of /cvsroot/super-tux/supertux/lib/utils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13367/lib/utils Modified Files: configfile.cpp configfile.h Log Message: move over rewritten lispreader from tuxkart (with additional fixes), generalized TileManager and Tile classes and use them for the worldmap too Index: configfile.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/utils/configfile.h,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- configfile.h 24 Nov 2004 14:10:23 -0000 1.7 +++ configfile.h 28 Nov 2004 14:56:48 -0000 1.8 @@ -20,7 +20,7 @@ #ifndef SUPERTUX_CONFIGFILE_H #define SUPERTUX_CONFIGFILE_H -#include "lispreader.h" +#include "lisp/lisp.h" namespace SuperTux { @@ -30,7 +30,7 @@ public: void load (); void save (); - virtual void customload(LispReader& ) + virtual void customload(const lisp::Lisp* ) {}; virtual void customsave(FILE* ) {}; Index: configfile.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/utils/configfile.cpp,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- configfile.cpp 24 Nov 2004 14:10:23 -0000 1.9 +++ configfile.cpp 28 Nov 2004 14:56:48 -0000 1.10 @@ -21,11 +21,13 @@ #include <cstdlib> #include <string> +#include <stdexcept> #include "configfile.h" #include "app/setup.h" #include "app/globals.h" #include "audio/sound_manager.h" +#include "lisp/parser.h" using namespace SuperTux; @@ -76,64 +78,49 @@ void Config::load() { - FILE * file = NULL; - defaults(); - /* override defaults from config file */ - - file = opendata(config_filename, "r"); - - if (file == NULL) - return; - - /* read config file */ - - lisp_stream_t stream; - lisp_object_t * root_obj = NULL; - - lisp_stream_init_file (&stream, file); - root_obj = lisp_read (&stream); - - if (root_obj->type == LISP_TYPE_EOF || root_obj->type == LISP_TYPE_PARSE_ERROR) - return; - - if (strcmp(lisp_symbol(lisp_car(root_obj)), (package_symbol_name+"-config").c_str()) != 0) - return; - - LispReader reader(lisp_cdr(root_obj)); - - reader.read_bool("fullscreen", use_fullscreen); - bool temp; - reader.read_bool("sound", temp); - SoundManager::get()->enable_sound(temp); - reader.read_bool("music", temp); - SoundManager::get()->enable_music(temp); - reader.read_bool("show_fps", show_fps); + lisp::Parser parser; + try { + std::auto_ptr<lisp::Lisp> root (parser.parse(st_dir + config_filename)); - std::string video; - reader.read_string ("video", video); - if (video == "opengl") - use_gl = true; - else - use_gl = false; + const lisp::Lisp* config_lisp = root->get_lisp( + package_symbol_name + "-config"); + if(!config_lisp) + throw new std::runtime_error("Config file is not a supertux-config file"); - reader.read_int ("joystick", joystick_num); + config_lisp->get("fullscreen", use_fullscreen); + bool temp = false; + if(config_lisp->get("sound", temp)) + SoundManager::get()->enable_sound(temp); + if(config_lisp->get("music", temp)) + SoundManager::get()->enable_music(temp); + config_lisp->get("show_fps", show_fps); - if (joystick_num >= 0) - { - reader.read_int ("joystick-x", joystick_keymap.x_axis); - reader.read_int ("joystick-y", joystick_keymap.y_axis); - reader.read_int ("joystick-a", joystick_keymap.a_button); - reader.read_int ("joystick-b", joystick_keymap.b_button); - reader.read_int ("joystick-start", joystick_keymap.start_button); - reader.read_int ("joystick-deadzone", joystick_keymap.dead_zone); + std::string video; + if(config_lisp->get("video", video)) { + if (video == "opengl") + use_gl = true; + else + use_gl = false; } - customload(reader); + joystick_num = 0; + config_lisp->get("joystick", joystick_num); + + if (joystick_num >= 0) { + config_lisp->get("joystick-x", joystick_keymap.x_axis); + config_lisp->get("joystick-y", joystick_keymap.y_axis); + config_lisp->get("joystick-a", joystick_keymap.a_button); + config_lisp->get("joystick-b", joystick_keymap.b_button); + config_lisp->get("joystick-start", joystick_keymap.start_button); + config_lisp->get("joystick-deadzone", joystick_keymap.dead_zone); + } - lisp_free(root_obj); - fclose(file); + customload(config_lisp); + } catch(std::exception& e) { + std::cerr << "Couldn't load configfile: " << e.what() << "\n"; + } } void Config::save () @@ -173,4 +160,3 @@ } } -/* EOF */ |
From: Matze B. <mat...@us...> - 2004-11-28 14:57:39
|
Update of /cvsroot/super-tux/supertux/lib/special In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13367/lib/special Modified Files: sprite.h sprite_data.cpp sprite_data.h sprite_manager.cpp Log Message: move over rewritten lispreader from tuxkart (with additional fixes), generalized TileManager and Tile classes and use them for the worldmap too Index: sprite_data.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/sprite_data.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- sprite_data.cpp 24 Nov 2004 14:10:23 -0000 1.2 +++ sprite_data.cpp 28 Nov 2004 14:56:48 -0000 1.3 @@ -27,6 +27,7 @@ #include "app/globals.h" #include "app/setup.h" #include "video/drawing_context.h" +#include "lisp/list_iterator.h" namespace SuperTux { @@ -46,21 +47,18 @@ delete *i; } -SpriteData::SpriteData(lisp_object_t* cur) +SpriteData::SpriteData(const lisp::Lisp* lisp) { - for(; !lisp_nil_p(cur); cur = lisp_cdr(cur)) { - std::string token = lisp_symbol(lisp_car(lisp_car(cur))); - lisp_object_t* data = lisp_car(lisp_cdr(lisp_car(cur))); - LispReader reader(lisp_cdr(lisp_car(cur))); - - if(token == "name") - name = lisp_string(data); - else if(token == "action") - parse_action(reader); - else - std::cerr << "Warning: Unknown sprite field: " << token << std::endl; + lisp::ListIterator iter(lisp); + while(iter.next()) { + if(iter.item() == "name") { + iter.value()->get(name); + } else if(iter.item() == "action") { + parse_action(iter.lisp()); + } else { + std::cerr << "Unknown sprite field: " << iter.item() << "\n"; + } } - if(name.empty()) throw std::runtime_error("Error: Sprite wihtout name."); if(actions.empty()) @@ -74,21 +72,22 @@ } void -SpriteData::parse_action(LispReader& lispreader) +SpriteData::parse_action(const lisp::Lisp* lisp) { Action* action = new Action; - if(!lispreader.read_string("name", action->name)) { + if(!lisp->get("name", action->name)) { if(!actions.empty()) throw std::runtime_error( "If there are more than one action, they need names!"); } - lispreader.read_int("x-offset", action->x_offset); - lispreader.read_int("y-offset", action->y_offset); - lispreader.read_int("z-order", action->z_order); - lispreader.read_float("fps", action->fps); + lisp->get("x-offset", action->x_offset); + lisp->get("y-offset", action->y_offset); + lisp->get("z-order", action->z_order); + lisp->get("fps", action->fps); - /* TODO: add a top filter entry */ + // this doesn't seem to be used and implemented +#if 0 std::vector <int> mask_color; lispreader.read_int_vector("apply-mask", mask_color); if(mask_color.size() == 4) { @@ -97,9 +96,10 @@ (*i)->apply_filter(MASK_FILTER, Color(mask_color)); } } +#endif std::string mirror_action; - lispreader.read_string("mirror-action", mirror_action); + lisp->get("mirror-action", mirror_action); if(!mirror_action.empty()) { Action* act_tmp = get_action(mirror_action); if(act_tmp == NULL) { @@ -116,7 +116,7 @@ } } else { // Load images std::vector<std::string> images; - if(!lispreader.read_string_vector("images", images)) { + if(!lisp->get_vector("images", images)) { std::stringstream msg; msg << "Sprite '" << name << "' contains no images in action '" << action->name << "'."; Index: sprite_data.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/sprite_data.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- sprite_data.h 24 Nov 2004 14:10:23 -0000 1.2 +++ sprite_data.h 28 Nov 2004 14:56:48 -0000 1.3 @@ -24,7 +24,7 @@ #include <vector> #include <map> -#include "utils/lispreader.h" +#include "lisp/lisp.h" #include "video/surface.h" namespace SuperTux @@ -35,7 +35,7 @@ public: /** cur has to be a pointer to data in the form of ((x-offset 5) (y-offset 10) ...) */ - SpriteData(lisp_object_t* cur); + SpriteData(const lisp::Lisp* cur); ~SpriteData(); const std::string& get_name() const @@ -72,7 +72,7 @@ typedef std::map <std::string, Action*> Actions; Actions actions; - void parse_action(LispReader& lispreader); + void parse_action(const lisp::Lisp* lispreader); /** Get an action */ Action* get_action(std::string act); Index: sprite_manager.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/sprite_manager.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- sprite_manager.cpp 20 Nov 2004 22:14:36 -0000 1.5 +++ sprite_manager.cpp 28 Nov 2004 14:56:48 -0000 1.6 @@ -22,10 +22,12 @@ #include <sstream> #include <stdexcept> -#include "utils/lispreader.h" #include "sprite_manager.h" #include "sprite_data.h" #include "sprite.h" +#include "lisp/lisp.h" +#include "lisp/parser.h" +#include "lisp/list_iterator.h" namespace SuperTux { @@ -45,42 +47,39 @@ void SpriteManager::load_resfile(const std::string& filename) { - lisp_object_t* root_obj = lisp_read_from_file(filename); - if (!root_obj) - { - std::cout << "SpriteManager: Couldn't load: " << filename << std::endl; - return; - } - - lisp_object_t* cur = root_obj; - - if (strcmp(lisp_symbol(lisp_car(cur)), "supertux-resources") != 0) - return; - cur = lisp_cdr(cur); + lisp::Parser parser; + try { + std::auto_ptr<lisp::Lisp> root (parser.parse(filename)); - while(cur) { - lisp_object_t* el = lisp_car(cur); + const lisp::Lisp* resources = root->get_lisp("supertux-resources"); + if(!resources) + throw std::runtime_error("file is not a supertux-resources files"); - if (strcmp(lisp_symbol(lisp_car(el)), "sprite") == 0) { - SpriteData* spritedata = new SpriteData(lisp_cdr(el)); + lisp::ListIterator iter(resources); + while(iter.next()) { + if(iter.item() == "sprite") { + SpriteData* spritedata = new SpriteData(iter.lisp()); - Sprites::iterator i = sprites.find(spritedata->get_name()); - if (i == sprites.end()) { - sprites[spritedata->get_name()] = spritedata; + printf("Spr: %s.\n", spritedata->get_name().c_str()); + Sprites::iterator i = sprites.find(spritedata->get_name()); + if (i == sprites.end()) { + sprites[spritedata->get_name()] = spritedata; + } else { + delete i->second; + i->second = spritedata; + std::cout << "Warning: dulpicate entry: '" << spritedata->get_name() + << "' in spritefile." << std::endl; + } } else { - delete i->second; - i->second = spritedata; - std::cout << "Warning: dulpicate entry: '" << spritedata->get_name() - << "' in spritefile." << std::endl; + std::cout << "SpriteManager: Unknown tag '" << iter.item() + << "' in spritefile.\n"; } - } else { - std::cout << "SpriteManager: Unknown tag in spritefile.\n"; } - - cur = lisp_cdr(cur); + } catch(std::exception& e) { + std::stringstream msg; + msg << "Couldn't load file '" << filename << "': " << e.what() << "\n"; + throw std::runtime_error(msg.str()); } - - lisp_free(root_obj); } Sprite* Index: sprite.h =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/special/sprite.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- sprite.h 24 Nov 2004 23:10:02 -0000 1.19 +++ sprite.h 28 Nov 2004 14:56:48 -0000 1.20 @@ -25,7 +25,6 @@ #include <cassert> #include <map> -#include "utils/lispreader.h" #include "video/surface.h" #include "math/vector.h" #include "sprite_data.h" |
From: Matze B. <mat...@us...> - 2004-11-28 14:57:39
|
Update of /cvsroot/super-tux/supertux/lib/video In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13367/lib/video Modified Files: font.cpp Log Message: move over rewritten lispreader from tuxkart (with additional fixes), generalized TileManager and Tile classes and use them for the worldmap too Index: font.cpp =================================================================== RCS file: /cvsroot/super-tux/supertux/lib/video/font.cpp,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- font.cpp 24 Nov 2004 14:10:24 -0000 1.15 +++ font.cpp 28 Nov 2004 14:56:48 -0000 1.16 @@ -22,12 +22,14 @@ #include <cstdlib> #include <cstring> +#include <stdexcept> #include "app/globals.h" +#include "lisp/parser.h" +#include "lisp/lisp.h" #include "screen.h" #include "font.h" #include "drawing_context.h" -#include "utils/lispreader.h" using namespace SuperTux; @@ -202,23 +204,30 @@ #define SCROLL 60 #define ITEMS_SPACE 4 -void SuperTux::display_text_file(const std::string& file, float scroll_speed, Font* heading_font, Font* normal_font, Font* small_font, Font* reference_font ) +void SuperTux::display_text_file(const std::string& file, float scroll_speed, + Font* heading_font, Font* normal_font, Font* small_font, + Font* reference_font) { std::string text; + std::string background_file; std::vector<std::string> names; - LispReader* reader = LispReader::load(datadir + "/" + file, "supertux-text"); + std::string filename = datadir + "/" + file; + lisp::Parser parser; + try { + std::auto_ptr<lisp::Lisp> root (parser.parse(filename)); - if(!reader) - { - std::cerr << "Error: Could not open text. Ignoring...\n"; + const lisp::Lisp* text_lisp = root->get_lisp("supertux-text"); + if(!text_lisp) + throw std::runtime_error("File isn't a supertux-text file"); + + if(!text_lisp->get("text", text)) + throw std::runtime_error("file doesn't contain a text field"); + } catch(std::exception& e) { + std::cerr << "Couldn't load file '" << filename << "': " << e.what() << + "\n"; return; - } - - reader->read_string("text", text, true); - std::string background_file; - reader->read_string("background", background_file, true); - delete reader; + } // Split text string lines into a vector names.clear(); |
From: Matze B. <mat...@us...> - 2004-11-28 14:57:36
|
Update of /cvsroot/super-tux/supertux/data/images/worldmap In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13367/data/images/worldmap Modified Files: antarctica.stwt Log Message: move over rewritten lispreader from tuxkart (with additional fixes), generalized TileManager and Tile classes and use them for the worldmap too Index: antarctica.stwt =================================================================== RCS file: /cvsroot/super-tux/supertux/data/images/worldmap/antarctica.stwt,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- antarctica.stwt 26 Aug 2004 22:57:13 -0000 1.8 +++ antarctica.stwt 28 Nov 2004 14:56:46 -0000 1.9 @@ -2,59 +2,58 @@ ;; (tile (id INT) ;; (directions TOP RIGHT DOWN LEFT) ;; -(supertux-worldmap-tiles - +(supertux-tiles (tile (id 1) - (image "road_h.png") + (images "road_h.png") (north #f) (south #f) (west #t) (east #t) (stop #f)) (tile (id 2) - (image "road_v.png") + (images "road_v.png") (north #t) (south #t) (west #f) (east #f) (stop #f)) (tile (id 3) - (image "road_ws.png") + (images "road_ws.png") (north #f) (south #t) (west #t) (east #f) (stop #t)) (tile (id 4) - (image "road_cross.png") + (images "road_cross.png") (north #t) (south #t) (west #t) (east #t) (stop #t)) (tile (id 5) - (image "road_end.png") + (images "road_end.png") (north #f) (south #f) (west #f) (east #t) (stop #t)) (tile (id 6) - (image "road_h_stop.png") + (images "road_h_stop.png") (north #f) (south #f) (west #t) (east #t) (stop #t)) (tile (id 7) - (image "road_v_stop.png") + (images "road_v_stop.png") (north #t) (south #t) (west #f) (east #f) (stop #t)) (tile (id 8) - (image "ground.png") + (images "ground.png") (north #f) (south #f) (east #f) @@ -62,140 +61,142 @@ (stop #f)) (tile (id 9) - (image "water.png")) + (images "water.png")) (tile (id 11) - (image "snow1.png")) + (images "snow1.png")) (tile (id 12) - (image "snow2.png")) + (images "snow2.png")) (tile (id 13) - (image "snow3.png")) + (images "snow3.png")) (tile (id 14) - (image "snow4.png")) + (images "snow4.png")) (tile (id 15) - (image "snow5.png")) + (images "snow5.png")) (tile (id 16) - (image "snow6.png")) + (images "snow6.png")) (tile (id 17) - (image "snow7.png")) + (images "snow7.png")) (tile (id 18) - (image "snow8.png")) + (images "snow8.png")) (tile (id 19) - (image "snow9.png")) + (images "snow9.png")) (tile (id 20) - (image "snow10.png")) + (images "snow10.png")) (tile (id 21) - (image "snow11.png")) + (images "snow11.png")) (tile (id 22) - (image "snow12.png")) + (images "snow12.png")) (tile (id 23) - (image "snow13.png")) + (images "snow13.png")) (tile (id 24) - (image "wood1.png")) + (images "wood1.png")) (tile (id 25) - (image "wood2.png")) + (images "wood2.png")) (tile (id 26) - (image "wood3.png")) + (images "wood3.png")) (tile (id 27) - (image "wood4.png")) + (images "wood4.png")) (tile (id 28) - (image "wood5.png")) + (images "wood5.png")) (tile (id 29) - (image "wood6.png")) + (images "wood6.png")) (tile (id 30) - (image "wood7.png")) + (images "wood7.png")) (tile (id 31) - (image "wood8.png")) + (images "wood8.png")) (tile (id 32) - (image "wood9.png")) + (images "wood9.png")) (tile (id 33) - (image "wood10.png")) + (images "wood10.png")) (tile (id 34) - (image "wood11.png")) + (images "wood11.png")) (tile (id 35) - (image "wood12.png")) + (images "wood12.png")) (tile (id 36) - (image "wood13.png")) + (images "wood13.png")) (tile (id 37) - (image "road_ne.png") + (images "road_ne.png") (stop #f) - (auto-walk #t) (north #t) (south #f) (west #f) (east #t)) (tile (id 38) - (image "road_nsw.png") + (images "road_nsw.png") (north #t) (south #t) (west #t) - (east #f)) + (east #f) + (stop #t)) (tile (id 39) - (image "road_sw.png") + (images "road_sw.png") (stop #f) - (auto-walk #t) (north #f) (south #t) (west #t) (east #f)) (tile (id 40) - (image "road_we.png") + (images "road_we.png") (north #f) (south #f) (west #t) (east #t) (stop #f)) (tile (id 41) - (image "road_nes.png") + (images "road_nes.png") (north #t) (south #t) (west #f) - (east #t)) + (east #t) + (stop #t)) (tile (id 42) - (image "road_nw.png") + (images "road_nw.png") (stop #f) - (auto-walk #t) (north #t) (south #f) (west #t) (east #f)) (tile (id 43) - (image "road_swe.png") + (images "road_swe.png") (north #f) (south #t) (west #t) - (east #t)) + (east #t) + (stop #t)) (tile (id 44) - (image "road_new.png") + (images "road_new.png") (north #t) (south #f) (west #t) - (east #t)) + (east #t) + (stop #t)) (tile (id 45) - (image "road_nesw.png") + (images "road_nesw.png") (north #t) (south #t) (west #t) - (east #t)) + (east #t) + (stop #t)) (tile (id 46) - (image "road_nws.png") + (images "road_nws.png") (north #t) (south #t) (west #t) - (east #f)) + (east #f) + (stop #t)) (tile (id 47) - (image "road_ns.png") + (images "road_ns.png") (north #t) (south #t) (west #f) (east #f) (stop #f)) (tile (id 48) - (image "road_se.png") + (images "road_se.png") (stop #f) - (auto-walk #t) (north #f) (south #t) (west #f) @@ -203,58 +204,58 @@ ;; castle (tile (id 49) - (image "castle1.png") + (images "castle1.png") (north #f) (south #f) (west #f) (east #f)) (tile (id 50) - (image "castle2.png") + (images "castle2.png") (north #f) (south #f) (west #f) (east #f)) (tile (id 51) - (image "castle3.png") + (images "castle3.png") (north #f) (south #f) (west #f) (east #f)) (tile (id 52) - (image "castle4.png") + (images "castle4.png") (north #f) (south #f) (west #f) (east #f)) (tile (id 53) - (image "castle5.png") + (images "castle5.png") (north #f) (south #f) (west #f) (east #f)) (tile (id 54) - (image "castle6.png") + (images "castle6.png") (north #f) (south #f) (west #f) (east #f)) (tile (id 55) - (image "castle7.png") + (images "castle7.png") (north #f) (south #f) (west #f) (east #f)) (tile (id 56) - (image "castle8.png") + (images "castle8.png") (stop #t) (north #f) (south #f) (west #f) (east #t)) (tile (id 57) - (image "castle9.png") + (images "castle9.png") (stop #f) (north #f) (south #f) @@ -262,14 +263,14 @@ (east #t)) (tile (id 58) - (image "igloo1.png") + (images "igloo1.png") (stop #f) (north #f) (south #f) (west #f) (east #f)) (tile (id 59) - (image "igloo2.png") + (images "igloo2.png") (stop #t) (north #f) (south #t) @@ -277,7 +278,7 @@ (east #f)) (tile (id 60) - (image "snowman.png") + (images "snowman.png") (north #f) (south #t) (west #f) @@ -285,14 +286,14 @@ ;; Secret paths (tile (id 61) - (image "road_nws.png") + (images "road_nws.png") (north #t) (south #t) (west #t) (east #t)) (tile (id 62) - (image "snow5.png") + (images "snow5.png") (stop #f) (north #f) (south #f) @@ -300,7 +301,7 @@ (east #t)) (tile (id 63) - (image "water.png") + (images "water.png") (stop #f) (north #f) (south #f) @@ -308,7 +309,7 @@ (east #t)) (tile (id 64) - (image "snow7.png") + (images "snow7.png") (stop #f) (north #f) (south #f) @@ -317,7 +318,7 @@ ;;one-way vertical road (tile (id 65) - (image "road_ns.png") + (images "road_ns.png") (north #t) (south #t) (west #f) @@ -327,7 +328,7 @@ ;;one-way horizontal road (tile (id 66) - (image "road_we.png") + (images "road_we.png") (north #f) (south #f) (west #t) @@ -337,7 +338,7 @@ ;; Another invisible road (tile (id 67) - (image "snow9.png") + (images "snow9.png") (stop #t) (north #f) (south #f) @@ -346,7 +347,7 @@ ;; End of the line (tile (id 68) - (image "road_n.png") + (images "road_n.png") (stop #t) (north #t) (south #f) @@ -354,29 +355,26 @@ (east #f)) (tile (id 69) - (image "road_e.png") - (stop #t) + (images "road_e.png") + (stop #t) (north #f) (south #f) (west #f) (east #t)) (tile (id 70) - (image "road_s.png") - (stop #t) + (images "road_s.png") + (stop #t) (north #f) (south #t) (west #f) (east #f)) (tile (id 71) - (image "road_w.png") - (stop #t) + (images "road_w.png") + (stop #t) (north #f) (south #f) (west #t) (east #f)) - - ) -;; EOF ;; |