Fix texture map

Add door to map
Added ability to "open" a door by pressing e

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-09-02 18:53:11 +02:00
parent 7fec071ce0
commit 3f6caff7e6
+94 -75
View File
@@ -23,16 +23,18 @@
// 270° => 3π/2 radians (BOTTOM) // 270° => 3π/2 radians (BOTTOM)
// 360° => 2π radians (RIGHT) // 360° => 2π radians (RIGHT)
// * Define the world // *MARK: Define the world
int mapX = 8, mapY = 8, mapSize = 32; int mapX = 8, mapY = 8, mapSize = 32;
float movementRestriction;
// clang-format off // clang-format off
int mapWalls[] = int mapWalls[] =
{ {
1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,
1,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,1,
1,0,1,0,0,0,0,1, 1,0,1,0,0,0,0,1,
1,0,1,0,0,0,0,1, 1,0,4,0,0,0,0,1,
1,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,1,
1,0,0,0,0,2,0,1, 1,0,0,0,0,2,0,1,
1,0,0,0,0,0,0,1, 1,0,0,0,0,0,0,1,
@@ -118,78 +120,78 @@ int All_Textures[] = // All 32x32 textures
0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,
//Window //Window
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,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,1, 1,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,1, 1,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,1,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,0,0,1, 1,0,0,0,0,0,0, 0,0,0,0,0,0,0, 0,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,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,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,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,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,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,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,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,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,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,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,0,
}; };
// clang-format on // clang-format on
@@ -199,7 +201,7 @@ typedef struct
} ButtonKeys; } ButtonKeys;
ButtonKeys Keys; ButtonKeys Keys;
// * ---------------- HELPERS -------------------------------------------------- // *MARK: HELPERS
// Function to check if a number is a power of 2 // Function to check if a number is a power of 2
int isPowerOfTwo(int n) int isPowerOfTwo(int n)
@@ -232,7 +234,7 @@ float distance(float ax, float ay, float bx, float by, float ang)
return (sqrt((bx - ax) * (bx - ax) + (by - ay) * (by - ay))); return (sqrt((bx - ax) * (bx - ax) + (by - ay) * (by - ay)));
} }
// * ---------------- PLAYER --------------------------------------------------- // *MARK: PLAYER
// Player position (playerX, playerY), delta (playerDeltaX, playerDeltaY), and angle (pa) // Player position (playerX, playerY), delta (playerDeltaX, playerDeltaY), and angle (pa)
float playerX, playerY, playerDeltaX, playerDeltaY, playerAngle; float playerX, playerY, playerDeltaX, playerDeltaY, playerAngle;
@@ -255,7 +257,7 @@ void drawPlayer2D()
glEnd(); glEnd();
} }
// * ---------------- Draw Rays and Walls -------------------------------------- // *MARK: Draw Rays and Walls
void drawRays2D() void drawRays2D()
{ {
@@ -945,11 +947,12 @@ void drawFloor()
glEnd(); glEnd();
} }
// * ---------------- MAIN ----------------------------------------------------- // *MARK: MAIN
float frame1, frame2, fps; float frame1, frame2, fps;
// * Main rendering // *MARK: Main rendering
void display() void display()
{ {
// Frames per second // Frames per second
@@ -1004,8 +1007,6 @@ void display()
} }
// We need to check if we're going to bump into a wall and prevent that from happening. // We need to check if we're going to bump into a wall and prevent that from happening.
float movementRestriction = mapSize / 4;
int xOffset = 0; int xOffset = 0;
if (playerDeltaX < 0) if (playerDeltaX < 0)
{ {
@@ -1082,7 +1083,8 @@ void display()
glutSwapBuffers(); glutSwapBuffers();
} }
// * Key input handling // *MARK: Key input handling
void ButtonDown(unsigned char key, int x, int y) void ButtonDown(unsigned char key, int x, int y)
{ {
if (key == 'a') if (key == 'a')
@@ -1105,6 +1107,20 @@ void ButtonDown(unsigned char key, int x, int y)
Keys.s = 1; Keys.s = 1;
} }
if (key == 'e')
{
int xOffset = (playerDeltaX < 0) ? -25 : 25;
int yOffset = (playerDeltaY < 0) ? -25 : 25;
int iPlayerX = playerX / mapSize, iPlayerX_add_xOffset = (playerX + xOffset) / mapSize;
int iPlayerY = playerY / mapSize, iPlayerY_add_yOffset = (playerY + yOffset) / mapSize;
if (mapWalls[iPlayerY * mapX + iPlayerX_add_xOffset] == 4)
mapWalls[iPlayerY * mapX + iPlayerX_add_xOffset] = 0;
if (mapWalls[iPlayerY_add_yOffset * mapX + iPlayerX] == 4)
mapWalls[iPlayerY_add_yOffset * mapX + iPlayerX] = 0;
}
glutPostRedisplay(); glutPostRedisplay();
} }
@@ -1134,6 +1150,7 @@ void ButtonUp(unsigned char key, int x, int y)
} }
// * Window resizing // * Window resizing
void resize(int w, int h) void resize(int w, int h)
{ {
// Prevent division by zero // Prevent division by zero
@@ -1153,7 +1170,7 @@ void resize(int w, int h)
glLoadIdentity(); glLoadIdentity();
} }
// * Check for key presses and move the "player" accordingly // *MARK: Init and main
void init() void init()
{ {
@@ -1169,6 +1186,8 @@ void init()
playerX = 1.5f * mapSize; playerX = 1.5f * mapSize;
playerY = 1.5f * mapSize; playerY = 1.5f * mapSize;
movementRestriction = mapSize / 4;
playerAngle = 0; playerAngle = 0;
// Calculate the initial player deltaX and deltaY // Calculate the initial player deltaX and deltaY