Skip to content

Project backlog

Juan Ignacio Solinis Riobello edited this page Jun 16, 2022 · 16 revisions

Goal: make a dynamic view inside a maze, in which you’ll have to find your way.

Mandatory part

  • Parsing map

    • Error handling
      1. Number of arguments
      2. File extension
      3. Type identifiers:
        • All present
        • No foreign identifier (error or ignore?)
        • NO, SO, WE, EA:
          • Path is valid
          • Not the same path
        • F, C:
          • In range (0 to 255)
          • Not the same color
      4. Map validation:
        • Only 6 possible characters: 1, 0, N, S, E, W
        • N, S, E, W:
          • Only one of them
        • Map surronded by walls (1)
    • Parsing:
      • Generate map struct with map data from file
      • Add new data to struct describing map (e.g. height and width)
  • Window

    • Create window with appropriate size
      • Create connection with mlx API
      • Create window (1280 x 720):
        • game window (900 x 460)
        • HUD (bonus) (push images)
    • Hooks
      • X button
      • Esc
  • Render map

    • Define cube size (128x128x128)
    • Define coordinate system (x, y & degrees for angles)
    • Projection definition
      • Player's height (128/2), field of view (60º) & position
      • Dimension of the Projection Plane = 900 x 460 units
      • Center of the Projection Plane = (450,230)
      • Distance to the Projection Plane = 779 units (half of PP width divided by tangent(30º))
      • Angle between subsequent rays = 60/900 degrees
    • Raycasting
      • Finding intersections
        • Finding horizontal intersections
          • Find coordinates of intersection with the ray closest to the player
            • If facing North -> Ay = floor(Py / 128) * 128 - 1
            • If facing South -> Ay = floor(Py / 128) * 128 + 128
            • Ax = Px + (Py - Ay) / tan(60)
          • Divide coordinates by cube size (128).
          • Check the grid if there is a wall.
          • If there is no wall extend to C (next intersection)
            • If facing up -> Ya = -128
            • If facing down -> Ya = 128
            • Xa = 128 / tan(60)
            • Cy = Ay + Ya
            • Cx = Ax + Xa
          • Repeat the divide & check the grid steps and repeat until wall is found.
        • Finding vertical intersections
          • Same as with horizontal but inverting x & y formulas & depending on left or right facing values.
        • Finding distance to wall
          • PlayerPointWallPoint = ABS(Px - Wx)/cos(angle between center ray and current ray) = ABS(Py - Wy)/sin(angle between center ray and current ray)
        • Select shortest distance to wall
  • Player movement

    • Key bindings
    • Rotating view
Clone this wiki locally