Teo-CD
cad775f88e
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.
36 lines
792 B
C++
36 lines
792 B
C++
#include <iostream>
|
|
#include <SFML/Graphics.hpp>
|
|
|
|
#include "World.h"
|
|
|
|
// TODO: Handle inputs to move player
|
|
// TODO: Find a way to go to edges instead of just equally split (?)
|
|
|
|
int main()
|
|
{
|
|
World world(10,10);
|
|
world.setBlock(BlockType::AIR,1,1,8,8);
|
|
world.setBlock(BlockType::WALL,4,4,2,2);
|
|
world.player.move(2,2);
|
|
std::cout << world << std::endl;
|
|
|
|
sf::RenderWindow window(sf::VideoMode(800,600),"Da raycasting");
|
|
world.render(window);
|
|
window.display();
|
|
|
|
while (window.isOpen())
|
|
{
|
|
sf::Event event;
|
|
while (window.pollEvent(event))
|
|
{
|
|
if (event.type == sf::Event::Closed)
|
|
window.close();
|
|
}
|
|
window.clear();
|
|
|
|
world.render(window);
|
|
window.display();
|
|
}
|
|
|
|
return 0;
|
|
}
|