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

Pages: [1]
1
Graphics / Re: Sprite not drawing, but no errors display.
« on: April 04, 2017, 03:47:49 am »
I'm not sure what the transform is that you're using for these objects. Should it be applied to both "render sprites"? Also, why is it multiplied?

I'm using your NinePatch.hpp, so thanks for that!
You are welcome! I'm very pleased that you find it useful.
One obvious question, though: why are you not using Selba Ward's Progress Bar too? :P

Just following this tilemap here, even though the one I use now is modified a decent amount to fit my needs. https://www.sfml-dev.org/tutorials/2.4/graphics-vertex-array.php#example-tile-map

Ha, I thought about it but I figured what I had planned would be a little less intensive (even though I'm still getting thousands of FPS, ha).

2
Graphics / Re: Sprite not drawing, but no errors display.
« on: April 04, 2017, 01:30:06 am »
I must admit that I'm not entirely sure of the thing you are trying to fix.

Once I've compiled the RenderTexture for the loaded_health_displays sprite and sent it to the window.draw() function, nothing shows up.

It used to work, but at that time, it would display the entire health.png in a single 64x64 tile, erratically, really. I'm just using that as a confirmation that it actually loads the texture correctly, because I haven't messed with that aspect since.

I fixed the errors that you've pointed out, also, I'm using your NinePatch.hpp, so thanks for that!

3
Graphics / Sprite not drawing, but no errors display.
« on: April 04, 2017, 12:49:06 am »
This used to work, but it showed all 9 health bars in a single 64x64 tile. I fixed the way it calculates how to select the correct one instead of all 9, so that "should" work.

Health tiles, 640x64 image with 64x64 tiles, first 64x64 tile is blank for 0 health


Code checks the health's percentage by increments of 10%, returning 0-10, then selects the correct tile. It should work...
if (int_durability < 10 && int_durability > 0)
{
    std::cout << "oh" << std::endl;
    health_quad = &health_vertices[(i + j * map_width) * 4];

    health_quad[0].position = sf::Vector2f(i * tile_size.x, j * tile_size.y);
    health_quad[1].position = sf::Vector2f((i + 1) * tile_size.x, j * tile_size.y);
    health_quad[2].position = sf::Vector2f((i + 1) * tile_size.x, (j + 1) * tile_size.y);
    health_quad[3].position = sf::Vector2f(i * tile_size.x, (j + 1) * tile_size.y);

    health_quad[0].texCoords = sf::Vector2f(int_durability * tile_size.x, 0);
    health_quad[1].texCoords = sf::Vector2f((int_durability + 1) * tile_size.x, 0);
    health_quad[2].texCoords = sf::Vector2f((int_durability + 1) * tile_size.x, tile_size.y);
    health_quad[3].texCoords = sf::Vector2f(int_durability * tile_size.x, tile_size.y);
}
else
{
    health_quad[0].position = sf::Vector2f(i * tile_size.x, j * tile_size.y);
    health_quad[1].position = sf::Vector2f((i + 1) * tile_size.x, j * tile_size.y);
    health_quad[2].position = sf::Vector2f((i + 1) * tile_size.x, (j + 1) * tile_size.y);
    health_quad[3].position = sf::Vector2f(i * tile_size.x, (j + 1) * tile_size.y);

    health_quad[0].texCoords = sf::Vector2f(0, 0);
    health_quad[1].texCoords = sf::Vector2f(64, 0);
    health_quad[2].texCoords = sf::Vector2f(64, 64);
    health_quad[3].texCoords = sf::Vector2f(0, 64);
}

This is the part of the code that turns the current health sf::RenderTexture that displays over the tilemap into a sprite, which is then called to draw from the main game loop.

///DISPLAY TILES
    states.transform *= getTransform();
    states.texture = &m_tileset;

    r_texture.clear();
    r_texture.draw(environment_vertices, states);
    r_texture.draw(floor_vertices, states);
    r_texture.draw(block_vertices, states);
    r_texture.draw(object_vertices, states);
    r_texture.display();

    loaded_map.setTexture(r_texture.getTexture());

    ///DISPLAY HEALTH READINGS
    states.texture = &h_texture;

    r_texture_health.clear();
    r_texture_health.draw(health_vertices, states);
    r_texture_health.display();

    loaded_health_displays.setTexture(r_texture_health.getTexture());

Accessed in the main loop by:

window.draw(tmap.getHealthTexture());

Code to return the sprite:

sf::Sprite getHealthTexture()
{
    return loaded_health_displays;
}

health_vertices is declared like every other tile vertex:
        object_vertices.setPrimitiveType(sf::Quads);
        object_vertices.resize(map_width * map_height * 4);

        health_vertices.setPrimitiveType(sf::Quads);
        health_vertices.resize(map_width * map_height * 4);

Any ideas? Like I previously mentioned, it correctly gets the texture because it used to display it incorrectly, but when I "fixed" that I encountered this flaw in my design. It also correctly selects the tiles that have less than maximum durability, so that's not the issue. (aka it says "oh" for every damaged tile)

Thanks in advance!

Pages: [1]