diff options
| author | Treeki <treeki@gmail.com> | 2013-02-12 23:41:03 +0100 | 
|---|---|---|
| committer | Treeki <treeki@gmail.com> | 2013-02-12 23:41:03 +0100 | 
| commit | ed2d963a8fe18aee69a1ac9747c8af99705a9f4f (patch) | |
| tree | 619e1e8f601cdfa340043dc7db2a198426536c99 /src | |
| parent | 07fc6376d5b74531518327ffd5f1316a7d59f72f (diff) | |
| download | kamek-ed2d963a8fe18aee69a1ac9747c8af99705a9f4f.tar.gz kamek-ed2d963a8fe18aee69a1ac9747c8af99705a9f4f.zip | |
jumping and player Z order fix for maps
Diffstat (limited to '')
| -rw-r--r-- | src/koopatlas/pathmanager.cpp | 47 | ||||
| -rw-r--r-- | src/koopatlas/player.cpp | 2 | 
2 files changed, 37 insertions, 12 deletions
| diff --git a/src/koopatlas/pathmanager.cpp b/src/koopatlas/pathmanager.cpp index 169668b..0ef89fc 100644 --- a/src/koopatlas/pathmanager.cpp +++ b/src/koopatlas/pathmanager.cpp @@ -687,22 +687,45 @@ void dWMPathManager_c::moveThroughPath(int pressedDir) {  	VECScale(&move, &move, moveSpeed);  	if (isJumping) { -		float ys = (float)from->y; -		float ye = (float)to->y; -		float midpoint = (from->y + to->y) / 2; +		bool isFalling; +		if (from->y == to->y) { +			float xDistance = to->x - from->x; +			if (xDistance < 0) +				xDistance = -xDistance; +			float currentPoint = max(to->x, from->x) - player->pos.x; +			player->jumpOffset = (xDistance / 3.0f) * sin((currentPoint / xDistance) * 3.1415f); + +			if (to->x > from->x) // Moving right +				isFalling = (player->pos.x > (to->x - (move.x * 10.0f))); +			else // Moving left +				isFalling = (player->pos.x < (to->x + (move.x * 10.0f))); -		float top, len; -		if (ys > ye) { len = ys - ye; top = ys - midpoint + 10.0; } -		else		 { len = ye - ys; top = ye - midpoint + 10.0; } +		} else { +			float ys = (float)from->y; +			float ye = (float)to->y; +			float midpoint = (from->y + to->y) / 2; + +			float top, len; +			if (ys > ye) { len = ys - ye; top = ys - midpoint + 10.0; } +			else		 { len = ye - ys; top = ye - midpoint + 10.0; } + +			if (len == 0.0) { len = 2.0; } -		if (len == 0.0) { len = 2.0; } +			float a; +			if (timer > 0.0) { a = -timer; } +			else			 { a =  timer; } -		float a; -		if (timer > 0.0) { a = -timer; } -		else			 { a =  timer; } -		player->jumpOffset = -sin(a * 3.14 / len) * top; -		timer -= move.y; +			player->jumpOffset = -sin(a * 3.14 / len) * top; +			timer -= move.y; + +			if (ye > ys) // Moving down +				isFalling = (-player->pos.y) > (ye - (move.y * 10.0f)); +			else // Moving up +				isFalling = (-player->pos.y) < (ye + (move.y * 10.0f)); +		} +		if (isFalling) +			player->startAnimation(jumped, 1.0f, 10.0f, 0.0f);  	}  	player->pos.x += move.x; diff --git a/src/koopatlas/player.cpp b/src/koopatlas/player.cpp index 00092cd..e549871 100644 --- a/src/koopatlas/player.cpp +++ b/src/koopatlas/player.cpp @@ -53,6 +53,8 @@ int daWMPlayer_c::onExecute() {  	mMtx myMatrix;  	myMatrix.scale(scale.x, scale.y, scale.z);  	myMatrix.applyTranslation(pos.x, pos.y + jumpOffset, pos.z); +	if (dScKoopatlas_c::instance->warpZoneHacks && (currentAnim == jump || currentAnim == jumped)) +		myMatrix.applyTranslation(0, 0, 600.0f);  	myMatrix.applyRotationX(&rot.x);  	myMatrix.applyRotationY(&rot.y);  	// Z is unused for now | 
