Exploring raycasters and possibly make a little "doom like" game based on it.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
raycaster/texture.hpp

37 lines
832 B

#pragma once
#include <cstdint>
#include <vector>
#include <string>
#include <SFML/Graphics.hpp>
struct Sprite {
double x;
double y;
int texture;
sf::Sprite *sprite = nullptr;
sf::Texture *sprite_texture = nullptr;
// ZED: this should be a separate transform parameter
double elevation=0;
int uDiv=1;
int vDiv=1;
};
using Image = std::vector<uint32_t>;
struct TexturePack {
int NUM_SPRITES=1;
constexpr static const int TEXTURE_WIDTH=256; // must be power of two
constexpr static const int TEXTURE_HEIGHT=256; // must be power of two
std::vector<Image> images;
std::vector<Sprite> sprites;
Image floor;
Image ceiling;
Sprite sword;
void load_textures();
std::vector<uint32_t> load_image(std::string filename);
Sprite& get_sprite(size_t sprite_num);
Image& get_texture(size_t num);
};