Made a terrible animation sprite and then did a quick animation test. Won't keep it for now but this shows how it could work.
This commit is contained in:
parent
0882851b3f
commit
51858ea399
6 changed files with 9 additions and 4 deletions
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"textures": [
|
||||
"assets/floor_tile_test-256.png",
|
||||
"assets/wall_texture_test-256.png",
|
||||
"assets/floor_tile_test-256.png",
|
||||
"assets/ceiling_test-256.png",
|
||||
"assets/wood_wall-256.png"
|
||||
],
|
||||
|
|
BIN
assets/undead_peasant-spritesheet.png
Normal file
BIN
assets/undead_peasant-spritesheet.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 109 KiB |
|
@ -8,7 +8,7 @@ constexpr const int RAY_VIEW_X=(1280 - RAY_VIEW_WIDTH);
|
|||
constexpr const int RAY_VIEW_Y=0;
|
||||
constexpr const int SCREEN_HEIGHT=720;
|
||||
constexpr const int SCREEN_WIDTH=1280;
|
||||
constexpr const bool VSYNC=true;
|
||||
constexpr const bool VSYNC=false;
|
||||
constexpr const int FRAME_LIMIT=60;
|
||||
#ifdef NDEBUG
|
||||
constexpr const bool DEBUG_BUILD=false;
|
||||
|
|
|
@ -148,7 +148,9 @@ void Raycaster::sprite_casting() {
|
|||
int texY = ((d * textureHeight) / spriteHeight) / textureHeight;
|
||||
|
||||
sf_sprite->setScale({sprite_w, sprite_h});
|
||||
sf_sprite->setTextureRect(sf::IntRect({texX, texY}, {texX_end - texX, textureHeight}));
|
||||
auto time = $clock.getElapsedTime();
|
||||
int frame = int(time.asMicroseconds() / 200.0) % 4;
|
||||
sf_sprite->setTextureRect(sf::IntRect({texX + (textureWidth * frame), texY}, {texX_end - texX, textureHeight}));
|
||||
sf_sprite->setPosition({x, y});
|
||||
$window.draw(*sf_sprite);
|
||||
}
|
||||
|
|
|
@ -11,12 +11,14 @@
|
|||
#include "dbc.hpp"
|
||||
#include <memory>
|
||||
#include "texture.hpp"
|
||||
#include <SFML/System/Clock.hpp>
|
||||
|
||||
using matrix::Matrix;
|
||||
using RGBA = uint32_t;
|
||||
|
||||
struct Raycaster {
|
||||
int $pitch=0;
|
||||
sf::Clock $clock;
|
||||
|
||||
TexturePack $textures;
|
||||
double $posX = 0;
|
||||
|
|
|
@ -14,6 +14,7 @@ sf::Image TexturePack::load_image(std::string filename) {
|
|||
|
||||
void TexturePack::load_textures() {
|
||||
Config assets("assets/config.json");
|
||||
|
||||
for(string tile_path : assets["textures"]) {
|
||||
images.emplace_back(load_image(tile_path));
|
||||
}
|
||||
|
@ -25,7 +26,7 @@ void TexturePack::load_textures() {
|
|||
floor = load_image(assets["floor"]);
|
||||
ceiling = load_image(assets["ceiling"]);
|
||||
|
||||
sf::Texture* sprite_texture = new sf::Texture("assets/evil_eye_test-256.png");
|
||||
sf::Texture* sprite_texture = new sf::Texture("assets/undead_peasant-spritesheet.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});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue