|
|
|
@ -31,6 +31,12 @@ void draw_gui(sf::RenderWindow &window, sf::Text &text, Stats &stats) { |
|
|
|
|
window.draw(text); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void draw_weapon(sf::RenderWindow &window, sf::Sprite *weapon, float rotation) { |
|
|
|
|
weapon->setPosition({SCREEN_WIDTH/2,SCREEN_HEIGHT/2}); |
|
|
|
|
weapon->setRotation(sf::degrees(rotation)); |
|
|
|
|
window.draw(*weapon); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int main() { |
|
|
|
|
sf::RenderWindow window(sf::VideoMode({SCREEN_WIDTH, SCREEN_HEIGHT}), "Zed's Ray Caster Game Thing"); |
|
|
|
|
|
|
|
|
@ -55,6 +61,7 @@ int main() { |
|
|
|
|
window.close(); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
float rotation = -30.0f; |
|
|
|
|
Stats stats; |
|
|
|
|
|
|
|
|
|
window.setVerticalSyncEnabled(VSYNC); |
|
|
|
@ -68,6 +75,7 @@ int main() { |
|
|
|
|
stats.sample(1/elapsed.count()); |
|
|
|
|
|
|
|
|
|
draw_gui(window, text, stats); |
|
|
|
|
draw_weapon(window, rayview.$textures.sword.sprite, rotation); |
|
|
|
|
window.display(); |
|
|
|
|
|
|
|
|
|
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::W)) { |
|
|
|
@ -86,6 +94,12 @@ int main() { |
|
|
|
|
stats.reset(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if(sf::Mouse::isButtonPressed(sf::Mouse::Button::Left)) { |
|
|
|
|
rotation = -30.0f; |
|
|
|
|
} else { |
|
|
|
|
rotation = -10.0f; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
window.handleEvents(onClose); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|