(path
(mode "pingpong")
(node (x 200) (y 850))
- (node (x 200) (y 750))
+ (node (x 200) (y 750) (time 0.5))
(node (x 100) (y 750))
)
(sprite "images/objects/platforms/small.sprite")
(platform
(path
(mode "circular")
- (node (x 392) (y 850) (time 1))
+ (node (x 392) (y 850) (time 1))
(node (x 392) (y 750) (time 1))
(node (x 392) (y 650) (time 0.6))
(node (x 392) (y 750) (time 1))
(speed 0.5)
(speed-y 1.0)
)
- (path
- (name "path1")
- (circular #t)
- (nodes
- (node (x 0) (y 0) (time 3))
- (node (x 0) (y 0) (time 1))
- (node (x 0) (y -416) (time 3))
- (node (x 0) (y -416) (time 1))
- )
- )
- (path
- (name "path2")
- (circular #t)
- (nodes
- (node (x 0) (y 0) (time 3))
- (node (x 0) (y 0) (time 1))
- (node (x 0) (y 416) (time 3))
- (node (x 0) (y 416) (time 1))
- )
- )
- (path
- (name "path3")
- (circular #t)
- (nodes
- (node (x 0) (y 0) (time 1))
- (node (x 0) (y 0) (time 1))
- (node (x 0) (y -448) (time 2))
- (node (x 0) (y -448) (time 1))
- )
- )
(spawnpoint
(x 96)
(y 1306)
}
HitResponse
-BadGuy::collision_player(Player& player, const CollisionHit& )
+BadGuy::collision_player(Player& player, const CollisionHit& hit)
{
if(player.is_invincible()) {
kill_fall();
return ABORT_MOVE;
}
+ printf("PlayerHit: PM: %3.1f %3.1f BM: %3.1f %3.1f Hit: %3.1f %3.1f\n",
+ player.get_movement().x, player.get_movement().y,
+ get_movement().x, get_movement().y,
+ hit.normal.x, hit.normal.y);
// hit from above?
- if(player.get_movement().y - get_movement().y > 0 && player.get_bbox().p2.y <
+ if(player.get_movement().y /*- get_movement().y*/ > 0
+ && player.get_bbox().p2.y <
(get_bbox().p1.y + get_bbox().p2.y) / 2) {
// if it's not possible to squish us, then this will hurt
if(collision_squished(player))
walking_speed(1.0)
{
last_pos = path->nodes[0].position;
- node_time = path->nodes[0].time;
+ node_mult = 1 / path->nodes[0].time;
}
PathWalker::~PathWalker()
elapsed_time *= fabsf(walking_speed);
const Path::Node* current_node = & (path->nodes[current_node_nr]);
- while(node_time - elapsed_time < 0) {
- elapsed_time -= current_node->time - node_time;
+ while(node_time + elapsed_time * node_mult >= 1) {
+ elapsed_time -= (1 - node_time) * node_mult;
if(walking_speed > 0) {
advance_node();
}
current_node = & (path->nodes[current_node_nr]);
+ node_time = 0;
if(walking_speed > 0) {
- node_time = current_node->time;
+ node_mult = 1 / current_node->time;
} else {
- node_time = path->nodes[next_node_nr].time;
+ node_mult = 1 / path->nodes[next_node_nr].time;
}
}
const Path::Node* next_node = & (path->nodes[next_node_nr]);
- node_time -= elapsed_time;
+ node_time += elapsed_time * node_mult;
Vector new_pos = current_node->position +
- (next_node->position - current_node->position)
- * (1 - (node_time / current_node->time));
+ (next_node->position - current_node->position) * node_time;
Vector result = new_pos - last_pos;
last_pos = new_pos;
Vector last_pos;
- /** the time we already spend in the current node */
+ /**
+ * the position between the current node and the next node as fraction
+ * between 0 and 1
+ */
float node_time;
+ float node_mult;
float walking_speed;
};
float y2 = dest.p2.y;
// test with all tiles in this rectangle
- int starttilex = int(x1-1) / 32;
- int starttiley = int(y1-1) / 32;
- int max_x = int(x2+1);
- int max_y = int(y2+1);
+ int starttilex = int(x1) / 32;
+ int starttiley = int(y1) / 32;
+ int max_x = int(x2);
+ int max_y = int(y2);
uint32_t result = 0;
for(int x = starttilex; x*32 < max_x; ++x) {