You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to write a 2d game (remastered version of Digger from 1983 - can be played online here: https://www.futrega.org/digger/)
My question is about the field that can change (it can be eaten by the digger and hobbins, destroyed by falling bags, etc.). It is also used for collision detection to make monsters move along the eaten corridors.
So I draw black textures onto the field to draw tunnels. Then I draw this field texture onto the screen texture.
And it all works nicely (drawing). But now I need to make monsters move around and they need to know where black is (eaten field).
How can I do it efficiently?
On one forum I read what Ray wrote:
... retrieving Texture data is a costly process to be done in a frame-basis, why you need it? What is the use case?
This is the use-case.
I could use
Color GetImageColor(Image image, int x, int y)
But I'm dealing with textures.
Should I draw to an image and then just use this sequence on frame change?
Color *pixels = LoadImageColors(imCopy); // Load pixel data from image (RGBA 32bit)
UpdateTexture(texture, pixels); // Update texture with new image data
UnloadImageColors(pixels);
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to write a 2d game (remastered version of Digger from 1983 - can be played online here: https://www.futrega.org/digger/)
My question is about the field that can change (it can be eaten by the digger and hobbins, destroyed by falling bags, etc.). It is also used for collision detection to make monsters move along the eaten corridors.
So my field is:
I start with:
Then I draw the background in two loops:
Then I draw corridors like this:
Then I finish:
So I draw black textures onto the field to draw tunnels. Then I draw this field texture onto the screen texture.
And it all works nicely (drawing). But now I need to make monsters move around and they need to know where black is (eaten field).
How can I do it efficiently?
On one forum I read what Ray wrote:
This is the use-case.
I could use
But I'm dealing with textures.
Should I draw to an image and then just use this sequence on frame change?
as in this example textures_image_processing ?
How efficient is this?
Or should I change the field both in a texture and in a in-memory image?
Beta Was this translation helpful? Give feedback.
All reactions