View - dynamic offset and size

T

TypicalHog

Guest
I want the view to be affected by player's speed, here's what I have:


If I floor() the values below (which I think I should) screen seems to be shaking. (Can be seen in the video)
Is it OK if I leave them as a floating point number?
Also, do you have any suggestions how to improve this code?

// View offset
av_hspeed = (av_hspeed * 24 + phy_speed_x) / 25;
av_vspeed = (av_vspeed * 24 + phy_speed_y) / 25;
view_xview = x - (view_wview / 2) + av_hspeed * 32;
view_yview = y - (view_hview / 2) + av_vspeed * 32;

// View size
av_speed = (av_speed * 24 + phy_speed) / 25;
view_wview = global.screen_w + (av_speed * global.screen_w / 32);
view_hview = global.screen_h + (av_speed * global.screen_h / 32);

av_ stands for average.
 
J

jackhigh24

Guest
you can use floating points but you may or will have to prepare the backgrounds so they tile without lines in between and also turn off interpolate for all drawing, but someone else might pop on and give some other ways so see what advice gets offered before deciding.
 
T

TypicalHog

Guest
you can use floating points but you may or will have to prepare the backgrounds so they tile without lines in between and also turn off interpolate for all drawing, but someone else might pop on and give some other ways so see what advice gets offered before deciding.
I have AA and interpolation on, I'm not using backgrounds and it was all good, I just don't know if that will cause some other glitches or errors and if it's a bad practise.
 
J

jackhigh24

Guest
well it can do with the sprites you will have to test and see, if you see glitch looking sprite then you need to turn off interpolation for that sprite, try and test of two different screen ratio's if you have another screen, but most should show up on your own as you are zooming and that shows glitches when using floating points
 
T

TypicalHog

Guest
well it can do with the sprites you will have to test and see, if you see glitch looking sprite then you need to turn off interpolation for that sprite, try and test of two different screen ratio's if you have another screen, but most should show up on your own as you are zooming and that shows glitches when using floating points
Since I'm only zooming out and not in, I think I'm fine.
 
Top