Skip to content
Snippets Groups Projects
Commit 86a48a76 authored by belkhiritaha's avatar belkhiritaha
Browse files

fix des bugs visuels en cours

parent b9fab8c3
No related branches found
No related tags found
No related merge requests found
...@@ -72,7 +72,7 @@ void hitBall(){ ...@@ -72,7 +72,7 @@ void hitBall(){
//printf("distance to ball: %f\n", sqrt(pow(ball.x - player.x, 2) + pow(ball.y - player.y, 2))/BLOCK_SIZE); //printf("distance to ball: %f\n", sqrt(pow(ball.x - player.x, 2) + pow(ball.y - player.y, 2))/BLOCK_SIZE);
if (sqrt(pow(player.x - ball.x, 2) + pow(player.y - ball.y, 2))/BLOCK_SIZE < HIT_RANGE){ if (sqrt(pow(player.x - ball.x, 2) + pow(player.y - ball.y, 2))/BLOCK_SIZE < HIT_RANGE){
if (currAngle < angleMax && currAngle > angleMin){ if (currAngle < angleMax && currAngle > angleMin){
printf("hit\n"); //printf("hit\n");
freeIntList(landingPoint); freeIntList(landingPoint);
freeIntList(lastHitPoint); freeIntList(lastHitPoint);
lastHitPoint = allocLastHitPoint(); lastHitPoint = allocLastHitPoint();
...@@ -87,10 +87,10 @@ void hitBall(){ ...@@ -87,10 +87,10 @@ void hitBall(){
ball.speed = HIT_FORCE; ball.speed = HIT_FORCE;
ball.isHit = 1; ball.isHit = 1;
} }
printf("valid hit\n"); //printf("valid hit\n");
} }
else { else {
printf("unvalid hit\n"); //printf("unvalid hit\n");
} }
} }
//} //}
...@@ -102,7 +102,7 @@ void updateBall(){ ...@@ -102,7 +102,7 @@ void updateBall(){
if (ball.isHit){ if (ball.isHit){
ball.z = lagrangeInterpolation(ball.x, lastHitPoint[0], lastHitPoint[1], 15 , 2*player.h, landingPoint[0], 0); ball.z = lagrangeInterpolation(ball.x, lastHitPoint[0], lastHitPoint[1], 15 , 2*player.h, landingPoint[0], 0);
} }
//printf("ball position: %f %f %f\n", ball.x/BLOCK_SIZE, ball.y/BLOCK_SIZE, ball.z/BLOCK_SIZE); //printf("ball position: %f %f %f\n", ball.x/BLOCK_SIZE, ball.y/BLOCK_SIZE, ball.z);
} }
......
...@@ -409,8 +409,8 @@ void castRays(int map[][MAP_WIDTH]){ ...@@ -409,8 +409,8 @@ void castRays(int map[][MAP_WIDTH]){
//printf("%d %d\n", (int)rx, (int)ry); //printf("%d %d\n", (int)rx, (int)ry);
ray2[0] = (int)rx; ray2[0] = (int)rx;
ray2[1] = (int)ry; ray2[1] = (int)ry;
printf("ray1 %d %d\n", ray1[0]/BLOCK_SIZE, ray1[1]/BLOCK_SIZE); //printf("ray1 %d %d\n", ray1[0]/BLOCK_SIZE, ray1[1]/BLOCK_SIZE);
printf("ray2 %d %d\n", ray2[0]/BLOCK_SIZE, ray2[1]/BLOCK_SIZE); ///printf("ray2 %d %d\n", ray2[0]/BLOCK_SIZE, ray2[1]/BLOCK_SIZE);
} }
//printf("raylistlength %d\n", raysListLength); //printf("raylistlength %d\n", raysListLength);
addRayToList(rx, ry); addRayToList(rx, ry);
...@@ -435,6 +435,8 @@ void drawEnnemy(){ ...@@ -435,6 +435,8 @@ void drawEnnemy(){
//printf("%f\n", player.angle * RD); //printf("%f\n", player.angle * RD);
if (ennemyAngle >= player.angle - (FOV_ANGLE)/2 * DR && ennemyAngle <= player.angle + (FOV_ANGLE)/2 * DR){ if (ennemyAngle >= player.angle - (FOV_ANGLE)/2 * DR && ennemyAngle <= player.angle + (FOV_ANGLE)/2 * DR){
//printf("player angle %f\n", player.angle * RD);
//printf("ennemy angle %f\n", ennemyAngle * RD);
rect.x = screenDimension.w/2 + (screenDimension.w * tan(ennemyAngle - player.angle)) * sqrt(3) * 0.5; rect.x = screenDimension.w/2 + (screenDimension.w * tan(ennemyAngle - player.angle)) * sqrt(3) * 0.5;
rect.w = (ennemyWidth * screenDimension.w) / (ennemyDistance/BLOCK_SIZE); rect.w = (ennemyWidth * screenDimension.w) / (ennemyDistance/BLOCK_SIZE);
rect.h = (ennemyHeight * screenDimension.h)/(ennemyDistance/BLOCK_SIZE); rect.h = (ennemyHeight * screenDimension.h)/(ennemyDistance/BLOCK_SIZE);
...@@ -446,8 +448,6 @@ void drawEnnemy(){ ...@@ -446,8 +448,6 @@ void drawEnnemy(){
destRect.w = 64; destRect.w = 64;
destRect.h = 64; destRect.h = 64;
float angleSum = ennemyAngle + player.angle; float angleSum = ennemyAngle + player.angle;
printf("player angle %f\n", player.angle * RD);
printf("ennemy angle %f\n", ennemyAngle * RD);
if (angleSum > 2*pi) angleSum -= 2*pi; if (angleSum > 2*pi) angleSum -= 2*pi;
if (angleSum < 0) angleSum += 2*pi; if (angleSum < 0) angleSum += 2*pi;
...@@ -481,8 +481,14 @@ void drawBall(){ ...@@ -481,8 +481,14 @@ void drawBall(){
float scaledBallWidth = ballBaseWidth / sqrt(3); float scaledBallWidth = ballBaseWidth / sqrt(3);
int ballWidth = 25; int ballWidth = 25;
int ballHeight = 25; int ballHeight = 25;
float angleMin = player.angle - (FOV_ANGLE)/2 * DR;
if (ballAngle >= player.angle - (FOV_ANGLE)/2 * DR && ballAngle <= player.angle + (FOV_ANGLE)/2 * DR){ float angleMax = player.angle + (FOV_ANGLE)/2 * DR;
printf("ball angle: %f player angle: %f\n", ballAngle * RD, player.angle * RD);
printf("limit angles: %f %f\n", angleMin, angleMax);
if (ballAngle >= angleMin && ballAngle <= angleMax){
rect.x = screenDimension.w/2 + (screenDimension.w * tan(ballAngle - player.angle)) * sqrt(3) * 0.5; rect.x = screenDimension.w/2 + (screenDimension.w * tan(ballAngle - player.angle)) * sqrt(3) * 0.5;
rect.w = (ballWidth * screenDimension.w) / (ballDistance/BLOCK_SIZE); rect.w = (ballWidth * screenDimension.w) / (ballDistance/BLOCK_SIZE);
rect.h = (ballHeight * screenDimension.h)/(ballDistance/BLOCK_SIZE); rect.h = (ballHeight * screenDimension.h)/(ballDistance/BLOCK_SIZE);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment