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.


Topics - lezebulon

Pages: [1]
1
SFML projects / SFML Python console
« on: December 26, 2015, 06:42:19 pm »


Hi !
So I was thinking how to make to tools to help game making and debuging.

This project is based on the Lua console from FRex (http://en.sfml-dev.org/forums/index.php?topic=15962), and its purpose is to be a python shell within SFML that will also automatically be linked with game objects for debugging / inspection etc.

How does it work?
- user creates a swig wrapper file telling swig what objects are to be exported from C++ to python (for instance, "Player" class, etc)
- a specific project is dedicated to building the python module (.pyd file) generated by swig, which exposes the game objects
- within the actual SFML game, I use the Python C Api to do several things. A python shell is loaded and is bound to the SFML Console for rendering and input, then the previous pyd module is imported so the shell has the knowledge of some C++ classes within Python. From the SFML app, the user can specify which instances of game objects can be in scope within the python shell. For insance in the picture I put the instance named "pl" of a C++ "Player" class, into the global python objects, so the C++ object can be directly manipulated through the python console

limitations
due to the input format of the console it's not really possible to input multi-line strings and tabulations, which is pretty bad since the scripting language is python. So it's not really possible to input new functions in the shell


I'll post the source code later if anyone is interested



2
General / SFML ingame console?
« on: December 24, 2015, 12:52:49 am »
Hi!
is there a code snippet somewhere or a full source code on how to make a in-game "console" window in sfml?
basically :
- a text area is shown that will display what text is entered
- when enter is pressed, the text that was entered goes into a variable and an event is fired
- show output may or may not be displayed in the console window
Basically this :


Is there a way to do this easily?

3
Graphics / sf::VertexArray using incorrect texture coordinates?
« on: January 10, 2015, 02:57:45 pm »
Hi
I'm using a sf::VertexArray to display a tilemap : my array is composed of groups of 4 vertices making a square and each square is set to specific texture subrectangle.
 This works fine and give the intended result using a tileset as a sf::Texture (with smoothing off). However when I un-zoom my view and move it around, it seems that sometimes the subrectangle used for the texture goes 1 pixel off, which has the effect to draw 1 pixel from another tile in the tileset. I attached the picture for visual results of what I get when I move around. Again, this works fine when my view is 1:1 or when I zoom *in* .
Does anyone have an idea about this ? I'm using SFML 2.2 (from the github repo) and I kind of remember seeing this issue being mentionned here but I was unable to find it.

thanks!

4
SFML projects / Unamed 2D rpg game
« on: January 02, 2015, 12:21:08 am »

Hi,

I've been working on this for the past couple weeks. So far this is a basic "engine" that is using a tileset to display the world as a 2D grid.
Commands :
arrow keys
F - flashlight
X/C/V - change zoom
E - fire projectiles (you can keep the button down)

file in ressources/ folder contains the config files as plain text, you should be able to edit things if you want, the entry point is Game.txt

I'm interested in any bugs you find, and also if you manage to keep a decent framerate even with dezoom.

download link : http://www.fast-files.com/getfile.aspx?file=83962

Also, I'm looking for a name for this "engine", if anyone has an idea :)

5
Graphics / Animated tiles without looping ?
« on: December 24, 2014, 04:34:52 pm »
Hi guys

I'm making a 2D overhead game where the world is made of 32x32 tiles.
Some tiles are just a picture, some tiles are animated ie they cycle through a few frames during gameplay.

For now, each tile in my 2D map is a sprite. Now let's say that at a given frame, the animated tile frame should change. All I could manage to do for this effect was to call setTextureRect() on every animated tile and manually change the texture rectangle for each sprite, so that it matches the current frame. This works fine but it seems to me that I'm doing something wrong with editing manually *each* sprite's texture rectangle.
Is there a more logical way to do this that avoid looping over all the tiles ? Like doing some work directly on the texture itself?
Also, if I intend to change things later to a vertex array instead of a 2D table of sprites, would my concerns still apply ? what would be the solution then?

Thanks!

6
General / question about the main loop in the sfml book sample
« on: June 07, 2014, 01:24:44 am »
Hi
the main loop in the sfml sample from the book is like so :
        sf::Clock clock;
        sf::Time timeSinceLastUpdate = sf::Time::Zero;

        while (mWindow.isOpen())
        {
                sf::Time dt = clock.restart();
                timeSinceLastUpdate += dt;
                while (timeSinceLastUpdate > TimePerFrame)
                {
                        timeSinceLastUpdate -= TimePerFrame;
                        processInput();
                        update(TimePerFrame);

                        // Check inside this loop, because stack might be empty before update() call
                        if (mStateStack.isEmpty())
                                mWindow.close();
                }

                updateStatistics(dt);
                render();
        }

what's the point of the inner while() loop ? If I understand correctly this will potentially call the input / process functions several times if the previous frame was rendered too slowly... but shouldn't this be handled by the input function who will poll all the queued events anyway ? Also the input / process block can be skipped if timeSinceLastUpdate <= TimePerFrame, but I don't understand what is the point of this.


7
Graphics / question about RenderTextures, and co
« on: May 30, 2014, 01:34:30 am »
Hi!

let's say for example I intend to make a game like Age of Empires 2 ie overhead view, huge map and potentially lots of different sprites intersecting with the current view.
What is the optimal way to do something like this, in terms of RenderTextures ? I admit I'm a bit confused.

The simple solution would be :
- have single rendtexture of the size of the view
- redraw at each frame everything that is viewable

Now, let's assume for instance that the ground texture takes a significative amount of time to draw (for instance, because shaders, or could be tons of textures blended), and that I somehow want to cache it. The same problem would also happen if I wanted to make a game like Baldur's Gate, where the whole map (maybe 10k*10k pixels) is apparently a huge image with no repetitions, and I wouldn't want to load from disk chunks of the map at each frame, when the camera is moving.

I was thinking of doing something like that :
- split the whole map into RenderTextures of 512x512 pixels that would have the cached ground texture
- depending on the current view, draw first the correct cached textures, then draw on top the sprites

My question is : how is that approach scalable with respect to the map size ? I don't really understand how RenderTextures are actually working: is the data stored on GPU ? what's the max number of RenderTextures I can cache? How to compute this max number ?

Basically, what would your advice be for this specific use case ?

8
Graphics / shader keep being bound after call to draw ?
« on: May 28, 2014, 11:19:10 pm »
Hi
I'm trying to understand code from a library
here Sprite3d is a class derived from sf::Sprite:
 
void Sprite3d::draw(sf::RenderTarget& target, ShaderPack& shaderPack)
{
   //a texture was already set for "this"
    screen.draw(*this, &shader1);

    sf::Sprite sprite(*this);
    sprite.setTexture(heightmap);
    heightmapScreen.draw(sprite, &shader2);
}

this produces an unexpected result (for me!) where it seems that the shader1 is being called twice, the second time being during the second draw call, after shader2 is called. Is this normal?
For reference, if I do this instead:
 
void Sprite3d::draw(sf::RenderTarget& target, ShaderPack& shaderPack)
{
   //a texture was already set for "this"
    screen.draw(*this, &shader1);

    sf::Sprite sprite;
    sprite.setTexture(heightmap);
    heightmapScreen.draw(sprite, &shader2);
}
it produces a different result, and seems to call each shader 1 time, which is what I expect would have happened in the first example.

What am I missing here ? The code I'm looking at seems to be actually relying on the behavior from the 1st sample, so it's probably not a bug. I'm smelling that something is very fishy in the copy constructor of sf::Sprite but I'm unable to understand what exactly goes on... any idea?

9
Graphics / limited 3D transforms to textures ?
« on: May 19, 2014, 11:40:48 pm »
Hi
for a simple isometric game I'm drawing things like that :
(click to show/hide)
I'm just drawing a tiles with a diamong shape and then on top a vertex array of diamond "borders" in cyan.

would it be possible in SFML to instead, define all of this as a simple top-view grid with regular "rectangular" tile images, and then perform3D  transformations to obtain the picture I just posted?

Also, would it be possible to do something like that  ?
(click to show/hide)
ie I somehow define 2 textures and their orientation, and I have the ordering be correctly drawn after I do some transformation

Would it be possible in SFML or would I need to use the underlying OpenGL calls?

thanks!

10
Graphics / text window
« on: November 19, 2011, 01:05:20 am »
Hi
is there anyway to do a "text window" in SFML?
IE I define a rectangle of fixed size and I want the text to "fit" into this rectangle using line breaks, and tell me if the text entered is too long.
Is there any way to do this?
thanks

Pages: [1]
anything