Ejemplo n.º 1
0
int entity::feet_x() const
{
	if(solid_) {
		const int diff = solid_->area().x() + solid_->area().w()/2;
		return face_right() ? x() + diff : x() + current_frame().width() - diff;
	}
	return face_right() ? x() + current_frame().feet_x() : x() + current_frame().width() - current_frame().feet_x();
}
Ejemplo n.º 2
0
rect entity::body_rect() const
{
	const frame& f = current_frame();

	const int ypos = y() + (upside_down() ? (f.height() - (f.collide_y() + f.collide_h())) : f.collide_y());
	return rect(face_right() ? x() + f.collide_x() : x() + f.width() - f.collide_x() - f.collide_w(),
	            ypos, f.collide_w(), f.collide_h());
}
Ejemplo n.º 3
0
rect entity::hit_rect() const
{
	const frame& f = current_frame();
	const std::vector<frame::collision_area>& areas = f.collision_areas();
	foreach(const frame::collision_area& a, areas) {
		if(a.name == "attack") {
			const rect& r = a.area;
			return rect(face_right() ? x() + r.x() : x() + f.width() - r.x() - r.w(), y() + r.y(), r.w(), r.h());
		}
	}

	return rect();
}
Ejemplo n.º 4
0
point entity::pivot(const std::string& name, bool reverse_facing) const
{
	const frame& f = current_frame();
	if(name == "") {
		return midpoint();
	}

	bool facing_right = face_right();
	if(reverse_facing) {
		facing_right = !facing_right;
	}

	const point pos = f.pivot(name, time_in_frame());
	if(facing_right) {
		return point(x() + pos.x, y() + pos.y);
	} else {
		return point(x() + f.width() - pos.x, y() + pos.y);
	}
}
Ejemplo n.º 5
0
void entity::calculate_solid_rect()
{
	const frame& f = current_frame();

	frame_rect_ = rect(x(), y(), f.width(), f.height());
	
	solid_ = calculate_solid();
	if(solid_) {
		const rect& area = solid_->area();

		if(face_right()) {
			solid_rect_ = rect(x() + area.x(), y() + area.y(), area.w(), area.h());
		} else {
			solid_rect_ = rect(x() + f.width() - area.x() - area.w(), y() + area.y(), area.w(), area.h());
		}
	} else {
		solid_rect_ = rect();
	}

	platform_ = calculate_platform();
	if(platform_) {
		const int delta_y = last_move_y();
		const rect& area = platform_->area();
		
		if(area.empty()) {
			platform_rect_ = rect();
		} else {
			if(delta_y < 0) {
				platform_rect_ = rect(x() + area.x(), y() + area.y(), area.w(), area.h() - delta_y);
			} else {
				platform_rect_ = rect(x() + area.x(), y() + area.y(), area.w(), area.h());
			}
		}
	} else {
		platform_rect_ = rect();
	}
}
Ejemplo n.º 6
0
	int face_dir() const { return face_right() ? 1 : -1; }
Ejemplo n.º 7
0
bool entity::is_alpha(int xpos, int ypos) const
{
	return current_frame().is_alpha(xpos - x(), ypos - y(), time_in_frame(), face_right());
}