Skip to content
Snippets Groups Projects
Commit 63528231 authored by antoinemeyer5's avatar antoinemeyer5
Browse files

fix zone de shoot de la balle

parent 71c8f27c
No related branches found
No related tags found
No related merge requests found
......@@ -62,31 +62,35 @@ void hitBall()
// printf("map edges: %d %d\n", BLOCK_SIZE * MAP_WIDTH/2, BLOCK_SIZE *MAP_HEIGHT/2);
// printf("ray1: %d %d\n", ray1[0], ray1[1]);
int fermetureAngle = 2;
int angleMin = RD * atan2((MAP_WIDTH+fermetureAngle / 2) * BLOCK_SIZE - player.x, player.y);
int angleMax = RD * atan2((MAP_WIDTH+fermetureAngle / 2) * BLOCK_SIZE - player.x, MAP_HEIGHT * BLOCK_SIZE - player.y);
//int angleMin = RD * atan2((MAP_WIDTH+fermetureAngle / 2) * BLOCK_SIZE - player.x, player.y);
//int angleMax = 90 + RD * atan2((MAP_WIDTH+fermetureAngle / 2) * BLOCK_SIZE - player.x, MAP_HEIGHT * BLOCK_SIZE - player.y);
int currAngle = (int)((player.angle) * RD + 90) % 360;
// printf("player angle: %d\n",(int) ((player.angle) * RD +90) %360);
// 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 (currAngle < angleMax && currAngle > angleMin)
int rxWall, ryWall;
float distanceWall;
int rxNet, ryNet;
float distanceNet;
castSingleRay(player.angle, &distanceWall, &distanceNet, &rxWall, &ryWall, &rxNet, &ryNet);
printf("rayWall: %d %d\n", rxWall/BLOCK_SIZE, ryWall/BLOCK_SIZE);
printf("distanceWall: %f\n", distanceWall);
printf("rayNet: %d %d\n", rxNet/BLOCK_SIZE, ryNet/BLOCK_SIZE);
printf("distanceNet: %f\n", distanceNet);
if (rxWall > MAP_WIDTH/2)
{
// printf("hit\n");
if (player.isHitting)
{
freeIntList(landingPoint);
freeIntList(lastHitPoint);
int rxWall, ryWall;
float distanceWall;
int rxNet, ryNet;
float distanceNet;
castSingleRay(player.angle, &distanceWall, &distanceNet, &rxWall, &ryWall, &rxNet, &ryNet);
printf("rayWall: %d %d\n", rxWall/BLOCK_SIZE, ryWall/BLOCK_SIZE);
printf("distanceWall: %f\n", distanceWall);
printf("rayNet: %d %d\n", rxNet/BLOCK_SIZE, ryNet/BLOCK_SIZE);
printf("distanceNet: %f\n", distanceNet);
lastHitPoint = allocLastHitPoint();
......
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