Simplify these lines of code?

I’m not sure how I could simplify this to make it one line of code

1 Like

Make a function, add a number parameter (type)
if type = 0
then make iron
if type = 1
then make gold
the set wall and set empty can’t be in the function because location can’t be a parameter

1 Like

Ok i think i understand what you mean but could you visualize it for me? Thanks a lot

1 Like

I could send the link if you need

1 Like

one way to combine the code for those two projectile events is to combine the tiles themselves and use the arcade-tile-util extension to make them look different. the arcade-tile-util extension has several “cover tile” blocks that let you disguise one tile as a different one.

for example, take a look at this code:

this game has four breakable tiles (each of the four colors). when the tilemap is loaded, i loop over each breakable tile and cover it with itself while replacing the tile underneath with a different tile. then, i only need overlaps code for a single tile since they are all actually the same underneath.

also, in the overlaps code you need to clear the covered tile in addition to setting it to transparency. that’s the last line in that event block

here’s a link to that code:

2 Likes

Thank you, how though would i make them walls?

@Harmanuary if you want to do walls, swap the overlaps event with an “on hit wall” event and check the tile inside, like so:

image

1 Like

ive tried to drag the scene block that is the tile but it isn’t working

the ones in the array chain