diff --git a/assets/cinqueda_1-512.png b/assets/cinqueda_1-512.png new file mode 100644 index 0000000..58b0da5 Binary files /dev/null and b/assets/cinqueda_1-512.png differ diff --git a/main.cpp b/main.cpp index e3d81ba..568fff8 100644 --- a/main.cpp +++ b/main.cpp @@ -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); } diff --git a/texture.cpp b/texture.cpp index 8df28f4..22e5fa4 100644 --- a/texture.cpp +++ b/texture.cpp @@ -32,8 +32,11 @@ void TexturePack::load_textures() { sf::Texture* sprite_texture = new sf::Texture("assets/evil_eye_test-256.png"); sprite_texture->setSmooth(false); sf::Sprite* sf_sprite = new sf::Sprite(*sprite_texture); - sprites.push_back({4.0, 3.55, 6, sf_sprite, sprite_texture}); + + sword.sprite_texture = new sf::Texture("assets/cinqueda_1-512.png"); + sword.sprite_texture->setSmooth(false); + sword.sprite = new sf::Sprite(*sword.sprite_texture); } Image& TexturePack::get_texture(size_t num) { diff --git a/texture.hpp b/texture.hpp index 28bf7e4..fa651ac 100644 --- a/texture.hpp +++ b/texture.hpp @@ -28,6 +28,7 @@ struct TexturePack { std::vector sprites; Image floor; Image ceiling; + Sprite sword; void load_textures(); std::vector load_image(std::string filename);