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 - Nybble

Pages: [1] 2
1
SFML projects / Re: Nero Game Engine
« on: August 19, 2020, 03:41:21 am »
Man every version just gets better and better, good job on this, this is really cool.

2
SFML projects / Re: [Steam Release] Open Hexagon
« on: August 19, 2020, 03:26:28 am »
This game is awesome, I stumbled on your youtube channel then your website because of this game and have to say, good job man, awesome work.

3
General discussions / Re: Goodbye
« on: June 10, 2019, 03:25:34 am »
Thank you so much, for contributing to this wonderful project, you have helped so many people just out of the goodness of your hearts, I thank you for being so awesome, that goes to all the SFML contributors.

4
Graphics / sf::Transformable combine
« on: April 01, 2016, 08:51:07 pm »
Hello every one, what I am trying to do is "combine" 2 transforms, but it is not working, it works fine when it collides on all sides BUT the left side of another rectangle... I just think I'm using the combine method wrongly.

Object object; //this is my own "Entity" class which inherits from sf::Transformable and has methods to get "rectangle dimensions"
Vector2f offset(100,100);// arbitrary number in this case
sf::Rect<int> bb;

sf::Transform temp(0,0,offset.x, 0,0,offset.y, 0,0,1);
temp.combine(object.getTransform());

        sf::FloatRect localBounds(0.f,0.f, object.Box.width, object.Box.height); // object.Box is just a sf::Rect<int>
        sf::FloatRect globalBounds( temp.transformRect( localBounds ) );
        bb = { globalBounds.left, globalBounds.top, globalBounds.width, globalBounds.height };
 

now if I just use:
sf::Transformable temp;
temp.setPosition(object.getPosition().x, object.getPosition().y);
temp.setOrigin(object.getOrigin());
temp.setRotation(object.getRotation());
temp.setScale(object.getScale());
 

then compute the local bounds and global bounds it works fine, so I'm pretty sure I'm just not using the combine method the right way, is not a big deal, since I got it working with the second method, I just want to know how to use the sf::Transform::combine method the right way, thanks.

5
General discussions / Re: aMessage_To_Laurent
« on: September 03, 2015, 02:27:10 am »
I would like to thank all of you guys as well, SFML is just great, even if is just as a hobby it is just awesome, thanks SFML development team:

Code: [Select]
- Nexus
- binary1248
- Tank
- Grimshaw
- eXpl0it3r
- Hiura
- Sonkun

6
Graphics / Re: Basic rendering crashing
« on: February 11, 2015, 02:12:38 am »
Same here... My project works fine in 2.1 but made the switch and when I try to render anything it crashes... everything works fine except when I try to render...

I tried out your example Ivan and it does crash me, I'm guessing it's the graphics card... I do know I have an old graphics card:

radeon hd 4350:

Graphics Engine: Radeon HD 4350
Video Memory: 512MB memory
Memory Interface: 64-bit
DirectX® Support: 10.1
CrossFireX Support: Yes, (software mode)
Bus Standard: PCI Express x1 (works in x4, x8 and x16 PCIe slots)
Core Speed: 600MHz
Memory Speed: 400MHz x2 (800MHz effective)
Ports: 2 x DVI-I, 2 x VGA (with adapter), 1 TV Out
Output Ports: DMS59, TV Out
Number of Monitors Supported: Two DVI
Form Factor: Small Form Factor (SFF) Single Slot
Dimensions: 2.4" H x 6.7" D
Warranty: 3 year limited warranty8

7
Graphics / Re: Rendering slows down FPS
« on: September 26, 2013, 05:27:41 pm »
Well I didn't show the code here but I do use a timestep...  here is the code:

Quote
class Cfps
{
    private:
        int     rate;
        float   startTime;
        float   lastTime;
        int     Fps;
        int     frames;
        float   speed;

        sf::Clock   fpsClock;

    public:
        Cfps();
        Cfps(unsigned int _rate);

        int     getFps();
        float   getSpeed();
        void    update();
};
//==================================================================
/// Cfps
//==================================================================

Cfps::Cfps(unsigned int _rate)
{
    rate        = _rate;
    startTime   = 0;
    lastTime    = 0;
    Fps         = 0;
    frames      = 0;
    speed       = 0;
}

Cfps::Cfps()
{
    rate        = 60;
    startTime   = 0;
    lastTime    = 0;
    Fps         = 0;
    frames      = 0;
    speed       = 0;
}
//----------------------------------------------------------------
int Cfps::getFps()     {return Fps;}
//==================================================================
float Cfps::getSpeed() {return speed;}
//==================================================================
void Cfps::update()
{
    sf::Time ticks = fpsClock.getElapsedTime();

    //one second has passed ( 1000 miliseconds )
    if (startTime + 1000 < ticks.asMilliseconds())
    {
        startTime   = ticks.asMilliseconds();
        Fps         = frames;
        frames      = 0;
    }
    speed           = ( (ticks.asMilliseconds() - lastTime) / 1000 * rate );
    lastTime        = ticks.asMilliseconds();
    frames++;
}
Cfps    appFps(60);

then I do this in the main loop before update:
Quote
appFps.update();

same result.....

I think you are right though, what I need to do is multiply movement by delta time, I think...

8
Graphics / Re: Rendering slows down FPS
« on: September 26, 2013, 04:45:21 pm »
Ok here it is:

Quote
class MyEntity
{
public:
    MyEntity() : sprite(m_texture)
    {
        m_texture.loadFromFile("lucas.png");

        sprite.setTextureRect(sf::IntRect(0,0,40,40));
        sprite.setPosition(0, 0);
    }

    virtual void draw(sf::RenderWindow& target) const
    {
        target.draw(sprite);
    }

    sf::Sprite sprite;
    sf::Texture m_texture;
};

Quote
class TileMap : public sf::Drawable, public sf::Transformable
{
public:

    bool load(const std::string& tileset, sf::Vector2u tileSize, const int* tiles, unsigned int width, unsigned int height)
    {
        // load the tileset texture
        if (!m_tileset.loadFromFile(tileset))
            return false;

        // resize the vertex array to fit the level size

        // populate the vertex array, with one quad per tile
        for (unsigned int i = 0; i < width; ++i)
            for (unsigned int j = 0; j < height; ++j)
            {
                // get the current tile number
                int tileNumber = tiles[i + j * width];
        m_vertices.setPrimitiveType(sf::Quads);
        m_vertices.resize(width * height * 4);

                // find its position in the tileset texture
                int tu = tileNumber % (m_tileset.getSize().x / tileSize.x);
                int tv = tileNumber / (m_tileset.getSize().x / tileSize.x);

                // get a pointer to the current tile's quad
                sf::Vertex* quad = &m_vertices[(i + j * width) * 4];

                // define its 4 corners
                quad[0].position = sf::Vector2f(i * tileSize.x, j * tileSize.y);
                quad[1].position = sf::Vector2f((i + 1) * tileSize.x, j * tileSize.y);
                quad[2].position = sf::Vector2f((i + 1) * tileSize.x, (j + 1) * tileSize.y);
                quad[3].position = sf::Vector2f(i * tileSize.x, (j + 1) * tileSize.y);

                // define its 4 texture coordinates
                quad[0].texCoords = sf::Vector2f(tu * tileSize.x, tv * tileSize.y);
                quad[1].texCoords = sf::Vector2f((tu + 1) * tileSize.x, tv * tileSize.y);
                quad[2].texCoords = sf::Vector2f((tu + 1) * tileSize.x, (tv + 1) * tileSize.y);
                quad[3].texCoords = sf::Vector2f(tu * tileSize.x, (tv + 1) * tileSize.y);
            }

        return true;
    }

private:

    virtual void draw(sf::RenderTarget& target, sf::RenderStates states) const
    {
        // apply the transform
        states.transform *= getTransform();
        // apply the tileset texture
        states.texture = &m_tileset;
        // draw the vertex array
        target.draw(m_vertices, states);
    }
    sf::VertexArray m_vertices;
    sf::Texture m_tileset;
};

and main:

Quote
int main()
{

    MyEntity entity;

// create the window
    sf::RenderWindow window(sf::VideoMode(800, 600), "Tilemap");

    // define the level with an array of tile indices
    const int level[] =
    {
        0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
        0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0,
        1, 1, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3,
        0, 1, 0, 0, 2, 0, 3, 3, 3, 0, 1, 1, 1, 0, 0, 0,
        0, 1, 1, 0, 3, 3, 3, 0, 0, 0, 1, 1, 1, 2, 0, 0,
        0, 0, 1, 0, 3, 0, 2, 2, 0, 0, 1, 1, 1, 1, 2, 0,
        2, 0, 1, 0, 3, 0, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1,
        0, 0, 1, 0, 3, 2, 2, 2, 0, 0, 0, 0, 1, 1, 1, 1,
    };

    // create the tilemap from the level definition
    TileMap map;
    if (!map.load("tileset.png", sf::Vector2u(32, 32), level, 16, 8))
        return -1;
       
    window.setFramerateLimit(60);
    float x = 0, y = 0;
    // run the main loop
    while (window.isOpen())
    {
        // handle events
        sf::Event event;
        while (window.pollEvent(event))
        {
            if(event.type == sf::Event::Closed)
                window.close();
        }
        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
        {
            x+=1; //y+=1;
            entity.sprite.setPosition(x,y);
        }

        // draw the map
        window.clear();
        window.draw(map);
        entity.draw(window);
        window.display();
    }

    return 0;

}

now if I change     if (!map.load("tileset.png", sf::Vector2u(32, 32), level, 16, 8))

the 16 to say 116 it will draw more of the texture horizontally and slow down the "entity" as it moves compare to when it was 16, same thing if I add vertically etc...

also if I comment out the part that draws the "map" it speeds up the movement of the entity....

9
Graphics / Re: Rendering slows down FPS
« on: September 26, 2013, 05:44:35 am »
Alright so lets just take the code from the "example tile map", lets just say I'm using this code.


Quote
const int level[] =
    {
        0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
        0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0,
        1, 1, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3,
        0, 1, 0, 0, 2, 0, 3, 3, 3, 0, 1, 1, 1, 0, 0, 0,
        0, 1, 1, 0, 3, 3, 3, 0, 0, 0, 1, 1, 1, 2, 0, 0,
        0, 0, 1, 0, 3, 0, 2, 2, 0, 0, 1, 1, 1, 1, 2, 0,
        2, 0, 1, 0, 3, 0, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1,
        0, 0, 1, 0, 3, 2, 2, 2, 0, 0, 0, 0, 1, 1, 1, 1,
    };

    // create the tilemap from the level definition
    TileMap map;
    if (!map.load("tileset.png", sf::Vector2u(32, 32), level, 16, 8))

even using this small "map" slows gameplay a lot...

Quote
void Render(PencilTool& renderer)
    {
        Window.clear(sf::Color(0, 135, 206, 250));

        for( size_t i = 0 ; i < objectList.size(); i++)
        {
            objectList->Render(renderer);
        }

        Window.display();
    }

and the "PencilTool" is just this:

Quote
void Draw(sf::RenderWindow& window, sf::Sprite& object, const float& x, const float& y, const int16_t& x2, const int16_t& y2, const int16_t& w, const int16_t& h)
{
object.setPosition(x,y);
        object.setTextureRect(sf::IntRect(x2,y2,w,h));

        window.draw(object);
}

pretty generic stuff, that is all it does, and I obviously update object's position etc...
I never said "I did what X said and it doesn't work,"... clearly I said I used the code from here: http://www.sfml-dev.org/tutorials/2.0/graphics-vertex-array.php    after failing badly on my own, but anyways, I appreciate your help.

@ binary1248  wth are you talking about? I said after I THOUGHT my method was the problem (clearly wasn't the issue) I tried the vertext tut code, no push_back or stl etc and it does the EXACT same thing so how is the push_back the problem when the problem exist even without it?

10
Graphics / Rendering slows down FPS
« on: September 26, 2013, 05:17:37 am »
I am so frustrated trying to figure out why every time I render a "tile map" it slows down game play so much, I used a simple nested for loop to draw tiles like so:
Quote
for(int y = 0; y < mapHeight; y++)
for(int x = 0; y < mapWidth; x++)
{
    v.push_back(tile);
// same as v[y]
  • ; you get the point...

}

I thought this was the problem so I copied and pasted the code to for tile map from this LINK: http://www.sfml-dev.org/tutorials/2.0/graphics-vertex-array.php 

and yet again same thing happens, I have a simple question:
is it supposed to slow down the overall game play the more you draw? it makes no sense to me because if I draw a map lets say 40x40 it slows down a little, then if I draw 80x80 it pretty much slows down twice as much and so on so forth...

Is it maybe a bug with my entity update and/or rendering logic? I don't think it is, is simple update/rendering logic.

If you guys want to see some code, I would happily post it, I don't think it is needed, this happens regardless of how I approach it...

11
Network / Re: Sfml packet questions
« on: May 28, 2013, 04:14:31 am »
Well since I got it answered a while back and I remember this thread let me post my answer:

Code: [Select]
vector<char> buffer;
Packet & Packet::operator << (const unsigned int & data)
{
    unsigned char const * p = reinterpret_cast<unsigned char const*>(&data);
    std::copy(p, p + sizeof(data), std::back_inserter(buffer));
    return *this;
}

and to retrieve the data (in this case unsigned int):

Code: [Select]
vector<char> buffer;
Packet& Packet::operator >> (unsigned int & data)
{
    std::copy(&buffer[pos], &buffer[pos] + sizeof(data), reinterpret_cast<char*>(&data));
    pos += sizeof(data);
    return *this;
}

of course you can use templates if you want.

If you are using char arrays this is a better approach:
Code: [Select]
*(uInt32*)(&buffer[position]) = data;

and:

Code: [Select]
data = *(uInt32*)(&buffer[position]);

For anyone that might stumble across this post looking for something similar.

12
Network / Re: Sfml packet questions
« on: May 26, 2013, 02:07:50 pm »
I want to write unsigned longs, long longs, int etc on to vector<char> and the other ay around.

13
Network / Sfml packet questions
« on: May 26, 2013, 07:51:32 am »
Hello everyone, I hope this hasn't been asked before I have searched for a while now and could not find the answer to this...

The Sfml::Packet class is pretty simple and I'm trying to do something like what the class does, where I am having trouble is copying unsigned long or long long etc, I was using stf::copy but it was not working properly... I then used memcpy and it works but then I'm having trouble with the position on vector... take a look at this:

This is the Packet& operator >> (const unsigned long & data)
Quote
std::copy(&data, &data+ sizeof(data), std::back_inserter(buffer));

This is the Packet& operator >> (unsigned & long data)
Quote
std::copy(buffer[0] + pos, &buffer[0] + pos + sizeof(data), &data);
        pos += sizeof(dataSize);

this work for small numbers but if I use bigger numbers it will spit random numbers....

If Laurent or anyone that has had some experience with could help me with this, that would be awesome.

the memcpy version works like this
Quote
memcpy(&buffer[0], &data, sizeof(data));

AND:

memcpy(&data, &buffer[0], sizeof(data));

But the problem is when I use the operator it is always getting buffer[0] obviously and I am stuck on how to move the pos variable accordingly, it is really late an I have been at it for a while so I know is probably simple but my brain is blocking common sense right now...

14
SFML projects / Re: Map00(tile editor) - binary + source
« on: May 26, 2012, 12:54:37 am »
Sure thing, let me know what you think, How can I improve it? what features would make it better? etc any input.

15
SFML projects / Map00(tile editor) - binary + source
« on: May 18, 2012, 06:58:40 am »
Hello guys, I am releasing my "tile map editor", it is very simple right now but it gets the job done ;).

Features:
  • Load .nyb configuration files
  • Loads textures only once.
  • scrolling camera with Left/Right  Up/down buttons
  • right mouse button deletes tiles
  • left mouse button creates current selected tile

Notes:
  • the .nyb file contains the map name, map Width/Height, the tile size, map file and map texture. the files MUST be in the same directory for it to properly load them.
  • It uses a texture cache class to load textures, this prevents re-loading the same image more than once
  • My current camera class is much better than the one in this project and has the ability to lock on to targets, this can be easily implemented here.

DOWNLOAD: http://www.mediafire.com/?q1zwta1vv1q38q1

How to use:

1. You can either generate a map by creating a new mapEdit object like this:
Code: [Select]
Ccamera mapCam(640, 480);
mapEdit oMap("My map", 40, 40, 32, "tileSet.png",  mapCam);
Or like this :

Code: [Select]
Ccamera mapCam(640, 480);
mapEdit oMap(mapCam);

oMap.generate("My map", 40, 40, 32, "tileSet.png",  mapCam);

First is map name, then map width, map height, tilesize, tileset texture (PATH) and camera object,
after that you can edit your newly created map and save it.

To load a map is rather  easy this is how :
Code: [Select]
Ccamera mapCam(640, 480);
CmapEdit oMap(mapCam);
oMap.loadConfig("map00/map00.nyb");

and the map will be loaded using the loadConfig(std::string& _mapConfig); function, you can also load it at anytime using this function instead.

2. There are a couple of stuff I need to fix specially some of the mapEdit functions, I will fix them and update you guys.

Controls:
Quote
1. Scrolling : Left/Right, Up/Down   ( scrolls through the map ).
2. Placing tiles: mouse left click.
3. Deleting tiles: right mouse click.
4. changing tiles: A/S - A to move forward on the tile sheet and S to move backwards.
5. Save map: just press the X button on your keyboard.

Things to come:
  • Map clearing: a single press of a button and clear out the whole map
  • map generation/loading input: I'm going to implement a better way to load and create map files by input rather then having to manually edit the code ;)

Please leave comments/criticism/feedback if you want.

You can use this however you please, but don't claim as your own  :-\, I encourage to expand on it too and share!!

Media:




DOWNLOAD: http://www.mediafire.com/?q1zwta1vv1q38q1

Pages: [1] 2