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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - shackra

Pages: [1] 2 3 4
1
Python / Re: using sfml.audio on Cocos2D, good idea?
« on: April 26, 2013, 06:05:02 pm »
Yes, it helps :)

But I'm doing this task using ctypes, so it's possible to ship .so/.dll within the engine. Alà Pymunk, you see? :)

2
Audio / I want to use this module for another project!
« on: April 19, 2013, 04:42:37 am »
Hello! :D

I have a project that lacks of "advanced"  audio support (3D sound, load various sound formats and such) and I want to integrate this module to my project using Python's ctypes alà Pymunk, so I want to know:

  • the necessary files for this module to work are just: lib/libsfml-audio.a and lib/libsfml-audio-*.a (for GNU/Linux), bin/libsndfile-1.dll and bin/openal32.dll and bin/sfml-audio-2.dll and bin/sfml-audio-d-2.dll (for Windows) or there are more compiled files involved (for both platforms)?
  • May can I place all compiled files in one directory with (maybe) different names or names cares for the involved libs?

Just for Windows: csfml-audio-2.dll, libsndfile-1.dll and openal32.dll are all the files that I need to make the Audio module works or those files depends on others inside lib/?

cheers! :)

3
Python / python-sfml2: error: 'Back' is not a member of 'sf::Keyboard'
« on: April 19, 2013, 03:21:06 am »
D:

I was recompiling python*-sfml2 because some funky errors appeared when I did import sfml and I cough this error:

==> Retrieving sources...
  -> Found v1.2.zip
==> Validating source files with sha256sums...
    v1.2.zip ... Passed
==> Extracting sources...
  -> Extracting v1.2.zip with bsdtar
==> Starting build()...
running build
running build_py
creating build
creating build/lib.linux-x86_64-2.7
creating build/lib.linux-x86_64-2.7/sfml
copying src/sfml/__init__.py -> build/lib.linux-x86_64-2.7/sfml
copying src/sfml/show.py -> build/lib.linux-x86_64-2.7/sfml
running build_ext
building 'sfml.x11' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
creating build/temp.linux-x86_64-2.7/src/sfml
gcc -pthread -DNDEBUG -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -Isrc/sfml -I/usr/include/python2.7 -c src/sfml/x11.cpp -o build/temp.linux-x86_64-2.7/src/sfml/x11.o
src/sfml/x11.cpp: In function 'PyObject* __pyx_pf_4sfml_3x11_flush_screen(PyObject*, int)':
src/sfml/x11.cpp:536:35: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
   __pyx_v_myDisplay = ((Display *)__pyx_v_d);
                                   ^
g++ -pthread -shared -Wl,-O1,--sort-common,--as-needed,-z,relro -Wl,-O1,--sort-common,--as-needed,-z,relro,--hash-style=gnu -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-2.7/src/sfml/x11.o -L/usr/lib -lX11 -lpython2.7 -o build/lib.linux-x86_64-2.7/sfml/x11.so
building 'sfml.system' extension
gcc -pthread -DNDEBUG -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -Isrc/sfml -I/usr/include/python2.7 -c src/sfml/system.cpp -o build/temp.linux-x86_64-2.7/src/sfml/system.o
gcc -pthread -DNDEBUG -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -Isrc/sfml -I/usr/include/python2.7 -c src/sfml/error.cpp -o build/temp.linux-x86_64-2.7/src/sfml/error.o
g++ -pthread -shared -Wl,-O1,--sort-common,--as-needed,-z,relro -Wl,-O1,--sort-common,--as-needed,-z,relro,--hash-style=gnu -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 build/temp.linux-x86_64-2.7/src/sfml/system.o build/temp.linux-x86_64-2.7/src/sfml/error.o -L/usr/lib -lsfml-system -lsfml-graphics -lpython2.7 -o build/lib.linux-x86_64-2.7/sfml/system.so
building 'sfml.window' extension
gcc -pthread -DNDEBUG -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4 -D_FORTIFY_SOURCE=2 -fPIC -Iinclude -Isrc/sfml -I/usr/include/python2.7 -c src/sfml/window.cpp -o build/temp.linux-x86_64-2.7/src/sfml/window.o
src/sfml/window.cpp: In function 'void initwindow()':
src/sfml/window.cpp:20239:30: error: 'Back' is not a member of 'sf::Keyboard'
   __pyx_t_2 = PyInt_FromLong(sf::Keyboard::Back); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
                              ^
error: command 'gcc' failed with exit status 1
==> ERROR: A failure occurred in build().
    Aborting...
==> ERROR: Build failed, check /mnt/building/root/build
==> ERROR: (libremakepkg): An unknown error has occurred. Exiting...
 


I was compiling using this source code https://github.com/Sonkun/python-sfml/archive/v1.2.zip I think that this comes from a update of the package sfml

jorge [/tmp/python2-sfml2] ~> LC_ALL=C pacman -Qi sfml
Name           : sfml
Version        : 2.0-1
Description    : A simple, fast, cross-platform, and object-oriented multimedia API
Architecture   : x86_64
URL            : http://www.sfml-dev.org/
Licenses       : zlib
Groups         : None
Provides       : None
Depends On     : libsndfile  libxrandr  libjpeg  openal  glew  freetype2
Optional Deps  : None
Required By    : python2-sfml2
Optional For   : None
Conflicts With : None
Replaces       : None
Installed Size : 7992.00 KiB
Packager       : Sven-Hendrik Haase <sh[at]lutzhaase[dot]com>
Build Date     : Fri Apr 12 01:48:59 2013
Install Date   : Mon Apr 15 16:49:22 2013
Install Reason : Installed as a dependency for another package
Install Script : Yes
Validated By   : Signature

jorge [/tmp/python2-sfml2] ~>
 

Looks like that package was updated recently (Install Date: Mon Apr 15 16:49:22 2013). any fix? :)

4
Python / Re: Switching from Pygame
« on: April 18, 2013, 08:26:22 pm »
I seem to have gotten most of the commands down for SFML butt(?) here's one command that I have not and that is surface, unless pysfml has surface that'd be great...

We have RenderTexture which is the most quickies way to draw things and displaying them on the Window.

5
Python / using sfml.audio on Cocos2D, good idea?
« on: April 18, 2013, 10:05:57 am »
sleeeeeeeeep! Dx xd.

I just forked Cocos2D to build from there my own game engine, I noticed many things about Cocos2d (besides they sloooow development). They use pygame's audio module, OMG, they don't have spatial audio compared with SFML!.

So, among the changes that I want to do, I want to change pygame's audio module for Sonkun's SFML binding's audio module.

May I just can copy /usr/lib/python2.7/site-packages/sfml/audio.so file and place it on <project>/cocos/audio/ and start coding or I need to take care about more tough things?

cheers!

6
Python / Re: Which Python binding to use
« on: April 18, 2013, 09:59:57 am »
Regarding Sonkun's version, I deleted the "pysfml" in the path of the #include statements in the files that produced errors and it compiled ok. Kind of disappointed in the forum though. It doesn't seem very active. Any others try either of the two Python bindings? comments, recommendations...

in order to build Sonkun's SFML bindings, install SFML-2RC files on your system, don't try to use github version because Sonkun version is based on the stable release candidate!

7
Graphics / Re: VertexArray as individual layers: efficiency issue
« on: February 14, 2013, 10:47:51 pm »
Never ever do something like this:

In [1]: import sfml

In [2]: arrays = [sfml.Ver]
sfml.Vertex       sfml.VertexArray  

In [2]: arrays = [sfml.VertexArray(sfml.PrimitiveType.QUADS),] * 10
 

Why? Plain simple for the layman:

In [3]: arrays
Out[3]:
[<sfml.graphics.VertexArray at 0x12b0510>,
 <sfml.graphics.VertexArray at 0x12b0510>,
 <sfml.graphics.VertexArray at 0x12b0510>,
 <sfml.graphics.VertexArray at 0x12b0510>,
 <sfml.graphics.VertexArray at 0x12b0510>,
 <sfml.graphics.VertexArray at 0x12b0510>,
 <sfml.graphics.VertexArray at 0x12b0510>,
 <sfml.graphics.VertexArray at 0x12b0510>,
 <sfml.graphics.VertexArray at 0x12b0510>,
 <sfml.graphics.VertexArray at 0x12b0510>]

In [4]:

As you can see, there are 9 references to the same 1 object. So, no matter in which "layer" you may want to append a vertex, because of those references you are adding the vertexs of 10 layers to the same VertexArray, and drawing 10 times the same VertexArray, etc.

What  a novice mistake I committed xd.
That solves part of my issue, the FPS drops to 55~ when moving the view, that's is acceptable... However, I'm dealing with the issue of hiding the sprite behind other objects on the map. So, any advice or help on this will be appreciated :)

EDIT:

I realized that Tiled have a type of layer called "objects layer", and I noticed that I can place pieces of my tileset on the map, even forming thing like a house or a tree... so I can process all the objects that aren't polygons and load them as sprites, duh! xd

8
Graphics / [SOLVED] VertexArray as individual layers: efficiency issue
« on: February 14, 2013, 12:58:00 am »
Hello! ;D

I'm using Tiled to design scenes with multiple layers. I want to keep every layer separate in VertexArrays, so, when I drawn a sprite on the scene, it can be hidden by any layer that is over it (by its z index or something alike, isn't big deal).
I want to draw only those tiles that are visible for the player, so, I can achieve some performance on games with many, many, many tiles. I have achieved that feature on my engine, yes, for every layer (individual VertexArrays) of the scenario.

However: I'm having a very big issue on performance, take a look at my screenshots:



When I move the view I lost like 33 frames per second (because the scenario is transversing the N VertexArrays looking for those visible vertexs on them?), That's no cool ;(.
Actually, if I move the view where just one or two layers are seen, I win some frames per second until reach 63 fps (I'm running the example at 60), yes, 56 fps is by itself indicator that what I'm doing, I'm doing it wrong xd ;(.

So, I'm looking for people that has manage to have good performance for their games using scenarios with N layers; I really need advice on achieving what I want (basically, hiding fully or partially an sprite with those elements of the map, previously designed with Tiled, that are over it).

Source code? Well, I have the relevant code here, but is Python:

# coding: utf-8
# This file is part of Thomas Aquinas.
#    
# Thomas Aquinas is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Thomas Aquinas is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Thomas Aquinas.  If not, see <http://www.gnu.org/licenses/>.
#
#                       veni, Sancte Spiritus.

import logging
from thirdparty.pytmx import tmxloader
from itertools import product, chain, izip_longest, cycle
import common
import media
import sfml
import os
from copy import copy

class TATileImageException(Exception): pass

# Extiende tu mente a esto
#  https://github.com/SFML/SFML/wiki/Source:-TileMap-Render

class AbstractScene(sfml.Drawable):
    """Escena abstracta del juego.
   
    Las escenas representan partes visibles del juego, ya sea una
    pantalla de introduccion, creditos, o un campo de batalla.
   
    Para poder hacer escenas funcionales, debe derivar de esta clase
    cualquier escena que necesite.
   
    Esta clase usa Super para inicializar a sfml.Drawable. Use super
    en sus subclases!
    """

   
    def __init__(self, scenemanager):
        sfml.Drawable.__init__(self)
        self.scenemanager = scenemanager
        # Para cambiar una escena puede hacer lo siguiente:
        #     self.scenemanager.changescene(nuevaescena)
        # Y eso es todo :)
       
    def on_update(self, event):
        """El manejador de escenas llama este metodo para actualizar la logica.

        Aqui se actualizara todaas las entidades pertenecientes a la escena.
        Cada una recibe el mismo evento sacado de windw.events para hacer
        algo con su controlador que quizas quiera algo más que las propiedades
        de la entidad.
        """

        for entity in chain.from_iterable(self.sprites):
            entity.on_update(event)
   
# [···]
   
    def loadmap(self, mapfilepath=None):
        """Carga el mapa de la respectiva escena.
       
        No es necesario reimplementar éste método.
        Todos los archivos de mapa a leer deben ser en
        formato tmx, del software Tiled Map Editor
        http://www.mapeditor.org/"""

        if mapfilepath:
            self.__tmxmapfile = common.settings.joinpaths(
                common.settings.getrootfolder(),
                "maps", mapfilepath)
            self.tmxmapdata = tmxloader.load_tmx(self.__tmxmapfile)
           
            heightlist = []
            widthlist = []
            tilesets = []
           
            logging.info("Cargando las baldosas del escenario...")
            # carga todas las baldosas del set de baldosas
            # basado en el código escrito por bitcraft, del proyecto
            # pytmx. Revisar el método load_images_pygame del archivo
            # pytmx/tmxloader.py. fragmento de código bajo LGPL 3.
            self.tmxmapdata.images = [0] * self.tmxmapdata.maxgid
           
            for firstgid, tile in sorted((tile.firstgid, tile) for tile in \
                                      self.tmxmapdata.tilesets):
                filename = os.path.basename(tile.source)
                tilesets.append(
                    media.loadimg("maps/tilesets/{0}".format(filename)))
               
                w, h = tilesets[-1].size
                widthlist.append(w)
                heightlist.append(h)
                tile_size = (tile.tilewidth, tile.tileheight)
                totalheight = sum(heightlist[1:], 0)
                real_gid = tile.firstgid - 1
               
                # FIXME: sfml no convierte los valores hexadecimales a valores
                # RGB de 0 a 255.
                # colorkey = None
                # if t.trans:
                #     colorkey = pygame.Color("#{0}".format(t.trans))
                tilewidth = tile.tilewidth + tile.spacing
                tileheight = tile.tileheight + tile.spacing
               
                # some tileset images may be slightly larger than the tile area
                # ie: may include a banner, copyright, ect.
                # this compensates for that
                width = ((int((w - tile.margin * 2) + tile.spacing) / tilewidth) \
                         * tilewidth) - tile.spacing
                height = ((int((h - tile.margin * 2) + tile.spacing) / tileheight) \
                          * tileheight) - tile.spacing
               
                # using product avoids the overhead of nested loops
                p = product(xrange(tile.margin, height+tile.margin, tileheight),
                            xrange(tile.margin, width+tile.margin, tilewidth))
               
                for (y, x) in p:
                    real_gid += 1
                    # Puede que el llamado a ese metodo devuelva una tupla
                    # Sólo Dios sabe porqué...
                    gids = self.tmxmapdata.mapGID(real_gid)
                    if gids == []: continue
                   
                    # Esta operacion puede ser algo lenta...
                    # creamos una textura (imagen en memoria de vídeo)
                    # a partir de una imagen cargada de acuerdo a ciertas
                    # coordenadas. En esté caso, "extraeremos" una baldosa
                    # del set de imágenes de baldosas del respectivo mapa.
                   
                    # se usan cuatro Vertexs, uno como cada esquina de un plano
                    # orden de coordenadas: X, Y
                    v1 = sfml.Vertex((0, 0), None, sfml.Vector2(
                            float(x), float(y + totalheight)))
                    v2 = sfml.Vertex((0, 0), None, sfml.Vector2(
                            v1.tex_coords.x + tile_size[0],
                            v1.tex_coords.y))
                    v3 = sfml.Vertex((0, 0), None, sfml.Vector2(
                            v1.tex_coords.x + tile_size[0],
                            v1.tex_coords.y + tile_size[1]))
                    v4 = sfml.Vertex((0, 0), None, sfml.Vector2(
                            v1.tex_coords.x,
                            v1.tex_coords.y + tile_size[1]))
                    quad = (v1, v2, v3, v4,)
                    logging.debug("Quad mapeado en: ({0}),"
                                  " ({1}), ({2}), ({3})".format(
                            v1.tex_coords, v2.tex_coords,
                            v3.tex_coords, v4.tex_coords))
                    # No tengo ni la menor idea sobre que hace esté bucle for
                    for gid, flag in gids:
                        logging.debug("gid: {0}, flag: {1}".format(gid, flag))
                        self.tmxmapdata.images[gid] = quad
                       
            # Unimos todos los tiles sets en una sola imagen
            ## creamos una imagen del tamaño adecuado
            widthlist.sort()
            logging.info("Creando imagen de {0}x{1}".format(widthlist[-1],
                                                            sum(heightlist)))
            alltilesimg = sfml.Image.create(widthlist[-1],
                                            sum(heightlist))
            previousimg = sfml.Rectangle(sfml.Vector2(0.0, 0.0),
                                         sfml.Vector2(0.0, 0.0))
            for tileset in tilesets:
                logging.debug("Bliteando imagen a una altura de {0}".format(
                        previousimg.height))
                alltilesimg.blit(tileset, (0, previousimg.height))
                previousimg.height += tileset.height
               
            # Finalmente, creamos la textura con todos los tilesets
            self.scenetileset = sfml.Texture.from_image(alltilesimg)
            # estos vertexarray llevaran los vertices visibles unicamente,
            # por capa.
            self.__vertexarraytodraw = [
                sfml.VertexArray(sfml.PrimitiveType.QUADS),] * len(
                self.tmxmapdata.tilelayers)
            # Agregamos una lista de listas vacias para colocar a los sprites
            # cada lista vacia representa una capa del scenario.            
            self.sprites = [[],] * len(self.tmxmapdata.tilelayers)
            # POSICONANDO LOS TILES #
            self.__posvertexs()
            # PREPARANDO SOLAMENTE LOS TILES VISIBLES #
            self.__refreshvisibletiles(self.scenemanager.window.view)
            logging.info("Carga de baldosas exitosa!")
        else:
            self.__tmxmapfile = None
            self.sprites = [[]]

    def __refreshvisibletiles(self, currentview):
        """ Revisa cuales baldoas son visibles para el jugador.

        Aunque este metodo sea llamado, la revision de baldosas se realizara
        unicamente si la diferencia entre el centro del view viejo y el view
        actual es mayor al ancho y alto de una baldosa (en los ejes positivos
        y negativos).
        """

        try:
            assert self.__oldviewcenter
        except AttributeError:
            # FIRST time!
            logging.debug("La propiedad '__oldviewcenter'"
                          " no existe, creandola...")
            self.__oldviewcenter = currentview.center
            self.__oldviewcenter += sfml.Vector2(1000.0, 1000.0)

        # obtenemos la diferencia entre los centros de cada view
        currentdiff = self.__oldviewcenter - currentview.center
           
        tileheight, tilewidth = (self.tmxmapdata.tileheight,
                                 self.tmxmapdata.tilewidth)
       
        if ((tilewidth <= currentdiff.x) or
            (-tilewidth >= currentdiff.x)) or ((tileheight <= currentdiff.y) or
                                               (-tileheight >= currentdiff.y)):
            logging.debug("El centro del view de Window"
                          " a cambiado, diferencia: {0}".format(currentdiff))
            # sencillamente limpiamos de vertexs cada vertexarray
            for vertexarray in self.__vertexarraytodraw:
                vertexarray.clear()
            # Sí se ha movido el centro de forma significativa!
            self.__oldviewcenter = currentview.center
            # Creamos un rectangulo que representa la zona visible del escenario
            rect = sfml.Rectangle(currentview.center - currentview.size / 2.0,
                                  currentview.size + sfml.Vector2(tilewidth,
                                                                  tileheight)
                                  )
           
            logging.debug("Recreando baldosas visibles...")
            for array, arrayindex, xarrayrange in self.__vertexarrayranges:
                for vertex in xarrayrange:
                    if (rect.contains(array[vertex].position) or
                        rect.contains(array[vertex + 1].position) or
                        rect.contains(array[vertex + 2].position) or
                        rect.contains(array[vertex + 3].position)):
                        # Esta baldosa existe!
                        self.__vertexarraytodraw[arrayindex].append(
                            array[vertex])
                        self.__vertexarraytodraw[arrayindex].append(
                            array[vertex + 1])
                        self.__vertexarraytodraw[arrayindex].append(
                            array[vertex + 2])
                        self.__vertexarraytodraw[arrayindex].append(
                            array[vertex + 3])
           
    def __posvertexs(self):
        """ Posiciona los vertices y los guarda en la lista de VertexArrays.

        Lo ideal es llamar a esta funcion una vez luego de cargado el mapa.
        Así tendremos posicionados todos los vertices dentro de sus vertexarrays
        """

        # Obtenemos el alto y ancho de las baldosas
        height, width = (self.tmxmapdata.tileheight,
                         self.tmxmapdata.tilewidth)
        tiles = product(
            xrange(len(self.tmxmapdata.tilelayers)),
            xrange(self.tmxmapdata.width),
            xrange(self.tmxmapdata.height - 1, -1, -1) \
                if self.tmxmapdata.orientation == "isometric"\
                else xrange(self.tmxmapdata.height))
       
        vertexarraylist = [
            sfml.VertexArray(sfml.PrimitiveType.QUADS),] * len(
            self.tmxmapdata.tilelayers)
       
        for layer, x, y in tiles:
            quad = self.tmxmapdata.getTileImage(x, y, layer)
            if quad:
                # Tenemos dos formas de dibujar la baldosa
                # si es ortografica, entonces se coloca de
                # la siguiente forma: (x * width, y * height)
                # Si es isometrica, entonces de la siguiente
                # forma: ((x * width / 2) + (y * width / 2),
                # (y * height / 2) - (x * height /2))

                # Desempacamos los Vertexs
                v1, v2, v3, v4 = quad
                if self.tmxmapdata.orientation == "isometric":
                    v1.position = sfml.Vector2(
                        float((x * width / 2) + (y * width / 2)),
                        float((y * height / 2) - (y * height / 2)))
                    v2.position = sfml.Vector2(
                        v1.position.x + width, v1.position.y)
                    v3.position = sfml.Vector2(
                        v1.position.x + width, v1.position.y + height)
                    v4.position = sfml.Vector2(
                        v1.position.x, v1.position.y + height)
                else:
                    v1.position = sfml.Vector2(
                        float(x * width), float(y * height))
                    v2.position = sfml.Vector2(v1.position.x + width,
                                               v1.position.y)
                    v3.position = sfml.Vector2(v1.position.x + width,
                                               v1.position.y + height)
                    v4.position = sfml.Vector2(v1.position.x,
                                               v1.position.y + height)

                vertexarraylist[layer].append(v1)
                vertexarraylist[layer].append(v2)
                vertexarraylist[layer].append(v3)
                vertexarraylist[layer].append(v4)

        # Generamos una comprension de lista, necesitaremos
        # una de estas porque van a ser accedida muchas veces
        # durante la visualizacion del escenario.
        self.__vertexarrayranges = [(array,
                                     vertexarraylist.index(array),
                                     xrange(0, len(array), 4))
                                    for array in
                                    vertexarraylist]

# [···]

    def draw(self, target, states):
        """ Dibuja el mapa del escenario.
       
        se usa el argumento *sprites para pasar grupos de sprites que deban
        ser dibujados en encontrar la capa sprite. Éste grupo de sprites
        deberá de tener un método on_draw que llamara al método on_draw
        de cada uno de los sprites dentro del grupo.
        """

        if self.__tmxmapfile:
            self.__refreshvisibletiles(self.scenemanager.window.view)
            states.texture = self.scenetileset
            drawables = chain.from_iterable(
                izip_longest(self.__vertexarraytodraw, self.sprites))
            for drawable in drawables:
                if isinstance(drawable, list):
                    drawable.sort(key=lambda entity: entity.sprite.position.y)
                    for entity in drawable:
                        sprite.on_draw()
                        target.draw(entity.sprite, states)
                elif isinstance(drawable, sfml.VertexArray):
                    target.draw(drawable, states)
        else:
            target.clear(sfml.Color.WHITE)
            self.sprites[-1].sort(key=lambda entity: entity.sprite.position.y)
            logging.debug("Dibujando {0} entidade(s)".format(
                    len(drawable)))
            for entity in self.sprites[-1]:
                entity.on_draw()
                target.draw(entity.sprite, states)

Thanks! :)

9
Graphics / Re: How to know if a point is visible or not for the player?
« on: February 12, 2013, 12:30:26 am »
To find out whether a certain point is visible, you can check if the current view contains it.
sf::View view = window.getView();
sf::FloatRect viewRect(view.getCenter() - view.getSize() / 2.f, view.getSize());

sf::Vector2f point(...);
bool visible = viewRect.contains(point);

Really, that's all? D: I thought that it was more tough... anyway, I'll test that. Thank You! :)

Things get more trickier when you consider rotated views.

:O I'll take that on consideration!

10
Hello! :)

Please watch the following graphic:


I'm trying to wrap my mind on the process of asserting if certain point is or not visible for the user according to any sf::View object(?). In other words, I can't thought on a way of differentiate point A from point B regarding on the issue of if one of them are visible or not for the player...

any thoughts or advices on this? :O
cheers! :)

11
Python / Re: LoadFromFile crashes without error.
« on: February 02, 2013, 07:15:00 pm »
PySFML 1.6
I had some modules already implemented in 1.6 and no time to rewrite it for 2.0  :(

Better move your code to 2.0, there is a obvious difference between 1.6 and 2.0's API . Also, 2.0 have several bug fixes...

12
Python / Re: LoadFromFile crashes without error.
« on: February 02, 2013, 03:32:24 am »
are you using sfml 1.6 or 2.0?  ???

13
Python / Re: VertexArray & Vertex's tilemap nightmare
« on: February 01, 2013, 12:54:53 am »
There is!!



All tiles are drawn on screen, I need to implement that stuff drawing just those tiles that are visible!

14
Python / Re: VertexArray & Vertex's tilemap nightmare
« on: January 31, 2013, 08:58:11 pm »


almost there!!...

15
Python / Re: LoadFromFile crashes without error.
« on: January 31, 2013, 02:28:32 am »
Before someone says it. I know its an old topic about this exact same quest but replies were just like change to version 2.0 which I can't do.
Any real solution to the problem?

You have to instantiate sfml.Font using sfml.Font.load_from_file (bastie leonard bindings, though) or sfml.Font.get_default_font

So:
# incorrect
font = sfml.Font()
font = sfml.Font.get_default_font()

# correct
font = sfml.Font.get_default_font()
 

If you are thinking on using sfml2-python2 (Sonkun bindings, of course), please take a look on the documentation http://python-sfml.org/api/graphics.html#font and http://python-sfml.org/api/graphics.html#text

Pages: [1] 2 3 4
anything