Skip to content
Snippets Groups Projects
Commit f1eb5050 authored by Taha Belkhiri's avatar Taha Belkhiri
Browse files

ajout de nouvelles textures

parent 71c8f27c
No related branches found
No related tags found
No related merge requests found
travail_de_groupe/jeu_appren_par_renfo/Res/net.png

294 B | W: | H:

travail_de_groupe/jeu_appren_par_renfo/Res/net.png

222 B | W: | H:

travail_de_groupe/jeu_appren_par_renfo/Res/net.png
travail_de_groupe/jeu_appren_par_renfo/Res/net.png
travail_de_groupe/jeu_appren_par_renfo/Res/net.png
travail_de_groupe/jeu_appren_par_renfo/Res/net.png
  • 2-up
  • Swipe
  • Onion skin
travail_de_groupe/jeu_appren_par_renfo/Res/netLeft.png

249 B

travail_de_groupe/jeu_appren_par_renfo/Res/netRight.png

251 B

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
\ No newline at end of file
......@@ -63,10 +63,12 @@ void hitBall()
// 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 angleMax = 25 + 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);
printf("player angle: %d\n",(int) ((player.angle) * RD +90) %360);
printf("angle min: %d\n", angleMin);
printf("angle max: %d\n", angleMax);
//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)
......
......@@ -12,6 +12,8 @@ SDL_Rect sky;
SDL_Rect ground;
SDL_Texture *netTexture;
SDL_Texture *netEdgeLeftTexture;
SDL_Texture *netEdgeRightTexture;
SDL_Texture *crowdTexture;
SDL_Texture *playerTexture;
SDL_Texture *ballTexture;
......@@ -52,7 +54,7 @@ void freeRayInfoList(rayInfo_t *rayInfoHead)
}
}
rayInfo_t *allocRayInfo(float ra, float distT, int r, int isTransparent, int direction, float htexture)
rayInfo_t *allocRayInfo(float ra, float distT, int r, int isTransparent, int direction, float htexture, int rx, int ry)
{
rayInfo_t *rayInfo = malloc(sizeof(rayInfo_t));
if (rayInfo == NULL)
......@@ -66,6 +68,8 @@ rayInfo_t *allocRayInfo(float ra, float distT, int r, int isTransparent, int dir
rayInfo->isTransparent = isTransparent;
rayInfo->direction = direction;
rayInfo->htexture = htexture;
rayInfo->rx = rx;
rayInfo->ry = ry;
rayInfo->next = NULL;
return rayInfo;
}
......@@ -176,7 +180,17 @@ void drawRayColumn(rayInfo_t *rayInfo)
{
rect.h *= 1.2;
// rect.y -= rect.h/3;
SDL_RenderCopy(renderer, netTexture, &destRect, &rect);
if (map[rayInfo->ry/BLOCK_SIZE][rayInfo->rx/BLOCK_SIZE] == 3){
SDL_RenderCopy(renderer, netEdgeLeftTexture, &destRect, &rect);
}
if (map[rayInfo->ry/BLOCK_SIZE][rayInfo->rx/BLOCK_SIZE] == 4){
SDL_RenderCopy(renderer, netEdgeRightTexture, &destRect, &rect);
}
else {
SDL_RenderCopy(renderer, netTexture, &destRect, &rect);
}
}
else
{
......@@ -446,18 +460,18 @@ void castRays(int map[][MAP_WIDTH])
ra += 2 * pi;
// draw ray
rayInfo_t *column = allocRayInfo(ra, distT, r, foundTransparentWallV, direction, htexture);
rayInfo_t *column = allocRayInfo(ra, distT, r, foundTransparentWallV, direction, htexture, rx, ry);
addRayInfoToList(&raysListHead, column);
if (foundTransparentWallV)
{
if (foundSolidWallV)
{
rayInfo_t *column = allocRayInfo(ra, distT2, r, 0, direction2, htexture2);
rayInfo_t *column = allocRayInfo(ra, distT2, r, 0, direction2, htexture2, rx2, ry2);
addRayInfoToList(&raysListHead, column);
}
else
{
rayInfo_t *column = allocRayInfo(ra, distT2, r, 0, direction, htexture2);
rayInfo_t *column = allocRayInfo(ra, distT2, r, 0, direction, htexture2, rx2, ry2);
addRayInfoToList(&raysListHead, column);
}
}
......@@ -999,6 +1013,8 @@ void mainLoop()
crowdTexture = loadTexture("Res/crowd.png");
playerTexture = loadTexture("Res/player_sprite.png");
ballTexture = loadTexture("Res/ball_sprite.png");
netEdgeLeftTexture = loadTexture("Res/netLeft.png");
netEdgeRightTexture = loadTexture("Res/netRight.png");
ray1 = malloc(sizeof(int) * 2);
ray2 = malloc(sizeof(int) * 2);
......
......@@ -25,6 +25,8 @@ typedef struct rayInfo{
int isTransparent;
int direction;
float htexture;
int rx;
int ry;
struct rayInfo * next;
} rayInfo_t;
......@@ -36,6 +38,7 @@ extern int * ray1;
extern int * ray2;
void castSingleRay(float angle, float *distanceWall, float *distanceNet, int *returnXWall, int *returnYWall, int *returnXNet, int *returnYNet);
void drawString(char *str, int x, int y, int w, int h, int r, int g, int b, int a);
void mainLoop();
#endif
\ No newline at end of file
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