From: mathnerd314 Date: Fri, 1 Jan 2010 05:01:41 +0000 (+0000) Subject: Make it build with -DCOMPILE_AMALGATION=ON. Still not certain how intern_draw/next_po... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=8683e3e860459411dfb2bd451dfc404a7bfd7db4;p=supertux.git Make it build with -DCOMPILE_AMALGATION=ON. Still not certain how intern_draw/next_po2 should be shared around the code. Also remove loop for leveldone music git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6236 837edb03-e0f3-0310-88ca-d4d4e8b29345 --- diff --git a/data/music/leveldone.music b/data/music/leveldone.music index 74496ffc2..8f049e3c6 100644 --- a/data/music/leveldone.music +++ b/data/music/leveldone.music @@ -1,5 +1,3 @@ (supertux-music (file "leveldone.ogg") - (loop-begin 0.653061224489796) ;sample no. 28800 - (loop-at 5.514739229024940) ;sample no. 243200 ) diff --git a/src/badguy/captainsnowball.cpp b/src/badguy/captainsnowball.cpp index d4826413e..4e3e7daa2 100644 --- a/src/badguy/captainsnowball.cpp +++ b/src/badguy/captainsnowball.cpp @@ -21,7 +21,7 @@ #include "supertux/sector.hpp" namespace{ - static const float WALK_SPEED = 100; + static const float CAPTAIN_WALK_SPEED = 100; static const float BOARDING_SPEED = 200; } @@ -82,7 +82,7 @@ void CaptainSnowball::collision_solid(const CollisionHit& hit) { if (is_active() && (walk_speed == BOARDING_SPEED)) { - walk_speed = WALK_SPEED; + walk_speed = CAPTAIN_WALK_SPEED; physic.set_velocity_x(dir == LEFT ? -walk_speed : walk_speed); } WalkingBadguy::collision_solid(hit); diff --git a/src/badguy/flame.cpp b/src/badguy/flame.cpp index ff3c062d8..5387b74ba 100644 --- a/src/badguy/flame.cpp +++ b/src/badguy/flame.cpp @@ -22,7 +22,7 @@ #include "supertux/object_factory.hpp" #include "util/reader.hpp" -static const std::string SOUNDFILE = "sounds/flame.wav"; +static const std::string FLAME_SOUND = "sounds/flame.wav"; Flame::Flame(const Reader& reader) : BadGuy(reader, "images/creatures/flame/flame.sprite", LAYER_FLOATINGOBJECTS), @@ -36,7 +36,7 @@ Flame::Flame(const Reader& reader) : bbox.set_pos(Vector(start_position.x + cos(angle) * radius, start_position.y + sin(angle) * radius)); countMe = false; - sound_manager->preload(SOUNDFILE); + sound_manager->preload(FLAME_SOUND); set_colgroup_active(COLGROUP_TOUCHABLE); } @@ -55,7 +55,7 @@ Flame::active_update(float elapsed_time) void Flame::activate() { - sound_source.reset(sound_manager->create_sound_source(SOUNDFILE)); + sound_source.reset(sound_manager->create_sound_source(FLAME_SOUND)); sound_source->set_position(get_pos()); sound_source->set_looping(true); sound_source->set_gain(2.0); diff --git a/src/badguy/mole.cpp b/src/badguy/mole.cpp index 291d86ef8..302d089bb 100644 --- a/src/badguy/mole.cpp +++ b/src/badguy/mole.cpp @@ -24,7 +24,7 @@ #include -static const float IDLE_TIME = 0.2f; /**< time to wait before and after throwing */ +static const float MOLE_WAIT_TIME = 0.2f; /**< time to wait before and after throwing */ static const float THROW_TIME = 4.6f; /**< time to spend throwing */ static const float THROW_INTERVAL = 1; /**< time between two thrown rocks */ static const float THROW_VELOCITY = 400; /**< initial velocity of thrown rocks */ @@ -139,7 +139,7 @@ Mole::set_state(MoleState new_state) case PRE_THROWING: sprite->set_action("idle"); set_colgroup_active(COLGROUP_DISABLED); - timer.start(IDLE_TIME); + timer.start(MOLE_WAIT_TIME); break; case THROWING: sprite->set_action("idle"); @@ -150,7 +150,7 @@ Mole::set_state(MoleState new_state) case POST_THROWING: sprite->set_action("idle"); set_colgroup_active(COLGROUP_DISABLED); - timer.start(IDLE_TIME); + timer.start(MOLE_WAIT_TIME); break; case PEEKING: sprite->set_action("peeking", 1); diff --git a/src/badguy/skullyhop.cpp b/src/badguy/skullyhop.cpp index a401cd639..c76bace33 100644 --- a/src/badguy/skullyhop.cpp +++ b/src/badguy/skullyhop.cpp @@ -22,11 +22,9 @@ #include "supertux/object_factory.hpp" namespace { -const float VERTICAL_SPEED = -450; /**< y-speed when jumping */ -const float HORIZONTAL_SPEED = 220; /**< x-speed when jumping */ const float MIN_RECOVER_TIME = 0.1f; /**< minimum time to stand still before starting a (new) jump */ const float MAX_RECOVER_TIME = 1.0f; /**< maximum time to stand still before starting a (new) jump */ -static const std::string HOP_SOUND = "sounds/hop.ogg"; +static const std::string SKULLYHOP_SOUND = "sounds/hop.ogg"; } SkullyHop::SkullyHop(const Reader& reader) : @@ -34,7 +32,7 @@ SkullyHop::SkullyHop(const Reader& reader) : recover_timer(), state() { - sound_manager->preload( HOP_SOUND ); + sound_manager->preload( SKULLYHOP_SOUND ); } SkullyHop::SkullyHop(const Vector& pos, Direction d) : @@ -42,7 +40,7 @@ SkullyHop::SkullyHop(const Vector& pos, Direction d) : recover_timer(), state() { - sound_manager->preload( HOP_SOUND ); + sound_manager->preload( SKULLYHOP_SOUND ); } void @@ -69,9 +67,11 @@ SkullyHop::set_state(SkullyHopState newState) } else if (newState == JUMPING) { sprite->set_action(dir == LEFT ? "jumping-left" : "jumping-right"); +const float HORIZONTAL_SPEED = 220; /**< x-speed when jumping */ physic.set_velocity_x(dir == LEFT ? -HORIZONTAL_SPEED : HORIZONTAL_SPEED); +const float VERTICAL_SPEED = -450; /**< y-speed when jumping */ physic.set_velocity_y(VERTICAL_SPEED); - sound_manager->play( HOP_SOUND, get_pos()); + sound_manager->play( SKULLYHOP_SOUND, get_pos()); } state = newState; diff --git a/src/badguy/spidermite.cpp b/src/badguy/spidermite.cpp index 389d70e37..634088a4f 100644 --- a/src/badguy/spidermite.cpp +++ b/src/badguy/spidermite.cpp @@ -21,7 +21,7 @@ #include "supertux/object_factory.hpp" static const float FLYTIME = 1.2f; -static const float FLYSPEED = -100.0f; +static const float MOVE_SPEED = -100.0f; SpiderMite::SpiderMite(const Reader& reader) : BadGuy(reader, "images/creatures/spidermite/spidermite.sprite"), @@ -44,7 +44,7 @@ SpiderMite::initialize() { sprite->set_action(dir == LEFT ? "left" : "right"); mode = FLY_UP; - physic.set_velocity_y(FLYSPEED); + physic.set_velocity_y(MOVE_SPEED); timer.start(FLYTIME/2); } @@ -70,10 +70,10 @@ SpiderMite::active_update(float elapsed_time) if(timer.check()) { if(mode == FLY_UP) { mode = FLY_DOWN; - physic.set_velocity_y(-FLYSPEED); + physic.set_velocity_y(-MOVE_SPEED); } else if(mode == FLY_DOWN) { mode = FLY_UP; - physic.set_velocity_y(FLYSPEED); + physic.set_velocity_y(MOVE_SPEED); } timer.start(FLYTIME); } diff --git a/src/badguy/stalactite.cpp b/src/badguy/stalactite.cpp index 3c63bea43..6742c7346 100644 --- a/src/badguy/stalactite.cpp +++ b/src/badguy/stalactite.cpp @@ -23,7 +23,6 @@ static const int SHAKE_RANGE_X = 40; static const float SHAKE_TIME = .8f; -static const float SQUISH_TIME = 2; static const float SHAKE_RANGE_Y = 400; Stalactite::Stalactite(const Reader& lisp) : @@ -55,10 +54,8 @@ Stalactite::active_update(float elapsed_time) physic.enable_gravity(true); set_colgroup_active(COLGROUP_MOVING); } - } else if(state == STALACTITE_FALLING || state == STALACTITE_SQUISHED) { + } else if(state == STALACTITE_FALLING) { movement = physic.get_movement(elapsed_time); - if(state == STALACTITE_SQUISHED && timer.check()) - remove_me(); } } @@ -66,10 +63,12 @@ void Stalactite::squish() { state = STALACTITE_SQUISHED; - set_colgroup_active(COLGROUP_MOVING_ONLY_STATIC); - sprite->set_action("squished"); - if(!timer.started()) - timer.start(SQUISH_TIME); + physic.enable_gravity(true); + physic.set_velocity_x(0); + physic.set_velocity_y(0); + set_state(STATE_SQUISHED); + set_group(COLGROUP_MOVING_ONLY_STATIC); + run_dead_script(); } void diff --git a/src/badguy/stumpy.cpp b/src/badguy/stumpy.cpp index 1ad03a67c..218d871f3 100644 --- a/src/badguy/stumpy.cpp +++ b/src/badguy/stumpy.cpp @@ -25,7 +25,7 @@ #include -static const float WALKSPEED = 120; +static const float STUMPY_SPEED = 120; static const float INVINCIBLE_TIME = 1; Stumpy::Stumpy(const Reader& reader) : @@ -33,7 +33,7 @@ Stumpy::Stumpy(const Reader& reader) : mystate(STATE_NORMAL), invincible_timer() { - walk_speed = WALKSPEED; + walk_speed = STUMPY_SPEED; max_drop_height = 16; sound_manager->preload("sounds/mr_treehit.ogg"); } @@ -43,7 +43,7 @@ Stumpy::Stumpy(const Vector& pos, Direction d) : mystate(STATE_INVINCIBLE), invincible_timer() { - walk_speed = WALKSPEED; + walk_speed = STUMPY_SPEED; max_drop_height = 16; sound_manager->preload("sounds/mr_treehit.ogg"); invincible_timer.start(INVINCIBLE_TIME); diff --git a/src/badguy/toad.cpp b/src/badguy/toad.cpp index 9925739fb..9fc27c6fc 100644 --- a/src/badguy/toad.cpp +++ b/src/badguy/toad.cpp @@ -24,7 +24,7 @@ namespace { const float VERTICAL_SPEED = -450; /**< y-speed when jumping */ const float HORIZONTAL_SPEED = 320; /**< x-speed when jumping */ -const float RECOVER_TIME = 0.5; /**< time to stand still before starting a (new) jump */ +const float TOAD_RECOVER_TIME = 0.5; /**< time to stand still before starting a (new) jump */ static const std::string HOP_SOUND = "sounds/hop.ogg"; } @@ -60,7 +60,7 @@ Toad::set_state(ToadState newState) physic.set_velocity_y(0); sprite->set_action(dir == LEFT ? "idle-left" : "idle-right"); - recover_timer.start(RECOVER_TIME); + recover_timer.start(TOAD_RECOVER_TIME); } else if (newState == JUMPING) { sprite->set_action(dir == LEFT ? "jumping-left" : "jumping-right"); diff --git a/src/badguy/totem.cpp b/src/badguy/totem.cpp index 068472e6b..70bd8503d 100644 --- a/src/badguy/totem.cpp +++ b/src/badguy/totem.cpp @@ -24,7 +24,6 @@ #include -static const float WALKSPEED = 100; static const float JUMP_ON_SPEED_Y = -400; static const float JUMP_OFF_SPEED_Y = -500; static const std::string LAND_ON_TOTEM_SOUND = "sounds/totem.ogg"; @@ -61,6 +60,7 @@ void Totem::initialize() { if (!carried_by) { +static const float WALKSPEED = 100; physic.set_velocity_x(dir == LEFT ? -WALKSPEED : WALKSPEED); sprite->set_action(dir == LEFT ? "walking-left" : "walking-right"); return; diff --git a/src/badguy/treewillowisp.cpp b/src/badguy/treewillowisp.cpp index ff8410886..2b6c87ec6 100644 --- a/src/badguy/treewillowisp.cpp +++ b/src/badguy/treewillowisp.cpp @@ -25,7 +25,7 @@ #include -static const std::string SOUNDFILE = "sounds/willowisp.wav"; +static const std::string TREEWILLOSOUND = "sounds/willowisp.wav"; static const float SUCKSPEED = 25; TreeWillOWisp::TreeWillOWisp(GhostTree* tree, const Vector& pos, @@ -42,7 +42,7 @@ TreeWillOWisp::TreeWillOWisp(GhostTree* tree, const Vector& pos, tree(tree), suck_target() { - sound_manager->preload(SOUNDFILE); + sound_manager->preload(TREEWILLOSOUND); this->radius = radius; this->angle = 0; @@ -58,7 +58,7 @@ TreeWillOWisp::~TreeWillOWisp() void TreeWillOWisp::activate() { - sound_source.reset(sound_manager->create_sound_source(SOUNDFILE)); + sound_source.reset(sound_manager->create_sound_source(TREEWILLOSOUND)); sound_source->set_position(get_pos()); sound_source->set_looping(true); sound_source->set_gain(2.0); diff --git a/src/badguy/willowisp.cpp b/src/badguy/willowisp.cpp index 748a4439c..7fb4082ad 100644 --- a/src/badguy/willowisp.cpp +++ b/src/badguy/willowisp.cpp @@ -278,8 +278,8 @@ WillOWisp::expose(HSQUIRRELVM vm, SQInteger table_idx) return; std::cout << "Expose me '" << name << "'\n"; - scripting::WillOWisp* interface = static_cast (this); - expose_object(vm, table_idx, interface, name); + scripting::WillOWisp* _this = static_cast (this); + expose_object(vm, table_idx, _this, name); } void diff --git a/src/badguy/yeti.cpp b/src/badguy/yeti.cpp index ba8b54a4f..6249ea916 100644 --- a/src/badguy/yeti.cpp +++ b/src/badguy/yeti.cpp @@ -48,7 +48,7 @@ const float STOMP_WAIT = .5; /**< time we stay on the dais before jumping again const float SAFE_TIME = .5; /**< the time we are safe when tux just hit us */ const int INITIAL_HITPOINTS = 3; /**< number of hits we can take */ -const float SQUISH_TIME = 5; +const float YETI_SQUISH_TIME = 5; } Yeti::Yeti(const Reader& reader) : @@ -222,7 +222,7 @@ void Yeti::take_hit(Player& ) physic.set_velocity_y(0); state = SQUISHED; - state_timer.start(SQUISH_TIME); + state_timer.start(YETI_SQUISH_TIME); set_colgroup_active(COLGROUP_MOVING_ONLY_STATIC); sprite->set_action("dead"); diff --git a/src/badguy/yeti_stalactite.cpp b/src/badguy/yeti_stalactite.cpp index 12a925ef8..59d819bb5 100644 --- a/src/badguy/yeti_stalactite.cpp +++ b/src/badguy/yeti_stalactite.cpp @@ -18,7 +18,7 @@ #include "supertux/object_factory.hpp" -static const float SHAKE_TIME = .8f; +static const float YT_SHAKE_TIME = .8f; YetiStalactite::YetiStalactite(const Reader& lisp) : Stalactite(lisp) @@ -32,7 +32,7 @@ YetiStalactite::~YetiStalactite() void YetiStalactite::start_shaking() { - timer.start(SHAKE_TIME); + timer.start(YT_SHAKE_TIME); state = STALACTITE_SHAKING; } diff --git a/src/object/ambient_sound.cpp b/src/object/ambient_sound.cpp index d0d651ba0..730e7a723 100644 --- a/src/object/ambient_sound.cpp +++ b/src/object/ambient_sound.cpp @@ -235,8 +235,8 @@ AmbientSound::draw(DrawingContext &) void AmbientSound::expose(HSQUIRRELVM vm, SQInteger table_idx) { - scripting::AmbientSound* interface = static_cast (this); - expose_object(vm, table_idx, interface, name, false); + scripting::AmbientSound* _this = static_cast (this); + expose_object(vm, table_idx, _this, name, false); } void diff --git a/src/object/camera.cpp b/src/object/camera.cpp index 4ecf5b59c..9e1f53ff6 100644 --- a/src/object/camera.cpp +++ b/src/object/camera.cpp @@ -146,8 +146,8 @@ void Camera::expose(HSQUIRRELVM vm, SQInteger table_idx) { if(name.empty()) return; - scripting::Camera* interface = new scripting::Camera(this); - expose_object(vm, table_idx, interface, name, true); + scripting::Camera* _this = new scripting::Camera(this); + expose_object(vm, table_idx, _this, name, true); } void @@ -229,7 +229,7 @@ Camera::scroll_to(const Vector& goal, float scrolltime) mode = SCROLLTO; } -static const float EPSILON = .00001f; +static const float CAMERA_EPSILON = .00001f; static const float MAX_SPEED_Y = 140; void @@ -312,7 +312,7 @@ Camera::update_scroll_normal(float elapsed_time) last_player_pos = player_pos; // check that we don't have division by zero later - if(elapsed_time < EPSILON) + if(elapsed_time < CAMERA_EPSILON) return; /****** Vertical Scrolling part ******/ @@ -360,14 +360,14 @@ Camera::update_scroll_normal(float elapsed_time) float upperend = SCREEN_HEIGHT * config.edge_x; float lowerend = SCREEN_HEIGHT * (1 - config.edge_x); - if (player_delta.y < -EPSILON) { + if (player_delta.y < -CAMERA_EPSILON) { // walking left lookahead_pos.y -= player_delta.y * config.dynamic_speed_sm; if(lookahead_pos.y > lowerend) { lookahead_pos.y = lowerend; } - } else if (player_delta.y > EPSILON) { + } else if (player_delta.y > CAMERA_EPSILON) { // walking right lookahead_pos.y -= player_delta.y * config.dynamic_speed_sm; if(lookahead_pos.y < upperend) { @@ -445,8 +445,8 @@ Camera::update_scroll_normal(float elapsed_time) // Find out direction in which the player moves LookaheadMode walkDirection; - if (player_delta.x < -EPSILON) walkDirection = LOOKAHEAD_LEFT; - else if (player_delta.x > EPSILON) walkDirection = LOOKAHEAD_RIGHT; + if (player_delta.x < -CAMERA_EPSILON) walkDirection = LOOKAHEAD_LEFT; + else if (player_delta.x > CAMERA_EPSILON) walkDirection = LOOKAHEAD_RIGHT; else if (player->dir == ::LEFT) walkDirection = LOOKAHEAD_LEFT; else walkDirection = LOOKAHEAD_RIGHT; @@ -531,14 +531,14 @@ Camera::update_scroll_normal(float elapsed_time) float LEFTEND = SCREEN_WIDTH * config.edge_x; float RIGHTEND = SCREEN_WIDTH * (1 - config.edge_x); - if (player_delta.x < -EPSILON) { + if (player_delta.x < -CAMERA_EPSILON) { // walking left lookahead_pos.x -= player_delta.x * config.dynamic_speed_sm; if(lookahead_pos.x > RIGHTEND) { lookahead_pos.x = RIGHTEND; } - } else if (player_delta.x > EPSILON) { + } else if (player_delta.x > CAMERA_EPSILON) { // walking right lookahead_pos.x -= player_delta.x * config.dynamic_speed_sm; if(lookahead_pos.x < LEFTEND) { diff --git a/src/object/candle.cpp b/src/object/candle.cpp index d428745e4..1123ce0bb 100644 --- a/src/object/candle.cpp +++ b/src/object/candle.cpp @@ -70,8 +70,8 @@ void Candle::expose(HSQUIRRELVM vm, SQInteger table_idx) { if (name.empty()) return; - scripting::Candle* interface = new scripting::Candle(this); - expose_object(vm, table_idx, interface, name, true); + scripting::Candle* _this = new scripting::Candle(this); + expose_object(vm, table_idx, _this, name, true); } void diff --git a/src/object/level_time.cpp b/src/object/level_time.cpp index 44d656b81..011cb4f9b 100644 --- a/src/object/level_time.cpp +++ b/src/object/level_time.cpp @@ -46,8 +46,8 @@ void LevelTime::expose(HSQUIRRELVM vm, SQInteger table_idx) { if (name.empty()) return; - scripting::LevelTime* interface = new scripting::LevelTime(this); - expose_object(vm, table_idx, interface, name, true); + scripting::LevelTime* _this = new scripting::LevelTime(this); + expose_object(vm, table_idx, _this, name, true); } void diff --git a/src/object/platform.cpp b/src/object/platform.cpp index aa0392375..7c38238b1 100644 --- a/src/object/platform.cpp +++ b/src/object/platform.cpp @@ -133,8 +133,8 @@ void Platform::expose(HSQUIRRELVM vm, SQInteger table_idx) { if (name.empty()) return; - scripting::Platform* interface = new scripting::Platform(this); - expose_object(vm, table_idx, interface, name, true); + scripting::Platform* _this = new scripting::Platform(this); + expose_object(vm, table_idx, _this, name, true); } void diff --git a/src/object/star.cpp b/src/object/star.cpp index 9e7932a94..f421d4308 100644 --- a/src/object/star.cpp +++ b/src/object/star.cpp @@ -18,14 +18,14 @@ #include "object/star.hpp" static const float INITIALJUMP = -400; -static const float SPEED = 150; -static const float JUMPSPEED = -300; +static const float STAR_SPEED = 150; +static const float JUMPSTAR_SPEED = -300; Star::Star(const Vector& pos, Direction direction) : MovingSprite(pos, "images/powerups/star/star.sprite", LAYER_OBJECTS, COLGROUP_MOVING), physic() { - physic.set_velocity((direction == LEFT) ? -SPEED : SPEED, INITIALJUMP); + physic.set_velocity((direction == LEFT) ? -STAR_SPEED : STAR_SPEED, INITIALJUMP); } void @@ -38,7 +38,7 @@ void Star::collision_solid(const CollisionHit& hit) { if(hit.bottom) { - physic.set_velocity_y(JUMPSPEED); + physic.set_velocity_y(JUMPSTAR_SPEED); } else if(hit.top) { physic.set_velocity_y(0); } else if(hit.left || hit.right) { diff --git a/src/object/thunderstorm.cpp b/src/object/thunderstorm.cpp index ba4e5499d..253c82327 100644 --- a/src/object/thunderstorm.cpp +++ b/src/object/thunderstorm.cpp @@ -86,8 +86,8 @@ void Thunderstorm::expose(HSQUIRRELVM vm, SQInteger table_idx) { if (name == "") return; - scripting::Thunderstorm* interface = new scripting::Thunderstorm(this); - expose_object(vm, table_idx, interface, name, true); + scripting::Thunderstorm* _this = new scripting::Thunderstorm(this); + expose_object(vm, table_idx, _this, name, true); } void diff --git a/src/object/tilemap.cpp b/src/object/tilemap.cpp index a4c851093..1c5466e25 100644 --- a/src/object/tilemap.cpp +++ b/src/object/tilemap.cpp @@ -256,8 +256,8 @@ void TileMap::expose(HSQUIRRELVM vm, SQInteger table_idx) { if (name.empty()) return; - scripting::TileMap* interface = new scripting::TileMap(this); - expose_object(vm, table_idx, interface, name, true); + scripting::TileMap* _this = new scripting::TileMap(this); + expose_object(vm, table_idx, _this, name, true); } void diff --git a/src/object/wind.cpp b/src/object/wind.cpp index 0072fe2d9..49c5a9730 100644 --- a/src/object/wind.cpp +++ b/src/object/wind.cpp @@ -95,8 +95,8 @@ Wind::expose(HSQUIRRELVM vm, SQInteger table_idx) if (name == "") return; - scripting::Wind* interface = new scripting::Wind(this); - expose_object(vm, table_idx, interface, name, true); + scripting::Wind* _this = new scripting::Wind(this); + expose_object(vm, table_idx, _this, name, true); } void diff --git a/src/scripting/functions.cpp b/src/scripting/functions.cpp index 21b33bdbc..6c84d3002 100644 --- a/src/scripting/functions.cpp +++ b/src/scripting/functions.cpp @@ -113,16 +113,6 @@ void load_level(const std::string& filename) g_screen_manager->push_screen(new GameSession(filename, GameSession::current()->get_player_status())); } -static SQInteger squirrel_read_char(SQUserPointer file) -{ - std::istream* in = reinterpret_cast (file); - char c = in->get(); - if(in->eof()) - return 0; - - return c; -} - void import(HSQUIRRELVM vm, const std::string& filename) { IFileStream in(filename); diff --git a/src/scripting/squirrel_util.cpp b/src/scripting/squirrel_util.cpp index ffc7b4f08..d3e50e07b 100644 --- a/src/scripting/squirrel_util.cpp +++ b/src/scripting/squirrel_util.cpp @@ -308,7 +308,7 @@ void print_squirrel_stack(HSQUIRRELVM v) printf("--------------------------------------------------------------\n"); } -static SQInteger squirrel_read_char(SQUserPointer file) +SQInteger squirrel_read_char(SQUserPointer file) { std::istream* in = reinterpret_cast (file); char c = in->get(); diff --git a/src/scripting/squirrel_util.hpp b/src/scripting/squirrel_util.hpp index f419bdf54..aac6492f5 100644 --- a/src/scripting/squirrel_util.hpp +++ b/src/scripting/squirrel_util.hpp @@ -33,6 +33,8 @@ void update_debugger(); std::string squirrel2string(HSQUIRRELVM vm, SQInteger i); void print_squirrel_stack(HSQUIRRELVM vm); +SQInteger squirrel_read_char(SQUserPointer file); + HSQOBJECT create_thread(HSQUIRRELVM vm); SQObject vm_to_object(HSQUIRRELVM vm); HSQUIRRELVM object_to_vm(HSQOBJECT object); diff --git a/src/supertux/colorscheme.cpp b/src/supertux/colorscheme.cpp index 112288d40..462cfe2b9 100644 --- a/src/supertux/colorscheme.cpp +++ b/src/supertux/colorscheme.cpp @@ -1,61 +1,65 @@ +// SuperTux +// Copyright (C) 2009 qMax +// +// 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 3 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, see . + +#include "gui/menu.hpp" +#include "object/floating_text.hpp" +#include "object/level_time.hpp" +#include "object/text_object.hpp" +#include "supertux/levelintro.hpp" +#include "supertux/player_status.hpp" +#include "supertux/statistics.hpp" +#include "supertux/textscroller.hpp" +#include "trigger/climbable.hpp" +#include "trigger/secretarea_trigger.hpp" #include "video/color.hpp" +#include "worldmap/worldmap.hpp" + +Color LevelIntro::header_color(1.0,1.0,0.6); +Color LevelIntro::author_color(1.0,1.0,1.0); +Color LevelIntro::stat_hdr_color(0.2,0.5,1.0); +Color LevelIntro::stat_color(1.0,1.0,1.0); + +Color Statistics::header_color(1.0,1.0,1.0); +Color Statistics::text_color(1.0,1.0,0.6); + +Color Menu::default_color(1.0,1.0,1.0); +Color Menu::active_color(0.2,0.5,1.0); +Color Menu::inactive_color(0.5,0.5,0.5); +Color Menu::label_color(0.0,1.0,1.0); +Color Menu::field_color(1.0,1.0,0.6); + +Color PlayerStatus::text_color(1.0,1.0,0.6); + +Color TextObject::default_color(1.0,1.0,1.0); + +Color FloatingText::text_color(1.0,1.0,0.6); + +Color LevelTime::text_color(1.0,1.0,0.6); + +Color SecretAreaTrigger::text_color(1.0,1.0,0.6); + +Color Climbable::text_color(1.0,1.0,0.6); + +Color worldmap::WorldMap::level_title_color(1.0,1.0,1.0); +Color worldmap::WorldMap::message_color(1.0,1.0,0.6); +Color worldmap::WorldMap::teleporter_message_color(1.0,1.0,1.0); -namespace LevelIntro { -Color header_color(1.0,1.0,0.6); -Color author_color(1.0,1.0,1.0); -Color stat_hdr_color(0.2,0.5,1.0); -Color stat_color(1.0,1.0,1.0); -} - -namespace Statistics { -Color header_color(1.0,1.0,1.0); -Color text_color(1.0,1.0,0.6); -} - -namespace Menu { -Color default_color(1.0,1.0,1.0); -Color active_color(0.2,0.5,1.0); -Color inactive_color(0.5,0.5,0.5); -Color label_color(0.0,1.0,1.0); -Color field_color(1.0,1.0,0.6); -} - -namespace PlayerStatus { -Color text_color(1.0,1.0,0.6); -} - -namespace TextObject { -Color default_color(1.0,1.0,1.0); -} - -namespace FloatingText { -Color text_color(1.0,1.0,0.6); -} - -namespace LevelTime { -Color text_color(1.0,1.0,0.6); -} - -namespace SecretAreaTrigger { -Color text_color(1.0,1.0,0.6); -} - -namespace Climbable { -Color text_color(1.0,1.0,0.6); -} - -namespace worldmap { -namespace WorldMap { -Color level_title_color(1.0,1.0,1.0); -Color message_color(1.0,1.0,0.6); -Color teleporter_message_color(1.0,1.0,1.0); -}} - -namespace TextScroller { -Color small_color(1.0,1.0,1.0); -Color heading_color(1.0,1.0,0.6); -Color reference_color(0.2,0.6,1.0); -Color normal_color(1.0,1.0,1.0); -} +Color TextScroller::small_color(1.0,1.0,1.0); +Color TextScroller::heading_color(1.0,1.0,0.6); +Color TextScroller::reference_color(0.2,0.6,1.0); +Color TextScroller::normal_color(1.0,1.0,1.0); /* EOF */ diff --git a/src/supertux/sector.cpp b/src/supertux/sector.cpp index 126253af0..76ebf067b 100644 --- a/src/supertux/sector.cpp +++ b/src/supertux/sector.cpp @@ -768,11 +768,11 @@ Sector::before_object_add(GameObject* object) void Sector::try_expose(GameObject* object) { - ScriptInterface* interface = dynamic_cast (object); - if(interface != NULL) { + ScriptInterface* object_ = dynamic_cast (object); + if(object_ != NULL) { HSQUIRRELVM vm = scripting::global_vm; sq_pushobject(vm, sector_table); - interface->expose(vm, -1); + object_->expose(vm, -1); sq_pop(vm, 1); } } @@ -782,8 +782,8 @@ Sector::try_expose_me() { HSQUIRRELVM vm = scripting::global_vm; sq_pushobject(vm, sector_table); - scripting::SSector* interface = static_cast (this); - expose_object(vm, -1, interface, "settings", false); + scripting::SSector* this_ = static_cast (this); + expose_object(vm, -1, this_, "settings", false); sq_pop(vm, 1); } @@ -811,13 +811,13 @@ Sector::before_object_remove(GameObject* object) void Sector::try_unexpose(GameObject* object) { - ScriptInterface* interface = dynamic_cast (object); - if(interface != NULL) { + ScriptInterface* object_ = dynamic_cast (object); + if(object_ != NULL) { HSQUIRRELVM vm = scripting::global_vm; SQInteger oldtop = sq_gettop(vm); sq_pushobject(vm, sector_table); try { - interface->unexpose(vm, -1); + object_->unexpose(vm, -1); } catch(std::exception& e) { log_warning << "Couldn't unregister object: " << e.what() << std::endl; } diff --git a/src/video/drawing_context.cpp b/src/video/drawing_context.cpp index 5814c042a..57b0a769e 100644 --- a/src/video/drawing_context.cpp +++ b/src/video/drawing_context.cpp @@ -30,15 +30,6 @@ #include "video/texture_manager.hpp" #include "video/video_systems.hpp" -static inline int next_po2(int val) -{ - int result = 1; - while(result < val) - result *= 2; - - return result; -} - DrawingContext::DrawingContext() : renderer(0), lightmap(0), diff --git a/src/video/drawing_context.hpp b/src/video/drawing_context.hpp index 3bfedc8b5..5715df676 100644 --- a/src/video/drawing_context.hpp +++ b/src/video/drawing_context.hpp @@ -36,6 +36,15 @@ class Texture; class Renderer; class Lightmap; +inline int next_po2(int val) +{ + int result = 1; + while(result < val) + result *= 2; + + return result; +} + /** * This class provides functions for drawing things on screen. It also * maintains a stack of transforms that are applied to graphics. diff --git a/src/video/drawing_request.hpp b/src/video/drawing_request.hpp index 859d952d5..757d19936 100644 --- a/src/video/drawing_request.hpp +++ b/src/video/drawing_request.hpp @@ -32,16 +32,27 @@ class Surface; // some constants for predefined layer values enum { + // Image/gradient backgrounds (should cover entire screen) LAYER_BACKGROUND0 = -300, + // Particle backgrounds LAYER_BACKGROUND1 = -200, + // Tilemap backgrounds LAYER_BACKGROUNDTILES = -100, + // Solid tilemaps LAYER_TILES = 0, + // Ordinary objects LAYER_OBJECTS = 50, + // Objects that pass through walls LAYER_FLOATINGOBJECTS = 150, + // LAYER_FOREGROUNDTILES = 200, + // LAYER_FOREGROUND0 = 300, + // LAYER_FOREGROUND1 = 400, + // Hitpoints, time, coins, etc. LAYER_HUD = 500, + // Menus, mouse, console etc. LAYER_GUI = 600 }; diff --git a/src/video/gl/gl_lightmap.cpp b/src/video/gl/gl_lightmap.cpp index 57b9730a0..30df72a64 100644 --- a/src/video/gl/gl_lightmap.cpp +++ b/src/video/gl/gl_lightmap.cpp @@ -33,6 +33,7 @@ #include "video/drawing_request.hpp" #include "video/font.hpp" #include "video/gl/gl_surface_data.hpp" +#include "video/gl/gl_renderer.hpp" #include "video/gl/gl_texture.hpp" #include "video/glutil.hpp" #include "video/lightmap.hpp" @@ -40,93 +41,6 @@ #include "video/surface.hpp" #include "video/texture_manager.hpp" -namespace { - -inline void intern_draw(float left, float top, float right, float bottom, - float uv_left, float uv_top, - float uv_right, float uv_bottom, - float angle, float alpha, - const Color& color, - const Blend& blend, - DrawingEffect effect) -{ - if(effect & HORIZONTAL_FLIP) - std::swap(uv_left, uv_right); - - if(effect & VERTICAL_FLIP) - std::swap(uv_top, uv_bottom); - - // unrotated blit - glBlendFunc(blend.sfactor, blend.dfactor); - glColor4f(color.red, color.green, color.blue, color.alpha * alpha); - - if (angle == 0.0f) { - float vertices[] = { - left, top, - right, top, - right, bottom, - left, bottom, - }; - glVertexPointer(2, GL_FLOAT, 0, vertices); - - float uvs[] = { - uv_left, uv_top, - uv_right, uv_top, - uv_right, uv_bottom, - uv_left, uv_bottom, - }; - glTexCoordPointer(2, GL_FLOAT, 0, uvs); - - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - } else { - // rotated blit - float center_x = (left + right) / 2; - float center_y = (top + bottom) / 2; - - float sa = sinf(angle/180.0f*M_PI); - float ca = cosf(angle/180.0f*M_PI); - - left -= center_x; - right -= center_x; - - top -= center_y; - bottom -= center_y; - - float vertices[] = { - left*ca - top*sa + center_x, left*sa + top*ca + center_y, - right*ca - top*sa + center_x, right*sa + top*ca + center_y, - right*ca - bottom*sa + center_x, right*sa + bottom*ca + center_y, - left*ca - bottom*sa + center_x, left*sa + bottom*ca + center_y - }; - glVertexPointer(2, GL_FLOAT, 0, vertices); - - float uvs[] = { - uv_left, uv_top, - uv_right, uv_top, - uv_right, uv_bottom, - uv_left, uv_bottom, - }; - glTexCoordPointer(2, GL_FLOAT, 0, uvs); - - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - } - - // FIXME: find a better way to restore the blend mode - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); -} - -static inline int next_po2(int val) -{ - int result = 1; - while(result < val) - result *= 2; - - return result; -} - -} // namespace - GLLightmap::GLLightmap() : screen(), lightmap(), diff --git a/src/video/gl/gl_renderer.cpp b/src/video/gl/gl_renderer.cpp index b27184802..81d874326 100644 --- a/src/video/gl/gl_renderer.cpp +++ b/src/video/gl/gl_renderer.cpp @@ -18,7 +18,6 @@ #include #include -#include #include #include "supertux/gameconfig.hpp" @@ -32,84 +31,6 @@ # define glOrtho glOrthof #endif -namespace { - -inline void intern_draw(float left, float top, float right, float bottom, - float uv_left, float uv_top, - float uv_right, float uv_bottom, - float angle, float alpha, - const Color& color, - const Blend& blend, - DrawingEffect effect) -{ - if(effect & HORIZONTAL_FLIP) - std::swap(uv_left, uv_right); - - if(effect & VERTICAL_FLIP) - std::swap(uv_top, uv_bottom); - - glBlendFunc(blend.sfactor, blend.dfactor); - glColor4f(color.red, color.green, color.blue, color.alpha * alpha); - - // unrotated blit - if (angle == 0.0f) { - float vertices[] = { - left, top, - right, top, - right, bottom, - left, bottom, - }; - glVertexPointer(2, GL_FLOAT, 0, vertices); - - float uvs[] = { - uv_left, uv_top, - uv_right, uv_top, - uv_right, uv_bottom, - uv_left, uv_bottom, - }; - glTexCoordPointer(2, GL_FLOAT, 0, uvs); - - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - } else { - // rotated blit - float center_x = (left + right) / 2; - float center_y = (top + bottom) / 2; - - float sa = sinf(angle/180.0f*M_PI); - float ca = cosf(angle/180.0f*M_PI); - - left -= center_x; - right -= center_x; - - top -= center_y; - bottom -= center_y; - - float vertices[] = { - left*ca - top*sa + center_x, left*sa + top*ca + center_y, - right*ca - top*sa + center_x, right*sa + top*ca + center_y, - right*ca - bottom*sa + center_x, right*sa + bottom*ca + center_y, - left*ca - bottom*sa + center_x, left*sa + bottom*ca + center_y - }; - glVertexPointer(2, GL_FLOAT, 0, vertices); - - float uvs[] = { - uv_left, uv_top, - uv_right, uv_top, - uv_right, uv_bottom, - uv_left, uv_bottom, - }; - glTexCoordPointer(2, GL_FLOAT, 0, uvs); - - glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - } - - // FIXME: find a better way to restore the blend mode - glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); -} - -} // namespace - GLRenderer::GLRenderer() : desktop_size(-1, -1), screen_size(-1, -1), diff --git a/src/video/gl/gl_renderer.hpp b/src/video/gl/gl_renderer.hpp index a11ddfb37..9e208597b 100644 --- a/src/video/gl/gl_renderer.hpp +++ b/src/video/gl/gl_renderer.hpp @@ -18,8 +18,91 @@ #define HEADER_SUPERTUX_VIDEO_GL_RENDERER_HPP #include "math/size.hpp" +#include "video/drawing_request.hpp" #include "video/renderer.hpp" +#include + +namespace { + +inline void intern_draw(float left, float top, float right, float bottom, + float uv_left, float uv_top, + float uv_right, float uv_bottom, + float angle, float alpha, + const Color& color, + const Blend& blend, + DrawingEffect effect) +{ + if(effect & HORIZONTAL_FLIP) + std::swap(uv_left, uv_right); + + if(effect & VERTICAL_FLIP) + std::swap(uv_top, uv_bottom); + + glBlendFunc(blend.sfactor, blend.dfactor); + glColor4f(color.red, color.green, color.blue, color.alpha * alpha); + + // unrotated blit + if (angle == 0.0f) { + float vertices[] = { + left, top, + right, top, + right, bottom, + left, bottom, + }; + glVertexPointer(2, GL_FLOAT, 0, vertices); + + float uvs[] = { + uv_left, uv_top, + uv_right, uv_top, + uv_right, uv_bottom, + uv_left, uv_bottom, + }; + glTexCoordPointer(2, GL_FLOAT, 0, uvs); + + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + } else { + // rotated blit + float center_x = (left + right) / 2; + float center_y = (top + bottom) / 2; + + float sa = sinf(angle/180.0f*M_PI); + float ca = cosf(angle/180.0f*M_PI); + + left -= center_x; + right -= center_x; + + top -= center_y; + bottom -= center_y; + + float vertices[] = { + left*ca - top*sa + center_x, left*sa + top*ca + center_y, + right*ca - top*sa + center_x, right*sa + top*ca + center_y, + right*ca - bottom*sa + center_x, right*sa + bottom*ca + center_y, + left*ca - bottom*sa + center_x, left*sa + bottom*ca + center_y + }; + glVertexPointer(2, GL_FLOAT, 0, vertices); + + float uvs[] = { + uv_left, uv_top, + uv_right, uv_top, + uv_right, uv_bottom, + uv_left, uv_bottom, + }; + glTexCoordPointer(2, GL_FLOAT, 0, uvs); + + glDrawArrays(GL_TRIANGLE_FAN, 0, 4); + } + + // FIXME: find a better way to restore the blend mode + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); +} + +} // namespace + + + class GLRenderer : public Renderer { private: diff --git a/src/worldmap/worldmap.cpp b/src/worldmap/worldmap.cpp index 05004ed2a..372196db7 100644 --- a/src/worldmap/worldmap.cpp +++ b/src/worldmap/worldmap.cpp @@ -186,11 +186,11 @@ WorldMap::add_object(GameObject* object) void WorldMap::try_expose(GameObject* object) { - ScriptInterface* interface = dynamic_cast (object); - if(interface != NULL) { + ScriptInterface* object_ = dynamic_cast (object); + if(object_ != NULL) { HSQUIRRELVM vm = scripting::global_vm; sq_pushobject(vm, worldmap_table); - interface->expose(vm, -1); + object_->expose(vm, -1); sq_pop(vm, 1); } } @@ -198,13 +198,13 @@ WorldMap::try_expose(GameObject* object) void WorldMap::try_unexpose(GameObject* object) { - ScriptInterface* interface = dynamic_cast (object); - if(interface != NULL) { + ScriptInterface* object_ = dynamic_cast (object); + if(object_ != NULL) { HSQUIRRELVM vm = scripting::global_vm; SQInteger oldtop = sq_gettop(vm); sq_pushobject(vm, worldmap_table); try { - interface->unexpose(vm, -1); + object_->unexpose(vm, -1); } catch(std::exception& e) { log_warning << "Couldn't unregister object: " << e.what() << std::endl; }