You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.3 KiB
61 lines
1.3 KiB
#include "raycaster.hpp"
|
|
|
|
static const int SCREEN_HEIGHT=720;
|
|
static const int SCREEN_WIDTH=1280;
|
|
|
|
Matrix MAP{{8,8,8,8,8,8,8,8,8},
|
|
{8,0,2,0,0,0,0,0,8},
|
|
{8,0,7,0,0,5,6,0,8},
|
|
{8,0,0,0,0,0,0,0,8},
|
|
{8,8,0,0,0,0,0,8,8},
|
|
{8,0,0,1,3,4,0,0,8},
|
|
{8,0,0,0,0,0,8,8,8},
|
|
{8,0,0,0,0,0,0,0,8},
|
|
{8,8,8,8,8,8,8,8,8}
|
|
};
|
|
|
|
int main() {
|
|
using KB = sf::Keyboard;
|
|
|
|
sf::RenderWindow window(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT), "Zed's Ray Caster Game Thing");
|
|
|
|
int TILE_SIZE = RAY_VIEW_HEIGHT / matrix::width(MAP);
|
|
|
|
//ZED this should set with a function
|
|
float player_x = RAY_VIEW_HEIGHT / 2;
|
|
float player_y = RAY_VIEW_HEIGHT / 2;
|
|
|
|
Raycaster rayview(window, MAP);
|
|
rayview.position_camera(player_x, player_y, TILE_SIZE);
|
|
|
|
double moveSpeed = 0.1;
|
|
double rotSpeed = 0.1;
|
|
|
|
while(window.isOpen()) {
|
|
rayview.render();
|
|
// DRAW GUI
|
|
window.display();
|
|
|
|
if(KB::isKeyPressed(KB::W)) {
|
|
rayview.move_forward(moveSpeed);
|
|
} else if(KB::isKeyPressed(KB::S)) {
|
|
rayview.move_backward(moveSpeed);
|
|
}
|
|
|
|
if(KB::isKeyPressed(KB::D)) {
|
|
rayview.rotate_right(rotSpeed);
|
|
} else if(KB::isKeyPressed(KB::A)) {
|
|
rayview.rotate_left(rotSpeed);
|
|
}
|
|
|
|
sf::Event event;
|
|
while(window.pollEvent(event)) {
|
|
if(event.type == sf::Event::Closed) {
|
|
window.close();
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|