X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fobject%2Fgameobjs.cpp;h=bce0f212340e7efb8538ca73120940ef21e78434;hb=40e6e7cdc59c09befbd2595aea0c6e10428315d4;hp=3201eb285fe817eba0f1a07d3a33d3a1d7af195a;hpb=6f801c22d97251799740317fb1d0caf2e744b321;p=supertux.git diff --git a/src/object/gameobjs.cpp b/src/object/gameobjs.cpp index 3201eb285..bce0f2123 100644 --- a/src/object/gameobjs.cpp +++ b/src/object/gameobjs.cpp @@ -146,289 +146,6 @@ FloatingText::draw(DrawingContext& context) context.pop_transform(); } -/* Trampoline */ - -#if 0 -Sprite *img_trampoline; - -Trampoline::Trampoline(LispReader& reader) -{ - reader.read_float("x", base.x); - reader.read_float("y", base.y); - base.width = 32; - base.height = 32; - power = 7.5; - reader.read_float("power", power); - - frame = 0; - mode = M_NORMAL; - physic.reset(); -} - -Trampoline::Trampoline(float x, float y) -{ - base.x = x; - base.y = y; - base.width = 32; - base.height = 32; - power = 7.5; - - frame = 0; - mode = M_NORMAL; - physic.reset(); -} - -void -Trampoline::write(LispWriter& writer) -{ - writer.start_list("trampoline"); - - writer.write_float("x", base.x); - writer.write_float("y", base.y); - writer.write_float("power", power); - - writer.end_list("trampoline"); -} - -void -Trampoline::draw(DrawingContext& context) -{ - img_trampoline->set_frame(frame); - img_trampoline->draw(context, base, LAYER_OBJECTS); - frame = 0; -} - -void -Trampoline::action(float frame_ratio) -{ - // TODO: Remove if we're too far off the screen - - // Falling - if (mode != M_HELD) - { - if (issolid(base.x + base.width/2, base.y + base.height)) - { - base.y = int((base.y + base.height)/32) * 32 - base.height; - - physic.enable_gravity(false); - physic.set_velocity_y(0.0f); - - physic.set_velocity_x(0); - } - else - { - physic.enable_gravity(true); - } - } - else // Player is carrying us around - { - /* FIXME: The trampoline object shouldn't know about pplayer objects. */ - /* If we're holding the iceblock */ - Player& tux = *Sector::current()->player; - Direction dir = tux.dir; - - if(dir == RIGHT) - { - base.x = tux.base.x + 16; - base.y = tux.base.y + tux.base.height/1.5 - base.height; - } - else /* facing left */ - { - base.x = tux.base.x - 16; - base.y = tux.base.y + tux.base.height/1.5 - base.height; - } - - if(collision_object_map(base)) - { - base.x = tux.base.x; - base.y = tux.base.y + tux.base.height/1.5 - base.height; - } - } - - physic.apply(frame_ratio, base.x, base.y, Sector::current()->gravity); - collision_swept_object_map(&old_base, &base); -} - -void -Trampoline::collision(const MovingObject&, int) -{ - // comes later -} - -void -Trampoline::collision(void *p_c_object, int c_object, CollisionType type) -{ - Player* pplayer_c = NULL; - switch (c_object) - { - case CO_PLAYER: - pplayer_c = (Player*) p_c_object; - - if (type == COLLISION_NORMAL) - { - // Pick up if HELD (done in Player) - } - - else if (type == COLLISION_SQUISH) - { - int squish_amount = (32 - (int)pplayer_c->base.y % 32); - - if (squish_amount < 24) - frame = 3; - else if (squish_amount < 28) - frame = 2; - else if (squish_amount < 30) - frame = 1; - else - frame = 0; - - if (squish_amount < 20) { - pplayer_c->physic.set_velocity_y(power); - pplayer_c->fall_mode = Player::TRAMPOLINE_JUMP; - } - else if (pplayer_c->physic.get_velocity_y() < 0) - pplayer_c->physic.set_velocity_y(-squish_amount/32); - } - - break; - - default: - break; - - } -} -#endif - -/* Flying Platform */ - -#if 0 -Sprite *img_flying_platform; - -FlyingPlatform::FlyingPlatform(LispReader& reader) -{ - reader.read_int_vector("x", pos_x); - reader.read_int_vector("y", pos_y); - - velocity = 2.0; - reader.read_float("velocity", velocity); - - base.x = pos_x[0]; - base.y = pos_y[0]; - base.width = 96; - base.height = 40; - - point = 0; - move = false; - - float x = pos_x[point+1] - pos_x[point]; - float y = pos_y[point+1] - pos_y[point]; - vel_x = x*velocity / sqrt(x*x + y*y); - vel_y = -(velocity - vel_x); - - frame = 0; -} - -FlyingPlatform::FlyingPlatform(int x, int y) -{ -base.x = x; -base.y = y; -point = 0; -move = false; -} - -void -FlyingPlatform::write(LispWriter& writer) -{ - writer.start_list("flying-trampoline"); - - writer.write_int_vector("x", pos_x); - writer.write_int_vector("y", pos_y); - writer.write_float("velocity", velocity); - - writer.end_list("flying-trampoline"); -} - -void -FlyingPlatform::draw(DrawingContext& context) -{ - img_flying_platform->draw(context, base, LAYER_OBJECTS); -} - -void -FlyingPlatform::action(float frame_ratio) -{ - // TODO: Remove if we're too far off the screen - -if(!move) - return; - -if((unsigned)point+1 != pos_x.size()) - { - if(((pos_x[point+1] > pos_x[point] && base.x >= pos_x[point+1]) || - (pos_x[point+1] < pos_x[point] && base.x <= pos_x[point+1]) || - pos_x[point] == pos_x[point+1]) && - ((pos_y[point+1] > pos_y[point] && base.y >= pos_y[point+1]) || - (pos_y[point+1] < pos_y[point] && base.y <= pos_y[point+1]) || - pos_y[point] == pos_y[point+1])) - { - point++; - - float x = pos_x[point+1] - pos_x[point]; - float y = pos_y[point+1] - pos_y[point]; - vel_x = x*velocity / sqrt(x*x + y*y); - vel_y = -(velocity - vel_x); - } - } -else // last point - { - // point = 0; - // reverse vector - return; - } -/* -if(pos_x[point+1] > base.x) - base.x += velocity * frame_ratio; -else if(pos_x[point+1] < base.x) - base.x -= velocity * frame_ratio; - -if(pos_y[point+1] > base.y) - base.y += velocity * frame_ratio; -else if(pos_y[point+1] < base.y) - base.y -= velocity * frame_ratio; -*/ - -base.x += vel_x * frame_ratio; -base.y += vel_y * frame_ratio; -} - -void -FlyingPlatform::collision(const MovingObject&, int) -{ - // comes later -} - -void -FlyingPlatform::collision(void *p_c_object, int c_object, CollisionType type) -{ -(void) p_c_object; -(void) type; - -// Player* pplayer_c = NULL; - switch (c_object) - { - case CO_PLAYER: -// pplayer_c = (Player*) p_c_object; - move = true; - - break; - - default: - break; - - } -} -#endif - Sprite *img_smoke_cloud = 0; SmokeCloud::SmokeCloud(const Vector& pos)