1
0
Fork 0
Commit graph

12 commits

Author SHA1 Message Date
029f753bbf World: Re-use RectangleShapes for rendering
sf::RectangleShapes were created brand new each frame, which takes a lot of time.
Instead, keep an array of them available and update them instead of creating new ones.

This also allows a nice optimization of only updating them if needed, by checking their
previous value.

Update the available number of rects when the window resizes.
2024-01-29 00:25:57 +00:00
41437cd259 Clean-up: Change indentation to tabs 2024-01-28 22:08:35 +00:00
e234dda860 Colors: Introduce color type abstraction
SFML and Dear ImGui have incompatible color types, abstract them through
a new Color class which has conversions.

Centralize color constants in a namespace as well.
2024-01-26 23:07:25 +00:00
92daf5551f World: Rename wallColor to fillColor
As this function will get more generic, make the names more generic.

Fix some comments and indentation.
2024-01-26 21:34:13 +00:00
a0b6536432 World: make CastRay generic
Previously CastRay did the scale computation and used the player view statistics.
This makes it quite specialized, and the rest of the computations are made outside.

Move the computations in the render function and make castRay generic.
2024-01-25 22:31:39 +00:00
ddb01d0509 World: Clean warnings, optimize GetBlock
World has a lot of type conversion warnings. Take care of most of them,
for a slight performance hit ( :( ).
Re-order constructor parameters to match declaration.
Move FillColumn to a more appropriate place.

GetBlock gets called a lot : use direct memory access of the vector
rather than going through bounds checks with .at().
Introduce an integer overload to remove warnings.
2024-01-24 23:16:59 +00:00
b47052aa4d Implement moving the player
Player: Add rotation and linear speeds, as well as their current state.
Player: Allow to move in the local coordinates and compute
    world-speed equivalent.
Player: Update movement axis while rotating.

World: Add a function to advance a step.
Main: Handle key events, add world step in the main loop.
2024-01-21 22:11:46 +00:00
cad775f88e World: Implement raycaster
Implement the basic raycaster, checking every block intersection and the block
linked to that position.
Split the screen uniformally along the width.
Add data needed for camera maths in the Player class
Specify constraints on the raycast parameters.

Render the screen using the raycasts.
Call the renderer in the main loop.
2024-01-21 22:08:44 +00:00
c6b09d668c World: Use nicer custom colors 2024-01-21 20:41:19 +00:00
2d396269e0 Pick back up and comment
Clean placeholder code to get it running.
Add comments to clarify working, add TODOs in main,
add some references for the maths.
2023-12-30 14:50:35 +01:00
f21fc6f805 Ajout de la fonction render au monde
Joueur déplaçable
début du cast de rayon
Trop fatigué pour faire de la trigo
2019-06-01 06:42:29 +02:00
52a261de58 First commit, world map creation 2019-05-27 13:50:49 +02:00