Switching back to 256px textures for most things, but the weapon works best as a 512px.
BIN
assets/armored_knight_1-256.png
Normal file
After Width: | Height: | Size: 44 KiB |
BIN
assets/ceiling_test-256.png
Normal file
After Width: | Height: | Size: 61 KiB |
BIN
assets/ceiling_worm-256.png
Normal file
After Width: | Height: | Size: 37 KiB |
BIN
assets/cinqueda_1-256.png
Normal file
After Width: | Height: | Size: 22 KiB |
|
@ -1,17 +1,17 @@
|
|||
{
|
||||
"textures": [
|
||||
"assets/floor_tile_test-512.png",
|
||||
"assets/wall_texture_test-512.png",
|
||||
"assets/ceiling_test-512.png",
|
||||
"assets/wood_wall-512.png"
|
||||
"assets/floor_tile_test-256.png",
|
||||
"assets/wall_texture_test-256.png",
|
||||
"assets/ceiling_test-256.png",
|
||||
"assets/wood_wall-256.png"
|
||||
],
|
||||
"sprites": [
|
||||
"assets/armored_knight_1-512.png",
|
||||
"assets/cinqueda_1-512.png",
|
||||
"assets/wood_barrel_large-512.png",
|
||||
"assets/evil_eye_test-512.png",
|
||||
"assets/armored_knight_1-256.png",
|
||||
"assets/cinqueda_1-256.png",
|
||||
"assets/wood_barrel_large-256.png",
|
||||
"assets/evil_eye_test-256.png",
|
||||
"assets/undead_peasant-256.png"
|
||||
],
|
||||
"floor": "assets/floor_tile_test-512.png",
|
||||
"ceiling": "assets/ceiling_test-512.png"
|
||||
"floor": "assets/floor_tile_test-256.png",
|
||||
"ceiling": "assets/ceiling_test-256.png"
|
||||
}
|
||||
|
|
BIN
assets/evil_eye_test-256.png
Normal file
After Width: | Height: | Size: 57 KiB |
BIN
assets/floor_tile_test-256.png
Normal file
After Width: | Height: | Size: 89 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 42 KiB |
BIN
assets/wall_texture_test-256.png
Normal file
After Width: | Height: | Size: 96 KiB |
BIN
assets/wood_barrel_large-256.png
Normal file
After Width: | Height: | Size: 68 KiB |
BIN
assets/wood_wall-256.png
Normal file
After Width: | Height: | Size: 77 KiB |
|
@ -1,7 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
constexpr const int TEXTURE_WIDTH=512;
|
||||
constexpr const int TEXTURE_HEIGHT=512;
|
||||
constexpr const int TEXTURE_WIDTH=256;
|
||||
constexpr const int TEXTURE_HEIGHT=256;
|
||||
constexpr const int RAY_VIEW_WIDTH=960;
|
||||
constexpr const int RAY_VIEW_HEIGHT=720;
|
||||
constexpr const int RAY_VIEW_X=(1280 - RAY_VIEW_WIDTH);
|
||||
|
|
|
@ -67,6 +67,7 @@ void Raycaster::clear() {
|
|||
void Raycaster::sprite_casting() {
|
||||
const int textureWidth = TEXTURE_WIDTH;
|
||||
const int textureHeight = TEXTURE_HEIGHT;
|
||||
const int halfHeight = TEXTURE_HEIGHT / 2;
|
||||
|
||||
// sort sprites from far to close
|
||||
for(int i = 0; i < $textures.NUM_SPRITES; i++) {
|
||||
|
@ -126,7 +127,7 @@ void Raycaster::sprite_casting() {
|
|||
if(!(transformY > 0 && transformY < ZBuffer[stripe])) break;
|
||||
}
|
||||
|
||||
int texX_end = int(512 * (stripe - (-spriteWidth / 2 + spriteScreenX)) * textureWidth / spriteWidth) / 512;
|
||||
int texX_end = int(textureWidth * (stripe - (-spriteWidth / 2 + spriteScreenX)) * textureWidth / spriteWidth) / textureWidth;
|
||||
|
||||
if(drawStartX < drawEndX && transformY > 0 && transformY < ZBuffer[drawStartX]) {
|
||||
int vMoveScreen = int(sprite_rec.elevation * -1 / transformY);
|
||||
|
@ -136,15 +137,15 @@ void Raycaster::sprite_casting() {
|
|||
int drawEndY = spriteHeight / 2 + $height / 2 + vMoveScreen;
|
||||
if(drawEndY >= $height) drawEndY = $height - 1;
|
||||
|
||||
int texX = int(512 * (drawStartX - (-spriteWidth / 2 + spriteScreenX)) * textureWidth / spriteWidth) / 512;
|
||||
int texX = int(textureWidth * (drawStartX - (-spriteWidth / 2 + spriteScreenX)) * textureWidth / spriteWidth) / textureWidth;
|
||||
|
||||
float x = float(drawStartX + RAY_VIEW_X);
|
||||
float y = float(drawStartY + RAY_VIEW_Y);
|
||||
float sprite_w = float(spriteWidth) / float(textureWidth);
|
||||
float sprite_h = float(spriteHeight) / float(textureHeight);
|
||||
|
||||
int d = (y - vMoveScreen) * 512 - $height * 256 + spriteHeight * 256;
|
||||
int texY = ((d * textureHeight) / spriteHeight) / 512;
|
||||
int d = (y - vMoveScreen) * textureHeight - $height * halfHeight + spriteHeight * halfHeight;
|
||||
int texY = ((d * textureHeight) / spriteHeight) / textureHeight;
|
||||
|
||||
sf_sprite->setScale({sprite_w, sprite_h});
|
||||
sf_sprite->setTextureRect(sf::IntRect({texX, texY}, {texX_end - texX, textureHeight}));
|
||||
|
|
|
@ -25,7 +25,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-512.png");
|
||||
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});
|
||||
|
|