Skip to content

Commit f99d35c

Browse files
committed
better raycaster display
1 parent e381ef6 commit f99d35c

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

raycaster/simple_raycaster_textures.cpp

+13-10
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,16 @@ constexpr uint8_t MapWidth = 24;
6262
constexpr uint8_t MapHeight = 24;
6363

6464
// how big each map grid is in pixels for the top view
65-
constexpr uint8_t MapPixelSize = 16;
65+
constexpr uint8_t MapPixelSize = 24;
6666

6767
RenderTexture MapRenderTexture; // render texture for the top view
6868
RenderTexture ViewRenderTexture; // render texture for the 3d view
6969

7070
Texture2D WallTexture = { 0 };
7171

7272
// 3d view size
73-
constexpr uint16_t ViewWidth = 256;
74-
constexpr uint16_t ViewHeight = 196;
73+
constexpr uint16_t ViewWidth = 256 * 4;
74+
constexpr uint16_t ViewHeight = 192 * 4;
7575

7676
constexpr float ViewFOV = 90 * DEG2RAD;
7777

@@ -393,12 +393,15 @@ void UpdateMovement()
393393
// compute a rotation for this frame
394394
float rotation = 0;
395395

396-
if (IsKeyDown(KEY_A))
396+
if (IsKeyDown(KEY_Q))
397397
rotation += rotationSpeed;
398398

399-
if (IsKeyDown(KEY_D))
399+
if (IsKeyDown(KEY_E))
400400
rotation -= rotationSpeed;
401401

402+
if (IsMouseButtonDown(MOUSE_BUTTON_RIGHT))
403+
rotation -= GetMouseDelta().x / 100.0f;
404+
402405
// rotate the player and the camera plane
403406
PlayerFacing = Vector2Rotate(PlayerFacing, rotation);
404407
CameraPlane = Vector2Rotate(CameraPlane, rotation);
@@ -416,10 +419,10 @@ void UpdateMovement()
416419
if (IsKeyDown(KEY_S))
417420
newPos = Vector2Add(newPos, Vector2Scale(PlayerFacing, -movementSpeed));
418421

419-
if (IsKeyDown(KEY_Q))
422+
if (IsKeyDown(KEY_A))
420423
newPos = Vector2Add(newPos, Vector2Scale(sideStepVector, movementSpeed));
421424

422-
if (IsKeyDown(KEY_E))
425+
if (IsKeyDown(KEY_D))
423426
newPos = Vector2Add(newPos, Vector2Scale(sideStepVector, -movementSpeed));
424427

425428
// if the new pos is not inside the world, allow the player to move there
@@ -430,9 +433,9 @@ void UpdateMovement()
430433
int main()
431434
{
432435
// set up the window
433-
SetConfigFlags(FLAG_VSYNC_HINT);
434-
InitWindow(1280, 800, "Raycaster Example");
435-
SetTargetFPS(144);
436+
//SetConfigFlags(FLAG_VSYNC_HINT);
437+
InitWindow(1800, 900, "Raycaster Example");
438+
//SetTargetFPS(500);
436439

437440
// load render textures for the top view and 3d view
438441
MapRenderTexture = LoadRenderTexture(MapWidth * MapPixelSize, MapHeight * MapPixelSize);

0 commit comments

Comments
 (0)