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
16
Python / Re: Command Prompt raises when I run my game
« on: January 31, 2013, 02:21:12 am »
append an "w" to your filename's extension, so it becomes ".pyw".

you can also use pyinstaller to create "binaries" of your projects for both GNU/Linux and Windows.

17
Python / Re: AW: Re: VertexArray & Vertex's tilemap nightmare
« on: January 29, 2013, 10:15:39 pm »
but what I don't get at all is the process of "moving" the right vertexs to the left top corner of the screen in order to start drawing the tiles.
I've no idea what you're talking about here... ;)
never mind xd

Trying to figure out which Vertex are inside the View rect isn't good Idea either because some points of the 4 that compose the vertex will not been draw, thus, showing just three, two or one of them
In the logic part for culling you don't 'think' about points but about quads - you don't see 4 individual points, but a package of 4 points.

Hmm, yes, indeed that approach makes more sense! :)

EDIT:

I'm doing some progress but without testing it...
So, I'm thinking on packages of 4 points as eXpl0it3r told me, and I must say that this is really easy than I thought before. Consider the following image:



The trick here is to calculate correctly the coordinates for the first vertex (Vertex1 or v1), and then, use the position or tex_coords of the first Vertex to calculate the other 3 vertex of a Quad:

# We calculate the first vertex
v1 = sfml.Vertex(tex_coods=sfml.Vector2(
        float(x), float(y)))

# Then use v1.tex_coords to calculate the others
v2 = sfml.Vertex(tex_coords=sfml.Vector2(
        v1.tex_coords.x + tilewidth,
        v1.tex_coords.y))
v3 = sfml.Vertex(tex_coords=sfml.Vector2(
        v1.tex_coords.x + tilewidth,
        v1.tex_coords.y + tileheight))
v4 = sfml.Vertex(tex_coords=sfml.Vector2(
        v1.tex_coords.x,
        v1.tex_coords.y + tileheight))

# store the quad somewhere
tileimg = (v1, v2, v3, v4,)
 

very easy, right?
This should (yes, I didn't run any test yet) work also for positioning the quads on screen. Orthographic or Isometric maps, that no matters, just calculate the first vertex position correctly and everything else should flow naturally! 

18
SFML wiki / Re: [C#] TileMap renderer
« on: January 29, 2013, 06:51:42 am »
Try this: http://pastebin.com/SrBE69EC

Krazt, May can you add more commentaries to your source code? I got lost at some parts of it! :(

19
Python / Re: VertexArray & Vertex's tilemap nightmare
« on: January 29, 2013, 06:50:28 am »
I tried to understand the C++ code (about tile rendering using Vertex and VertexArray) but couldn't figure out why it would faster
The main reason is, that you only have one draw call for all the vertices, instead of N draw calls for N sprites (with 4 vertices). GPUs are built to process millions of vertices at once, thus there shouldn't be a problem passing on an huge array. ;)

However, I'm worried about perfomance with huge maps (8000x2000~ tiles), but what I don't get at all is the process of "moving" the right vertexs to the left top corner of the screen in order to start drawing the tiles.
Trying to figure out which Vertex are inside the View rect isn't good Idea either because some points of the 4 that compose the vertex will not been draw, thus, showing just three, two or one of them (as when you delete one vertice of a plane in Blender 3D, the plane lose its face!)

Maybe I should ask for more commentaries in that source code...

By the way, seems you're mastering drawing shapes/tiles at hand, once you understand everything I won't mind a feedback :p

No problem ;)

20
Graphics / is a good idea to combine many sprite atlas in one at runtime?
« on: January 28, 2013, 07:28:03 am »
Hello! :D

I use Tiled to design my maps, so, sometimes I need to use more than one tileset. I was thinking on "paste" each tileset in one texture at loading of my scenery/map, Is It a good idea?

cheers!

21
Python / Re: VertexArray & Vertex's tilemap nightmare
« on: January 28, 2013, 02:26:53 am »


    # Creamos una serie de vertexs conforme al mapa
    v1 = sfml.Vertex(sfml.Vector2(0, 0), sfml.Color.WHITE, sfml.Vector2(0, 0))
    v2 = sfml.Vertex(sfml.Vector2(32*2, 0), sfml.Color.WHITE, sfml.Vector2(32, 0))
    v3 = sfml.Vertex(sfml.Vector2(32*2, 32*2), sfml.Color.WHITE, sfml.Vector2(32, 32))
    v4 = sfml.Vertex(sfml.Vector2(0, 32*2), sfml.Color.WHITE, sfml.Vector2(0, 32))
    v5 = sfml.Vertex(sfml.Vector2(32*2, 0), sfml.Color.WHITE, sfml.Vector2(64, 64))
    v6 = sfml.Vertex(sfml.Vector2(64*2, 0), sfml.Color.WHITE, sfml.Vector2(95, 64))
    v7 = sfml.Vertex(sfml.Vector2(64*2, 32*2), sfml.Color.WHITE, sfml.Vector2(95, 95))
    v8 = sfml.Vertex(sfml.Vector2(32*2, 32*2), sfml.Color.WHITE, sfml.Vector2(64, 95))
 

Ok, I think that I'm getting the idea now... what about moving vertex to just show the ones that the user can see? D:

22
Python / Re: VertexArray & Vertex's tilemap nightmare
« on: January 24, 2013, 10:07:04 pm »
ok, ok, I'm getting the idea now.

Looks like you can only make one shape per vertexarray, no? how it comes for tilemapping? I'm missing something?

23
SFML wiki / Re: [C#] TileMap renderer
« on: January 24, 2013, 06:15:30 pm »
Try this: http://pastebin.com/SrBE69EC

cool! :'D
Thanks, I'll try to wrap my mind in this code :)

24
Python / Re: VertexArray & Vertex's tilemap nightmare
« on: January 24, 2013, 05:59:10 pm »


cool! :)

I feel like I'm not have the right idea about Vertex's position and text-coords (and sfml.PrimitiveType.QUADS). For instance, which position (on screen) and what's wrapping (from my texture) does
v1 = sfml.Vertex(sfml.Vector2(10, 10), sfml.Color.WHITE, sfml.Vector2(0, 0))
,
v2 = sfml.Vertex(sfml.Vector2(600, 50), sfml.Color.WHITE, sfml.Vector2(86, 0))
and
v3 = sfml.Vertex(sfml.Vector2(450, 450), sfml.Color.WHITE, sfml.Vector2(86, 86))
why 5 vertex and no 4 or 3? (that depends on the sfml.PrimitiveType.*?)

If you can add screenshots/pictures to your explanation, I'll appreciate that!

cheers!

25
Python / Re: VertexArray & Vertex's tilemap nightmare
« on: January 24, 2013, 02:12:13 am »
cool, a square!

I'm glad you have animations working :) and hope you'll get your performance issues solved quickly!

Yes, I did by filling the screen with white when no TMX file is passed to my AbstractScene class, just watch:



However, I'm trying to wrap my mind on this code that archives what I want https://github.com/SFML/SFML/wiki/Source:-TileMap-Render :(

EDIT:

I'm trying to undestand Tile-mapping with Vertexs... I wrote an example that goes like this:

#!/usr/bin/env python2
# coding: utf-8

import sfml

class Mapa(sfml.Drawable):
    def __init__(self, texture):
        sfml.Drawable.__init__(self)
        self.vertexarray = sfml.VertexArray(sfml.PrimitiveType.QUADS)
        self.texture = texture
       
    def draw(self, target, states):
        states.texture = self.texture
        target.draw(self.vertexarray, states)
       
def main():
    wn = sfml.RenderWindow(sfml.VideoMode(800, 600), "Prueba de Vertexs")
    wn.vertical_synchronization = True
    wn.framerate_limit = 60
   
    textura = sfml.Texture.from_file("textura.png")
    mapa = Mapa(textura)
    # Creamos una serie de vertexs conforme al mapa
    v1 = sfml.Vertex(sfml.Vector2(100, 1), sfml.Color.BLUE, sfml.Vector2(0, 0))
    v2 = sfml.Vertex(sfml.Vector2(300, 32), sfml.Color.RED, sfml.Vector2(0, 32))
    v3 = sfml.Vertex(sfml.Vector2(45, 64), sfml.Color.BLACK, sfml.Vector2(0, 64))
    v4 = sfml.Vertex(sfml.Vector2(32, 96), sfml.Color.YELLOW, sfml.Vector2(32, 0))
    # Existen más baldosas pero lo dejare hasta ahí
    for vertex in [v1, v2, v3, v4]:
        mapa.vertexarray.append(vertex)
       
    while wn.opened:
        for event in wn.events:
            if isinstance(event, sfml.CloseEvent):
                wn.close()
               
        wn.clear(sfml.Color.WHITE)
        wn.draw(mapa)
        wn.display()
       
if __name__ == "__main__":
    main()
 

and I got this:



Not what I was expecting xd. I'm using this image as texture:


any help? :)

26
SFML wiki / Re: [C#] TileMap renderer
« on: January 24, 2013, 01:48:28 am »
May can someone show me this code implemented in C++? My mind cannot wrap itself around C# code :(. After all, I am a python guy!

some help?

27
Python / [SOLVED] VertexArray & Vertex's tilemap nightmare
« on: January 19, 2013, 03:11:49 am »
Hello, hello! :D

I had a great progress on my framework, now, I have animated sprites :'D. BUT, I'm experiencing a lot of lag :-/ :(



A LOT! xd. I thought that was the tilemap drawing's fault, even if I'm drawing black squares on the screen (have to implement something to draw a color if no tmx file is passed), 10x10 pixels size in 80x60 tiles. Anyway, I want to use VertexArrays and Vertexs.

BOY! I don't have any idea at all about using VertexArrays to draw tilemaps, I was reading C++ and C# code but is like reading this:
Code: [Select]
使用系统;
使用SFML.Graphics;
使用SFML.Window;
使用测试;

命名空间SFML.Utils
{
    公共的委托无效TileProvider(X,Y,诠释层,出彩的颜色,出IntRect REC);
    MapRenderer:可绘制对象类
    {
        私人只读持股量TileSize;
        公共只读整型层;

        私人诠释的高度;
        私人诠释宽度;

        私人Vector2i偏移;
        私人顶点顶点;

        提供私人TileProvider;
        私人纹理质感;

        ,公共MapRenderer(纹理质地,TileProvider供应商,持股量tileSize=16,智力层=1)
        {
            (供应商== NULL | |层<= 0)抛出新的ArgumentException();
            this.provider供应商;

            TileSize tileSize;
            层=层;

            顶点=新的顶点[0];
            this.texture质感;

        }

        公共无效刷新()
        {
            RefreshLocal(0,0,宽度,高度);
        }

        私人无效RefreshLocal(左,诠释顶部,诠释的权利,诠释底部)
        {
            (VAR Y =顶部<底部,Y++)
                (VAR所述=左,X权; X ++)
                {
                    刷新(X + offset.X,Y+ offset.Y);
                }
        }

xD
anyway, get the idea, I don't understand ANYTHING! even that I can read C++ code. My question is:

How should I use VertexArray and Vertexs in order to draw tiles? because something that is confusing for me is the choosing a color for the Vertex. What's the idea of using that? Why you don't use a reference to a texture instead? Should I inherit from Drawable class and use the VertexArray and Vertex as an attributes?

I also like the idea of drawing only the vertex that the user sees (what he sees through sfml.View) but I don't know how to proceed, so, maybe a lay explication/mentoring might be helpful (once you understand how to use Vertex) for this.

cheers!

28
Python / Re: sfml.Sprite inheritance nightmare
« on: January 16, 2013, 08:35:05 pm »
I've no idea about the python binding, but in C++ one should not derive from the sprite class. It certainly is possible, but for OOP one should use the rule: composition over inheritances or derive from the classes Drawable and Transformable, but maybe Python has its own way there...

Also please, please use the code=python tag for posting! ::)

Composition over inhertance... got it. I'll try that jutsu and see how it works. Thanks!

29
Python / [SOLVED] sfml.Sprite inheritance nightmare
« on: January 16, 2013, 01:42:59 am »
import sfml

class BaseSprite(sfml.Sprite):
    def __init__(self, texture, arg1, arg2, arg3, rectangle=None):
        super(sfml.Sprite, self).__init__(texture, rectangle)
        self.__arg1 = arg1
        self.__arg2 = arg2
        self.__arg3 = arg3
    # ...
       
# Later, in other file...
import sfml
import media
from spritefactory import BaseSprite
from scenefactory import BaseScene

class Testsprite(BaseSprite):
    # second time inheritance
    def __init__(self, texture, arg1, arg2, arg3, rectangle=None):
        BaseSprite.__init__(texture, arg1, arg2, arg3, rectangle)
        self.setsomething(0)
       
class Scenetest(BaseScene):
    def __init__(self, scenemanager):
        BaseScene.__init__(self, scenemanager)
        self.loadmap("some/map.tmx")
        self.spritetexture = media.loadimg("some/sprite/sheet.png", False) # returns a Texture not an Image
        self.__sprite = {"mai": Test(self.spritetexture, 0, 1, 3)}
        # a bunch of code...
 

Hello! The code above is a less-detailed version of my actual source code. I'm having a nightmare trying to inheritance BaseSprite one more time. When I run the app, an awkward error shows up.

Traceback (most recent call last):
  File "main.py", line 8, in <module>
    escena = escena_2.Maitest(director)
  File "/home/jorge/coders/desarrollo/thomas-aquinas/scenes/escena_2.py", line 22, in __init__
    "sprites/others/Mai Shiranui "
  File "graphics.pyx", line 1365, in sfml.graphics.Sprite.__cinit__ (src/sfml/graphics.cpp:23985)
TypeError: __cinit__() takes at most 2 positional arguments (4 given)
 

and if I tend to pass just one argument (i.e: the texture for the sprite) the exception change just a little:

Traceback (most recent call last):
  File "main.py", line 8, in <module>
    escena = escena_2.Maitest(director)
  File "/home/jorge/coders/desarrollo/thomas-aquinas/scenes/escena_2.py", line 21, in __init__
    self.__sprite = {"mai": Mai(self.maitext)}#, 0, self.scenemanager.window,
TypeError: __init__() takes exactly 5 arguments (2 given)

and if I don't pass any arguments at all, it changes again:

Traceback (most recent call last):
  File "main.py", line 8, in <module>
    escena = escena_2.Maitest(director)
  File "/home/jorge/coders/desarrollo/thomas-aquinas/scenes/escena_2.py", line 21, in __init__
    self.__sprite = {"mai": Mai()}#self.maitext), 0, self.scenemanager.window,
  File "graphics.pyx", line 1365, in sfml.graphics.Sprite.__cinit__ (src/sfml/graphics.cpp:23985)
TypeError: __cinit__() takes at least 1 positional argument (0 given)

For God's sake, somebody help me!! D':

cheers! :)

30
Python / Re: How do I Inheritance from sfml.TransformableDrawable??
« on: January 09, 2013, 01:27:16 am »
you miss a period at class MyDrawable(sfTransformableDrawable): :)

I'll see which solution is more elegant... thanks!

Pages: 1 [2] 3 4
anything