1
0
Fork 0
Toy-Raytracer/World.h
trotFunky 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

50 lines
1.1 KiB
C++

//
// Created by trotfunky on 27/05/19.
//
#ifndef RAYCASTING_WORLD_H
#define RAYCASTING_WORLD_H
#include <vector>
#include <ostream>
#include <SFML/Graphics.hpp>
#include <iostream>
#include "Player.h"
enum class BlockType {
AIR,
WALL,
DOOR,
WINDOW,
};
class World {
public:
Player player;
World(int w, int h, sf::Color groundColor = sf::Color::Green, sf::Color ceilingColor = sf::Color::Blue,
std::vector<BlockType> worldMap = {});
int getW() const;
int getH() const;
BlockType getBlock(float x, float y) const;
void setBlock(BlockType block, int x, int y, int width = 1, int height = 1);
void render(sf::RenderWindow&) const;
friend std::ostream& operator<<(std::ostream& ostream, World const & world);
private:
int w;
int h;
std::vector<BlockType> map;
sf::Color groundColor;
sf::Color ceilingColor;
void fillColumn(sf::RenderWindow&, int column, float scale, sf::Color wallColor = sf::Color(127,127,127)) const;
float castRay(float originX, float originY, float orientation);
};
#endif //RAYCASTING_WORLD_H