0 votes

I'd like to create an image that is made by compositing tiles from another source image. While I could do this just by adding a lot of sprites to the screen, I feel it would make more sense to composite an offscreen image and then use that as the source of a single sprite. (This image is meant to be a background terrain, with things like rivers and roads drawn upon it.) Is there a way to do this? The docs have quite a bit of info of using a tile set to make independent sprites, but I'm having trouble finding anything for compositing(ie, creating your own image on the fly).

in Engine by (115 points)

you can collect and categorize tiles in a TileSet
you can then draw with that TileSet to many layers of TileMap
https://docs.godotengine.org/en/stable/tutorials/2d/using_tilemaps.html

is that what you mean? you can also create images by setting individual pixels but using TileMaps would be easier

_image.create(int(size.x), int(size.y), false, Image.FORMAT_RGBA8)
_image.lock()
for y in range(size.y):
    for x in range(size.x):
        var actualX := int(x + offset.x)
        var actualY := int(y + offset.y)
        _image.set_pixel(x, y, _level.getMapColor(actualX, actualY))
_image.unlock()
_image.expand_x2_hq2x()
_image.expand_x2_hq2x()
_imageTexture.create_from_image(_image)

Thanks. That looks helpful. I'm going to need to read up to see how to load my initial image and then how to draw my _imageTexture to the screen.

this is the minimal code that you need to draw pixels to screen using an image

https://gist.github.com/kasthor/da23d1ed802a1eab7ac354305608f40f

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.