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

Author Topic: Jagged edges  (Read 1940 times)

0 Members and 1 Guest are viewing this topic.

deliciouscake

  • Newbie
  • *
  • Posts: 1
    • View Profile
Jagged edges
« on: May 26, 2011, 02:55:03 pm »
I'm playing around a bit with isometric tiles. At first transparency didn't work but after changing graphics software it worked as it should. But then I noticed that the transparency color bled into the bled into the sprite, so I turned off Smoothing. Now, however, I get jagged edges on my sprites. I cast the X/Y values to integers before drawing. How do I fix this?

The jagged edges wander when I move the sprite in the Y axis.

http://i.imgur.com/1xbsy.png

Also, is there a way to not have the transparent color bleed with smoothing enabled? The file is a .png created in Graphics Gale

Code: [Select]
#include <SFML/Graphics.hpp>

int main(int argc, char *argv[]){

    char map[32][32];

    unsigned int sprite = 0;

    sf::RenderWindow App(sf::VideoMode(800,600,32), "Isometric tiles");

    sf::Image Image;
    if (!Image.LoadFromFile("testtile.png")){

    }
   
    Image.SetSmooth(false);

    sf::Sprite Sprite;
    Sprite.SetImage(Image);

    App.SetFramerateLimit(50);

    while(App.IsOpened()){

        sf::Event Event;
        while(App.GetEvent(Event)){
            if(Event.Type == sf::Event::Closed){
                App.Close();
            }
            if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::Q)){
                sprite--;
            }
            if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::W)){
                sprite++;
            }
            if(Event.Type == sf::Event::MouseMoved){
                Sprite.SetX((int)(Event.MouseMove.X));
                Sprite.SetY((int)(Event.MouseMove.Y));
            }
        }
        App.Clear();

        Sprite.SetSubRect(sf::IntRect((64*sprite),0,(64*(sprite+1)), 32));

        App.Draw(Sprite);

        App.Display();
    }

    return EXIT_SUCCESS;
}

Roswell_r

  • Newbie
  • *
  • Posts: 12
    • View Profile
Jagged edges
« Reply #1 on: May 28, 2011, 01:04:04 am »
I dont see anything wrong with your code, can you supply the tile?

Also you should throw in there some code to keep 'sprite' within bounds (just in-case its doing something stupid like you've pressed Q or W too many times and you're getting something drawn on screen like you are).

But you're right, you've set smoothing off and tile should look normal, but we'd need to see the tile.

 

anything