Sprite rotation and size
Started by MattieB, Sep 21 2012 06:21 AM
5 replies to this topic
#1 Members - Reputation: 124
Posted 21 September 2012 - 06:21 AM
Hi
I'm currently working on a top-down, tile-based 2d tactical game. Time has come to work a little bit on the art and I'm having some problems with my playing characters. A player is represented as a circle with a small line perpendicular to the edge ( something like this: o- ). I currently use a 16x16 png file which i rotate according to the 'player's walking angle' (if the player is walking from (0,0) to (10,10), i rotate the sprite 45 degrees). The rotation angle of the sprite can therefore be any (float) value between 0 and 360 degrees. When the angle is not a multiple of 90 degrees, I notice that the result looks really bad (I guess every pixel is rotated and due to rounding errors the resulting position of some pixels is wrong (I use sfml btw)).
Now I was wondering if this problem is solvable (my first guess is: yes) and how? Will it, for instance, help if i make a high res png file (eg 256x256)), which i let sfml rotate and scale? Is it maybe better to use the shape drawing api (after all, it's just a circle and a line, though at this moment i have a slightly 3d effect in the png which i want to have. This is probably hard to simulate with the graphics api).
In general, is it good tactics to have high res textures and scale them according to zooming level, or is it better to have 1 png file per zooming level per object (and what about continuous zooming) (for instance 16x16, 32x32 and 64x64 png file)? I've been playing around a little bit with the different options, but at this moment I haven't found a satisfying one. So what is your approach?
Thanks for the help,
Jan
Ps: my goal is to have something similar to the map view of the Hitman games. There the enemies seem to turn around very smoothly and the circles are quite sharp.
I'm currently working on a top-down, tile-based 2d tactical game. Time has come to work a little bit on the art and I'm having some problems with my playing characters. A player is represented as a circle with a small line perpendicular to the edge ( something like this: o- ). I currently use a 16x16 png file which i rotate according to the 'player's walking angle' (if the player is walking from (0,0) to (10,10), i rotate the sprite 45 degrees). The rotation angle of the sprite can therefore be any (float) value between 0 and 360 degrees. When the angle is not a multiple of 90 degrees, I notice that the result looks really bad (I guess every pixel is rotated and due to rounding errors the resulting position of some pixels is wrong (I use sfml btw)).
Now I was wondering if this problem is solvable (my first guess is: yes) and how? Will it, for instance, help if i make a high res png file (eg 256x256)), which i let sfml rotate and scale? Is it maybe better to use the shape drawing api (after all, it's just a circle and a line, though at this moment i have a slightly 3d effect in the png which i want to have. This is probably hard to simulate with the graphics api).
In general, is it good tactics to have high res textures and scale them according to zooming level, or is it better to have 1 png file per zooming level per object (and what about continuous zooming) (for instance 16x16, 32x32 and 64x64 png file)? I've been playing around a little bit with the different options, but at this moment I haven't found a satisfying one. So what is your approach?
Thanks for the help,
Jan
Ps: my goal is to have something similar to the map view of the Hitman games. There the enemies seem to turn around very smoothly and the circles are quite sharp.
Here we are now,entertain us.
Sponsor:
#2 Members - Reputation: 612
Posted 21 September 2012 - 06:36 AM
Can you post a screenshot of how the rotated images are 'wrong'?
If you go for a shapey look'n'feel, I would recommend drawing the shapes directly. The result will be always better than using bitmaps, which have limited precision.
Having more versions of one texture with different sizes and using them is a technique used in 3D graphics, it is called mipmapping. For 2D games, it is probably superfluous, however.
If you go for a shapey look'n'feel, I would recommend drawing the shapes directly. The result will be always better than using bitmaps, which have limited precision.
Having more versions of one texture with different sizes and using them is a technique used in 3D graphics, it is called mipmapping. For 2D games, it is probably superfluous, however.
#4 Marketplace Seller - Reputation: 8960
Posted 21 September 2012 - 10:17 AM
Did you enable anti-aliasing for that sprite? (I think SFML calls it "smoothing").
sf::Texture::setSmooth( bool smooth ); //False by default; try it set to true.
sf::Texture::setSmooth( bool smooth ); //False by default; try it set to true.
All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.
Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal
#6 Members - Reputation: 1566
Posted 21 September 2012 - 12:06 PM
FWIW, your game sounds kind of like my game I made (in my old blog link here and in my sig) in that it's a top-down shooter, and my character is a circle with an arrow pointing the way. Although, it used SFML 2.0 pre-release (and pre-coding standard change it went through)
Have fun, and good luck!
Have fun, and good luck!
My Gamedev Journal: 2D Game Making, the Easy Way
---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)
---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)








