new Maze_Raycaster()
Ray caster class. Casts a cone of rays from the player to the closest obstacle and uses the distance to draw a block based 3D maze.
- Source:
Methods
adjustFrameRate()
Adjusts the rendering framerate by drawing smaller images scaled up. A quality decrease is 10 times faster than increase and happens immediately, while a quality increase will wait for the average FPS over a long period.
- Source:
castRay(cameraX) → {Object}
Casts a ray from the player until it hits a wall.
Parameters:
| Name | Type | Description |
|---|---|---|
cameraX |
On screen x coordinate of the ray. |
- Source:
Returns:
Ray data structure, contains the coordinates of the wall hit, its side and distance and direction from the player.
- Type
- Object
draw()
Draws the 3D scene.
- Source:
drawSprites()
Determines the player's left and right viewing angles and draws the events at the appropriate position.
- Source:
drawVLine(ray, cameraX)
Draws a single slice of a wall, determining the correct texture to apply. The east and west sides of the wall are drawn with a darker shadow.
Parameters:
| Name | Type | Description |
|---|---|---|
ray |
Ray which has hit the wall. |
|
cameraX |
On screen x coordinate of the wall. |
- Source:
getTexture(x, y) → {Object}
Retrieves the wall texture for a tile.
Parameters:
| Name | Type | Description |
|---|---|---|
x |
X coordinate of the tile on map. |
|
y |
Y coordinate of the tile on map. |
- Source:
Returns:
Structure containing the bitmap and the offset for the chosen tile.
- Type
- Object
initialize(screenSprite, scaleFactor, auto)
Initializes the rayscaster.
Parameters:
| Name | Type | Description |
|---|---|---|
screenSprite |
Bitmap on which the scene will be drawn. |
|
scaleFactor |
Scale factor for framerate adjustement. |
|
auto |
If true, the scale factor will automatically change to keep an high framerate. |
- Source: