Skip to content

Commit

Permalink
Additional notes added to caster docs.
Browse files Browse the repository at this point in the history
This needs to be cleaned up further.
  • Loading branch information
salt-die committed Feb 10, 2025
1 parent a4c39b0 commit 5711167
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/batgrl/gadgets/_raycasting.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,8 @@ def cast_rays(


cdef uint8 shade_wall(uint8 value, double distance):
# ! Should shading be set by kwarg in caster?
# ! `-0.15` is pretty arbitrary.
return <uint8>(value * exp(-0.15 * distance))


Expand Down Expand Up @@ -507,6 +509,7 @@ def text_cast_rays(
continue

tex_pos += step
# ! How much to shade a side wall? `2.0 * side` for now...
wall_value = shade_wall(
wall_texture[tex_y, tex_x], perp_wall_dist + 2.0 * side
)
Expand Down
9 changes: 9 additions & 0 deletions src/batgrl/gadgets/raycaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@ class Raycaster(Graphics):
r"""
A raycaster gadget.
``caster_map`` should not contain a value greater than the length of
``wall_textures``. A non-zero value ``N`` in ``caster_map`` represents a wall with
texture ``wall_textures[N - 1]``.
``sprite_indexes`` should not contain a value greater than or equal to the length of
``sprite_textures``. A value ``N`` in ``sprite_indexes`` represents a sprite with
texture ``sprite_textures[N]``. ``sprite_coords`` and ``sprite_indexes`` must be the
same length.
Parameters
----------
caster_map : NDArray[np.uint8]
Expand Down
18 changes: 17 additions & 1 deletion src/batgrl/gadgets/text_raycaster.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,23 @@

class TextRaycaster(Text):
r"""
A raycaster gadget.
A raycaster gadget that renders with text.
``caster_map`` should not contain a value greater than the length of
``wall_textures``. A non-zero value ``N`` in ``caster_map`` represents a wall with
texture ``wall_textures[N - 1]``.
The integer arrays in ``wall_textures`` determine how walls are shaded. With low
values darker and high values lighter.
``sprite_indexes`` should not contain a value greater than or equal to the length of
``sprite_textures``. A value ``N`` in ``sprite_indexes`` represents a sprite with
texture ``sprite_textures[N]``. ``sprite_coords`` and ``sprite_indexes`` must be the
same length.
It's convention in ``batgrl`` to refer to RGBA arrays as textures. ``wall_textures``
and ``sprite_textures`` do not contain RGBA arrays, but the names are kept to be
consistent with the graphics raycaster.
Parameters
----------
Expand Down

0 comments on commit 5711167

Please sign in to comment.