How do I generate a tile object based on a black and white or black and transparent image?

1 favourites
  • 9 posts
From the Asset Store
Elevate your games with our AI Chatbot Integration! Seamlessly connect your Construct 3 projects with GPT-4 for dynamic,
  • Is there a way to generate a tile object for collision purposes without manually tracing each black line of this maze? Thank you!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Interesting. I'm playing with that AddOn now. It may be an alternate way to get a good result. Thank you!

    Ashley Do you know if what I'm asking is possible, or is the ROTJS AddOn the closest thing? Thank you.

  • It is possible, but a bit roundabout.

    Paste the image into a drawing canvas object. Save the snapshot. Then you'll have access to pixel data at x/y. Loop through coordinates at your desired resolution, and set an overlapping collision tilemap's tiles accordingly by comparing the pixel data at each location if black/white. It only needs to be done once at start of layout, so it should probably be fine to use a high resolution, or go pixel by pixel even.

  • Okay, that definitely sounds promising and very close to what I'm looking for. I'll do my best here and will update this thread if I make progress or maybe need more guidance on those steps. Thank you!

  • oosyrag I was able to do the first part.

    The 2nd part is far more complex. I'm unsure if it can be done just through Events, a script, or both. Would you please be able to assist with getting this to work, with the example maze provided in this post. We can certainly work out fair payment over PayPal as well if that's allowed. Thank you.

  • dropbox.com/s/3lp90ilj38s9nio/pixeltransfer_example.c3p

    I'm not sure what's going on with that first row of pixels. Might be worth a bug report.

  • Thanks for the example file. It does seem to "work" in the sense that after a second or two a black and also pink/magenta copy loads. The magenta copy that loads is the one that has collision properties. What's interesting is then I hear my computer fans spinning like crazy and scaling the generated collision tiles is proving difficult.

    I'm currently exploring a variation of the script to procedurally generate either 3d boxes for collision or sprites for collision, based on the concepts and scripts seen in this video: youtube.com/watch

    I'm also revisiting and playing with the ROTJS plugin suggested earlier. Thank you!

  • The black copy is the drawing canvas copy, and the pink copy is the tilemap. You can get rid of or hide the first two as you wish.

    The game is doing nothing after the initial load as far as transferring the image to the drawing canvas and tilemap is concerned.

    High cpu usage is probably from the collision checks - each pixel is a tile. You can lower the overhead by lowering the resolution of tiles. This will also speed up the initial draw.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)