Replies: 1 comment
-
|
Sorry for late reply. Since the rendering depends on the project that uses the library, there is no To render a level, first, you need a way to open the texture file and be able to render tiles from it. Then you can refer to the examples for how to iterate on the tiles of you level. This is from the raylib example: // Load the texture and the renderer.
Texture2D texture = LoadTexture(("assets/" + layer.getTileset().path).c_str());
RenderTexture2D renderer = LoadRenderTexture(level.size.x, level.size.y);
// Draw all the tiles.
ClearBackground(BLACK);
for (const auto &tile : tiles_vector) {
const auto& position = tile.getPosition();
const auto& texture_rect = tile.getTextureRect();
Vector2 dest = {
static_cast<float>(position.x),
static_cast<float>(position.y),
};
Rectangle src = {
static_cast<float>(texture_rect.x),
static_cast<float>(texture_rect.y),
static_cast<float>(texture_rect.width) * (tile.flipX ? -1.0f : 1.0f),
static_cast<float>(texture_rect.height) * (tile.flipY ? -1.0f : 1.0f)
};
DrawTextureRec(texture, src, dest, WHITE);
}
If you show me the code you are using to render images using QPainter, I might be able to provide an example code specific to your project |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I got the library working but I don't know how you render the level. I am using
QCand itsQPainter. Do I do something likelevel.render()or what?Beta Was this translation helpful? Give feedback.
All reactions