Detecting a contiguous line of objects ( or check collision on create/spawn )

0 favourites
  • 13 posts
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • So, I am generating a 'line' of sprites to detect how many objects are in a line, then moving all those objects in one batch.

    However, I want to truncate the line if there's a gap ( the game is pushing lines of cakes around )

    I can't seem to either check objects with matching x/y or overlay upon spawn ( which would make things really easy)

    In the screenshot, the rat pushes Cake B, it should close the two tile gap, THEN push A, but upon creating the line with a For Loop, I can't exit/stop the loop or not create a line if no cake exists in collision area.

  • Use loop 'For each (ordered)' to sort the queue. Puzzle tray example: dropbox.com/s/q8de9p0c5dpy8zj/jigsaw_puzzle_pic.capx

  • Thanks alextro - that's similar to what I'm currently trying ( but isn't working)

    Start with generic loop , pick cake that matches current index position x/y , then where count is 1 , add the collider ( which pushes the cake ) .

    Where count is 0 stop loop and add a sprite to mark end of 'ray'

  • That's a bit expression intensive but lovely. You might consider to create instance variable "queue" to keep track queue order for each item and retrieve the value to position them by feeding the expression under 'For each (ordered)' condition.

  • I'm stumped as to the best approach, Ideally I'd like the object to just interact independently.

    I.E. If object pushed, test if path blocked, if object pushable, set as 'pushed', then repeat until no obstruction, then move.

  • Are you just wanting to be able to push things around?

    This works. Just change dx,dy and it should work for isometric too. The logic is it checks xy positions along the line by dx,dy steps. If it's a movable object, it is marked. If a wall or free spot is hit it stops the loop. And finally if it stopped on a free spot it moves the player and any marked movable objects

    dropbox.com/s/ayiduh75dimcxcn/sokoban_like.capx

    Edit: smooth motion idea.

    dropbox.com/s/l5f80pnz93658u8/sokoban_like_smooth.capx

  • Thanks R0J0hound - that's amazing - very happy to see you're still around and active one the forums!

    Every time you share something I learn something extra too. Did not know Construct Functions could take parameters.

    The smooth moving version is very elegant. I have a bad habit of adding more stuff instead of simplifying things, what you have with the testing position is spot on.

    I'll post once I've got it working in Isometric - thanks again! :)

  • Here's a rough demo of iso. I'm poor at ripping/creating art but it gets the point across.

    dropbox.com/s/7pz214ogx58jzz0/sokoban_like_iso.capx

  • Wow dude, above and beyond, thanks for sharing. When I get round to doing the devlog video for the final one, I'll be sure to cover your solutions to my roadblock.

    I replicated your much more elegant solution into a 2d grid, with a view to just rendering it out to isometric, rather than trying to calculate collisions / interactions etc in isometric space like before.

    I'm going to update the cat enemy / rat ally logic to work in 2d also, and alter the play area so it's a lot more fast paced. I've deleted 90% of the event sheet to start again :)

    Did you enter the Ludum Dare yourself?

    ldjam.com/events/ludum-dare/52/cake-sweeper

    I posted my progress with some gifs, thanks again for your help, I should use the forums more than once every 2 years :D

    ldjam.com/events/ludum-dare/52/cake-sweeper/one-step-back-for-two-steps-forward-rat-burger-cake-sweeper-v2-0

  • Nice. It is helpful to do stuff from another point of reference. Can be easier to debug in 2d, plus easier to use behaviors.

    Those game jams do look fun. I haven’t done one as of yet. Seems like a good challenge to make something in a short amount of time. Good way to break out of the endless design phase and just start making something. Although I’d probably bite off more than I can chew.

    I do like reading the progress updates for such challenges though.

  • R0J0hound - I finished it finally - I hope I pronounced your name right!

    youtube.com/watch

    The game is playable here:

    johnnysix.net/games/CakeSweeper

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Cool. Always nice to finish a game. Looks interesting.

    I’ve always pronounced it roho, but rojo works too. When it comes down to it I used zeros instead of O’s so it’s not really pronounceable.

  • Such an enjoyment to play the game despite that I don't know all the rule especially with the cat's hand.

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