(image "arctis.jpg")
(speed 0.500000)
)
- (path (name "path1") (speed 100) (x 0) (y 0) (x 0) (y -100) (x 100) (y -100) (x 100) (y 0))
- (path (name "path2") (speed 100) (x 0) (y 0) (x 0) (y 100) (x 100) (y 100) (x 100) (y 0))
+ (path (name "path1") (circular #t) (speed 100) (x 0) (y 0) (x 0) (y -100) (x 100) (y -100) (x 100) (y 0))
+ (path (name "path2") (circular #t) (speed 100) (x 0) (y 0) (x 0) (y 100) (x 100) (y 100) (x 100) (y 0))
(platform (use_path "path1") (x 200) (y 850) (type "block1"))
(platform (use_path "path1") (x 232) (y 850) (type "block2"))
(platform (use_path "path2") (x 264) (y 650) (type "block2"))
-// $Id:$
+// $Id$
//
// SuperTux
// Copyright (C) 2005 Philipp <balinor@pnxs.de>
Path::Path(const lisp::Lisp& reader)
{
+ forward = true;
float x,y;
lisp::ListIterator iter(&reader);
assert(token == "name");
iter.value()->get(name);
+ circular = true;
+ assert (iter.next());
+ token = iter.item();
+ assert(token == "circular");
+ iter.value()->get(circular);
+
pixels_per_second = DEFAULT_PIXELS_PER_SECOND;
assert (iter.next());
token = iter.item();
void
Path::draw(DrawingContext& context)
{
- // NOOP ;-)
+ // TODO: Add a visible flag, draw the path if true
}
const Vector&
{
Vector distance;
- ++next_target;
- if (next_target == points.end()) {
- next_target = points.begin();
+ if (circular) {
+ ++next_target;
+ if (next_target == points.end()) {
+ next_target = points.begin();
+ }
+ }
+ else if (forward) {
+ ++next_target;
+ if (next_target == points.end()) {
+ forward = false;
+ }
+ }
+ else {
+ //FIXME: Implement going backwards on the list
+ // I have no f***ing idea how this is done in C++
}
distance = *next_target - pos;
-// $Id:$
+// $Id$
//
// SuperTux
// Copyright (C) 2005 Philipp <balinor@pnxs.de>
static Path* GetByName(const std::string& name);
private:
- std::string name;
- float pixels_per_second;
- PathPoints points;
- PathPointIter next_target;
- Vector pos;
- Vector velocity;
- Vector last_movement;
+ std::string name;
+ float pixels_per_second;
+ PathPoints points;
+ PathPointIter next_target;
+ Vector pos;
+ Vector velocity;
+ Vector last_movement;
+
+ bool circular;
+ bool forward;
void calc_next_velocity();
flags |= FLAG_SOLID;
path = Path::GetByName(use_path);
+ if (path == NULL) {
+ std::cerr << "Warning: Path for moving platform not found! Make sure that the name is spelled correctly,\nand that the path is initialized before the platform in the level file!\n";
+ }
path_offset = bbox.p1 - path->GetStart();
}
delete sprite;
}
+//TODO: Squish Tux when standing between platform and solid tile/object
+// Improve collision handling
+// Move all MovingObjects lying on the platform instead of only the player
HitResponse
Platform::collision(GameObject& other, const CollisionHit& hit)
{
if(other.get_flags() & FLAG_SOLID) {
//Collision with a solid tile
//does nothing, because the movement vector isn't used at the moment
+ return ABORT_MOVE;
}
return FORCE_MOVE;
}