Switching back to 256px textures for most things, but the weapon works best as a 512px.
This commit is contained in:
parent
5e6f95513c
commit
0882851b3f
14 changed files with 18 additions and 17 deletions
|
@ -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}));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue