@@ -193,24 +193,23 @@ void PlayerDraw3D(Player p, int screenWidth, int screenHeight) {
193193 double distaux = sqrt (pow (p -> posX - collisionPoint .x , 2 ) + pow (p -> posY - collisionPoint .y , 2 ));
194194 double distance = (1.5 * MapGetTileSize (p -> map )* screenHeight ) / (distaux * cos (MapRayGetAngleOffsetRad (ray )));
195195
196- Color drawColor ;
197- if (currentCollision .hitSide == X_AXIS ) {
198- drawColor = (Color ) {255 , 255 , 255 , 255 };
199- } else {
200- drawColor = (Color ) {210 , 210 , 210 , 255 };
201- }
196+ Color drawColor = currentCollision .hitSide == X_AXIS ?
197+ (Color ) {255 , 255 , 255 , 255 }
198+ : (Color ) {210 , 210 , 210 , 255 };
199+
202200 //DrawRectangle(rayX, (screenHeight/2)-(distance/2), line_width, distance, drawColor);
203201
204202 Vector2 collisionPointGrid = (Vector2 ) {currentCollision .collisionGridX , currentCollision .collisionGridY };
205203
206204 Texture tex = TileGetTexture (currentCollision .tile );
207-
208- int ray_percentage ; // Percentage of tile that ray hit (not really percentage, just number of tile pixels)
209- if (currentCollision .hitSide == X_AXIS ) {
210- ray_percentage = (int ) (collisionPoint .y ) % MapGetTileSize (p -> map ) + 1 ;
211- } else {
212- ray_percentage = (int ) (collisionPoint .x ) % MapGetTileSize (p -> map ) + 1 ;
213- }
205+
206+ int coll_point_axis = currentCollision .hitSide == X_AXIS ?
207+ (int ) (collisionPoint .y )
208+ : (int ) (collisionPoint .x );
209+
210+ // Percentage of tile that ray hit (not really percentage, just number of tile pixels)
211+ int ray_percentage = coll_point_axis % MapGetTileSize (p -> map ) + 1 ;
212+
214213 double texture_offset = ((double ) (ray_percentage ) / (double ) (MapGetTileSize (p -> map )))* ((double ) tex .width );
215214 int texture_width = 1 ;
216215
@@ -219,8 +218,8 @@ void PlayerDraw3D(Player p, int screenWidth, int screenHeight) {
219218 (Rectangle ) {rayX , (screenHeight /2 )- (distance /2 ), line_width , distance },
220219 (Vector2 ) {0 , 0 }, 0 , drawColor );
221220
222- ListMoveToNext (collisions );
223- } else if (currentCollision .collisionType == COLLISION_BILLBOARD ) {
221+ ListMoveToNext (collisions );
222+ } else if (currentCollision .collisionType == COLLISION_BILLBOARD ) {
224223 Billboard bb = currentCollision .billboard ;
225224
226225 double distaux = sqrt (pow (p -> posX - collisionPoint .x , 2 ) + pow (p -> posY - collisionPoint .y , 2 ));
0 commit comments