You can now stab stuff with a sword.
This commit is contained in:
parent
ad38f575a3
commit
d397c02d38
4 changed files with 19 additions and 1 deletions
BIN
assets/cinqueda_1-512.png
Normal file
BIN
assets/cinqueda_1-512.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 75 KiB |
14
main.cpp
14
main.cpp
|
@ -31,6 +31,12 @@ void draw_gui(sf::RenderWindow &window, sf::Text &text, Stats &stats) {
|
||||||
window.draw(text);
|
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() {
|
int main() {
|
||||||
sf::RenderWindow window(sf::VideoMode({SCREEN_WIDTH, SCREEN_HEIGHT}), "Zed's Ray Caster Game Thing");
|
sf::RenderWindow window(sf::VideoMode({SCREEN_WIDTH, SCREEN_HEIGHT}), "Zed's Ray Caster Game Thing");
|
||||||
|
|
||||||
|
@ -55,6 +61,7 @@ int main() {
|
||||||
window.close();
|
window.close();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
float rotation = -30.0f;
|
||||||
Stats stats;
|
Stats stats;
|
||||||
|
|
||||||
window.setVerticalSyncEnabled(VSYNC);
|
window.setVerticalSyncEnabled(VSYNC);
|
||||||
|
@ -68,6 +75,7 @@ int main() {
|
||||||
stats.sample(1/elapsed.count());
|
stats.sample(1/elapsed.count());
|
||||||
|
|
||||||
draw_gui(window, text, stats);
|
draw_gui(window, text, stats);
|
||||||
|
draw_weapon(window, rayview.$textures.sword.sprite, rotation);
|
||||||
window.display();
|
window.display();
|
||||||
|
|
||||||
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::W)) {
|
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Key::W)) {
|
||||||
|
@ -86,6 +94,12 @@ int main() {
|
||||||
stats.reset();
|
stats.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(sf::Mouse::isButtonPressed(sf::Mouse::Button::Left)) {
|
||||||
|
rotation = -30.0f;
|
||||||
|
} else {
|
||||||
|
rotation = -10.0f;
|
||||||
|
}
|
||||||
|
|
||||||
window.handleEvents(onClose);
|
window.handleEvents(onClose);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,11 @@ void TexturePack::load_textures() {
|
||||||
sf::Texture* sprite_texture = new sf::Texture("assets/evil_eye_test-256.png");
|
sf::Texture* sprite_texture = new sf::Texture("assets/evil_eye_test-256.png");
|
||||||
sprite_texture->setSmooth(false);
|
sprite_texture->setSmooth(false);
|
||||||
sf::Sprite* sf_sprite = new sf::Sprite(*sprite_texture);
|
sf::Sprite* sf_sprite = new sf::Sprite(*sprite_texture);
|
||||||
|
|
||||||
sprites.push_back({4.0, 3.55, 6, 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) {
|
Image& TexturePack::get_texture(size_t num) {
|
||||||
|
|
|
@ -28,6 +28,7 @@ struct TexturePack {
|
||||||
std::vector<Sprite> sprites;
|
std::vector<Sprite> sprites;
|
||||||
Image floor;
|
Image floor;
|
||||||
Image ceiling;
|
Image ceiling;
|
||||||
|
Sprite sword;
|
||||||
|
|
||||||
void load_textures();
|
void load_textures();
|
||||||
std::vector<uint32_t> load_image(std::string filename);
|
std::vector<uint32_t> load_image(std::string filename);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue