1
0
Fork 0

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.
This commit is contained in:
Teo-CD 2024-01-21 22:03:04 +00:00
parent c6b09d668c
commit cad775f88e
4 changed files with 126 additions and 28 deletions

View file

@ -1,22 +1,13 @@
#include <iostream>
#include "SFML/Graphics.hpp"
#include <SFML/Graphics.hpp>
#include "World.h"
// TODO: Handle inputs to move player
// TODO: Raycast from player position
// TODO: Fix raycasts and use it correctly
// TODO: Render world in event loop
// TODO: Understand what the code was doing (looks like scale from fill column is the output of the raycast)
// Ref: https://lodev.org/cgtutor/raycasting.html
// Ref: http://yunes.informatique.univ-paris-diderot.fr/wp-content/uploads/cours/INFOGRAPHIE/08-Raycasting.pdf
// TODO: Update player for camera plane
// TODO: Camera plane represents screen, rays go through it proportional to the screen
// TODO: Find a way to go to edges instead of just equally split (?)
int main()
{
std::cout << "Hello, World!" << std::endl;
World world(10,10);
world.setBlock(BlockType::AIR,1,1,8,8);
world.setBlock(BlockType::WALL,4,4,2,2);
@ -35,6 +26,10 @@ int main()
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
world.render(window);
window.display();
}
return 0;