Updated Amit's code to run in sfml 3.0
This commit is contained in:
parent
105c974f1c
commit
7fb2d5cf26
3 changed files with 58 additions and 28 deletions
35
amt/main.cpp
35
amt/main.cpp
|
@ -24,10 +24,15 @@ Matrix MAP{
|
|||
{1,1,1,1,1,1,1,1,1}
|
||||
};
|
||||
|
||||
int main() {
|
||||
using KB = sf::Keyboard;
|
||||
void draw_gui(sf::RenderWindow &window) {
|
||||
sf::RectangleShape rect({SCREEN_WIDTH - RAY_VIEW_WIDTH, 300});
|
||||
rect.setPosition({0,0});
|
||||
rect.setFillColor({100, 100, 100});
|
||||
window.draw(rect);
|
||||
}
|
||||
|
||||
sf::RenderWindow window(sf::VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT), "Zed's Ray Caster Game Thing");
|
||||
int main() {
|
||||
sf::RenderWindow window(sf::VideoMode({SCREEN_WIDTH, SCREEN_HEIGHT}), "Zed's Ray Caster Game Thing");
|
||||
|
||||
//ZED this should set with a function
|
||||
float player_x = MAP.rows() / 2;
|
||||
|
@ -40,6 +45,12 @@ int main() {
|
|||
double moveSpeed = 0.1;
|
||||
double rotSpeed = 0.1;
|
||||
|
||||
const auto onClose = [&window](const sf::Event::Closed&)
|
||||
{
|
||||
window.close();
|
||||
};
|
||||
|
||||
|
||||
std::size_t const max_count = 100;
|
||||
std::vector<double> frames(max_count);
|
||||
std::size_t it = 1;
|
||||
|
@ -57,27 +68,23 @@ int main() {
|
|||
it = 1;
|
||||
}
|
||||
++it;
|
||||
// DRAW GUI
|
||||
|
||||
draw_gui(window);
|
||||
window.display();
|
||||
|
||||
if(KB::isKeyPressed(KB::W)) {
|
||||
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::W)) {
|
||||
rayview.run(moveSpeed, 1);
|
||||
} else if(KB::isKeyPressed(KB::S)) {
|
||||
} else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::S)) {
|
||||
rayview.run(moveSpeed, -1);
|
||||
}
|
||||
|
||||
if(KB::isKeyPressed(KB::D)) {
|
||||
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::D)) {
|
||||
rayview.rotate(rotSpeed, -1);
|
||||
} else if(KB::isKeyPressed(KB::A)) {
|
||||
} else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::A)) {
|
||||
rayview.rotate(rotSpeed, 1);
|
||||
}
|
||||
|
||||
sf::Event event;
|
||||
while(window.pollEvent(event)) {
|
||||
if(event.type == sf::Event::Closed) {
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
window.handleEvents(onClose);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue