Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Getting half a pixel from the scaled sprite?  (Read 856 times)

0 Members and 1 Guest are viewing this topic.

Eika

  • Newbie
  • *
  • Posts: 1
    • View Profile
Getting half a pixel from the scaled sprite?
« on: November 07, 2016, 02:18:47 pm »
Hello,

Im using SFML.Net 2.2

Making a raycasting game, where i need to get vertical strips from the texture.
I use scaling to make the sprite to have desired height

A sprite that is far away, will need to take use from texture per pixel drawn, so it will be scaled a lot more. I use this to find out how many pixels i need to get:
var widthGet = (int)Math.Round(1/scale);
So if scale is 0.5 (object is far enough that the image size is scaled by 0.5), i would get 2 pixels from the scaled texture(1 pixel in screen).

But, now i have issue when the scaling is bigger than or equal to 2, i would scale the texture say by 2, then calculate that i need to get half a pixel from the scaled texture, and get nothing drawn.
I tried doing a simple check such as:
if(widthGet == 0) widthGet = 1;
But, now these strips show double the amount needed(it looks fine, because they get drawn over the next strip)
However, the last strip from the close object is not getting drawn over, which is a problem.

Is there a way to scale the texture 2x, and then get what would be an equivalent of a half pixel from the original?

http://pastebin.com/eCU690jm relevant code


« Last Edit: November 08, 2016, 09:11:21 am by Eika »
Crawling in my skin, these bugs they will not fix