How do I make multiple loops?

0 favourites
  • 12 posts
From the Asset Store
SynthWave Loop Pack includes 68 seamless loops, founded on 11 original melodies.
  • is the loop im working with. It freezes, so the loops arent closing.

    just to summarize it. its going through each tile y1-x1-,,,,x30 finding a value thats 4.

    then its checking each tile past that adding 1 to plusrightvalue to work out how many tiles are next to each other.

    then, its adding 1 to axisY to check on the next Y layer the same origional loop at y2-x1,,,,,,,x30

    honestly.. im winging this hard. im not competent in loops, hence my multiple poor descriptions.

    ANY help on multiple loops is deeply appreciated.

    im 4 days in on this. but when its done i can work on pathfinding. battles, and non imp digging jobs

  • If it freezes it’s a logic error somewhere in your loop events where they never end so it becomes an infinite loop.

    To debug where the error is I usually write it a bit at a time and make sure it works for the simpler stuff before adding more to it. That way it’s easier to track when you introduce the error.

    Another idea is to try to use the debugger to step through the events. Although I haven’t really used it and I’m not sure how detailed it’s able to step through your events.

    You could also use “repeat” or “for” instead of “while” for your loops. With those a logic error would just not work instead of freezing. Also tweaking your logic to use those loop conditions instead may help fix the logic anyways.

    Once you get it not to freeze you could log values to the console or editbox as your events run. And that could be a tool to see what is happening and maybe help you spot where to look for the error.

    Just reading the events and running them in your mind sometimes works too. But breaking things down to simpler steps helps more.

    Anyways, those are some strategies I use.

    I used to be better at debugging others code but lack the time and patience lately.

    What you’re running into with using all those while loops is there are many more places for the code to fail so it’s too tall an order to debug from a screenshot. A minimal example to download is better for other users to fiddle with if they get the urge to give debugging a go.

    There could be some action or condition that’s not working as you expected. For that I often find it useful to do small tests with them to better understand what they are doing.

  • When using "While" loops I always add this condition to prevent infinite loops:

    loopindex<100000

    So even if you create an infinite loop by accident, at least it won't freeze.

  • loop ending isnt the problem. i can just slap on a repeat count like you say.

    this works. it goes through all x. on all lines. (left to right) and expands a sprite over tiles next to each other.

    but thats not the issue. in this image, the tiles are connected. it should all be the same "room"

    im getting close. but, i always hit a dead end. i hate that its so hard to explain.. im more hoping someone has done this before and can save me from this tourture.

    how many tiles right, how many tiles down. make sprite to cover it. this is the "room"

    i have some more ideas. if i get it to work, ill offer it up as an example to the forum..in hopes to save others from this pain

  • i made it not transparent.. maybe that helps visualise it

  • ok. best way to describe it.

    just check up

    now with check right active also

    both are enabled

    but it will just do the first loop. it wont do multiple. THIS is what i mean by how do i do multiple loops,

  • i think ive got it.

    its not logical to me. but, its ending after 1 loop. so, i just need the ending of spawning the sprite to calculate the total accumulated values for up down left right.

  • well... its a mess. but working ish

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Loops are actually easy. Algorithms can be harder, especially when making them from scratch.

    So what are you trying to do exactly? Do you want to know all the tiles connected to a certain tile? You can do that with a flood fill algorithm. That could help narrow your search for how people solved that kind of thing before.

    I get lost though when you mention other things you’re trying to do and I’m not seeing a lot of connection. It probably is because I’ve never played the game you’re replicating.

  • ok.

    exactly what i need:

    i want a room to be made that involves all connecting tiles.

    so when i pathfind: i can pick nearest room. then pick a tile.

    i.e on monster created: pick nearest room. pick tile that is free, make a bed.

    i.e: room is 3x3 food room. create chicken every 20 seconds

    i.e prison is 3x3: i0.wp.com/www.gggames.se/wp-content/uploads/2015/12/dungeon_keeper_4.jpg

    (amazed more people havent played dungeon keeper, i was a speed runner)

    You build a square. it is 1 room. you connect 2 squares. that becomes a room.

    sny squares connected are 1 room. if not connected, thay are a seperate room.

    on a map, you can see where each room is. so ill need a map that can read room locations.

    dungeonkeeper.fandom.com/wiki/Secret_1

    i couldnt rip the gif. its the first and only image.

    i could and will flood fill. to get an outline of the room. and i can set a variable to which player it belongs to (huge ambitions) ...mmm multiplayer, but enemies will need that.

    ok. where i am at now>

    just need to figure out spawn points. and merge existing sprites (that are the same room...)

  • if you think i can flood fill an overlapping tilemap: then create a room from it. i am 100% down to try!

    i wanted to spawn a tilemap that had tiles set in the room. so i could pathfind to the room. and it would be eisier to choose a tile

  • its working... its placing things perfectly, and its a tile map. ill need to merge them, or set a variable to show what room it is

    but its working!

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