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

Author Topic: My sprites are not the same as input file  (Read 1204 times)

0 Members and 1 Guest are viewing this topic.

mayou

  • Newbie
  • *
  • Posts: 2
    • View Profile
My sprites are not the same as input file
« on: April 29, 2013, 09:54:45 pm »
Hi all,

i just start to learn your API, and I just meet a display problem.
When SFML draws a sprite in the window it's not the same as input :
My source image :

My SFML app :


Why ?

Here is my code :

#!/usr/bin/python
# -*- coding: utf-8 -*-

from PySFML import sf

brick_image = sf.Image()
brick_image.LoadFromFile("brick_.png")

window = sf.RenderWindow(sf.VideoMode(320,240,32), "SFML")

while True:

        window.Clear()

        for j in range(0,24) :
                for i in range(0,16) :
                        sprite = sf.Sprite(brick_image)
                        sprite.SetPosition(i * 20, j * 10)
                        idx = (i+j)%2
                        sprite.SetSubRect(sf.IntRect(20 * idx, 0, 20 + 20 * idx, 10))
                        window.Draw(sprite)

        window.Display()

Thanks in advance.

G.

  • Hero Member
  • *****
  • Posts: 1592
    • View Profile
Re: My sprites are not the same as input file
« Reply #1 on: April 29, 2013, 10:08:29 pm »
Hi, it's 1.6 right?

In 1.6 images are smoothed by default, try using SetSmooth(false) on your brick_image.

mayou

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: My sprites are not the same as input file
« Reply #2 on: April 29, 2013, 10:34:28 pm »
Yup, it is 1.6... may I upgrade to 2.0 ?

Unfortunately
brick_image = sf.Image()
brick_image.LoadFromFile("brick_.png")
brick_image.SetSmooth(False)
or
brick_image = sf.Image()
brick_image.SetSmooth(False)
brick_image.LoadFromFile("brick_.png")
do not change anything.

G.

  • Hero Member
  • *****
  • Posts: 1592
    • View Profile
Re: My sprites are not the same as input file
« Reply #3 on: April 30, 2013, 12:01:38 am »
Someone on this thread from 2010 said that SetSmooth wasn't working in the 1.6 release, maybe that's your problem.

I've never used SFML with python so I may not be the best person to give you advice, but switching to 2.0 is a good idea.