How do I randomly create and remove tiles?

0 favourites
  • 3 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hey guys! Have had alot of help here before and am struggling with an idea.

    To put it simply; can I create a small 32x32 solid tilemap and add/remove random blocks? I've got a jumping based platformer and want to add a little block every now and then that creates a random shape.

    I've read alot about autotiling / arrays and am happy to go deep into these if needed, but thought I'd ask here first to check if I'm missing something relatively simple to add or remove random blocks in a tilemap.

  • You can just use the random function and floor it, but if you want to make random shapes, that would be more difficult. Adding random tiles to random locations is easy though.

    For example:

    tilemap > set tile at

    X: [int(random(tilemap.width)/{put tile dimensions here})] to {whatever tile}

    Y: same as above but using tilemap.height

    To remove tiles you just do the same thing, but with the 'erase' action.

    To make certain shapes you would have to make a whole bunch of rules for where tiles can go, and then use repeat loops or something similar to check each tile in an area for those rules, or something like that.

    ...Or ask someone who knows more than I do about random generation.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks alot man, appreciate it. This will give me a good starting point !

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