How to detect when 2 images that are apart are eventually connected by 3 new images between them

Hi

Am new to corona. Need some help with the code for achieving the following.

I have 2 orange boxes at each end of the screen. What i am trying to do is, have them connected by 3 white boxes in the middle. But how can I make the game know when all 3 boxes connect the 2 orange ones so it can move to the next step.
thanks [import]uid: 10542 topic_id: 3418 reply_id: 303418[/import]

Hi,

Can you explain more what you mean by “connecting” the boxes? What is the intended user interaction?

Tim [import]uid: 8196 topic_id: 3418 reply_id: 10287[/import]

presumably they will all be touching.

O1-W1-W2-W3-O2

on collision, store this info somewhere (ie O1 collides with W1, W3 collides with 02), then check the following info is present

O1W1
W1W2
W2W3
W3O2

how you store that is up to you

remember to remove the collision info for the “ended” phase

[import]uid: 6645 topic_id: 3418 reply_id: 10292[/import]

Yes,

They all will be touching. The boxes will be scattered around the screen not touching at first, then the user will move the white boxes so that they are all touching and connected. with the Orange ones.

Just like Jmp909 said they will be in the following format but not necessarily in a straight line.
O1-W1-W2-W3-O2
(O1,O2 - are Orange boxes that are static)
(W1,W2,W3… etc) are white boxes and are movable)

once this is done it should be detected and move to next level.

I’m kinda new to coding so, some code that will show how this is done will be very helpful.

thanks
[import]uid: 10542 topic_id: 3418 reply_id: 10305[/import]

I guess this will be more like Sokoban, where physics is not such an important factor, right? Is your game tile based when you say that the sequence has to be made or physics based? If it is tile based, then you can just ensure that the tiles have an x/y grid and then check for the positions of the boxes, if the white boxes are in the same x and y+1, y+2, y+3 from the first orange box, the sequence is achieved or sideways with the same y and x+1, x+2, x+3 from the first orange box.

I hope you did get an idea of what I am saying here

cheers,

Jayant C Varma [import]uid: 3826 topic_id: 3418 reply_id: 10328[/import]

Hi Jayantv

I thought about your approach, but the truth is that it may end up being many more white boxes between the 2 oranges ones, and many different directions and ways of them connecting together so, checking the x/y position of every white box seems lengthy. is there a faster way. like i said, am a bit new to the programming thing so forgive me if i miss understood.

Thanks [import]uid: 10542 topic_id: 3418 reply_id: 10340[/import]

Hi Swiftelf,
I understand where you are coming from when you want an easier way to resolve the checking.

Let’s take a simple example of a game of Tic-Tac-Toe, now to determine the winnig position, lets say on the given board
1|2|3
-±±
4|5|6
-±±
7|8|9

you have to check for the combinations of 1-2-3, 4-5-6, 7-8-9, 1-4-7, 2-5-8, 3-6-9, 1-5-9, 3-5-7. For the simplest of games, you have to check these 8 combinations, for your game, not knowing what you r board is like, suggesting an easier way to check is going to be difficult.

All I can say without knowing much about your app is that the winning positions are when there are boxes in between the two orange boxes, right?

so, take for example a board with 10x10 squares and the orange block that determine the start and the end are at either ends, i.e. 2B and 7G

Now you know that to determine the winning sequence, you have to get a connected path from 2B to 7G, each position has 8 squares around it, you you have to check for the presence of a White block that is in either of the 4 directions (N, E, W or S) and keep transversing till you reach 7G, if you cannot reach 7G then it is definitely not connected. It is almost like solving the maze solution problem.

Games will be a bit of hard work, there are no simple solutions, wish there were.

cheers,

Jayant C Varma [import]uid: 3826 topic_id: 3418 reply_id: 10445[/import]

swiftelf, are you using physics/collision detection for this? [import]uid: 6645 topic_id: 3418 reply_id: 12126[/import]

@ jmp909

Nope, it like jayantv said, it similar to Tic-Tac-Toe, or a tile puzzle game where u need to slide the tiles around till they are in the correct position to make the picture.

It’s about 12x12 rows and columns. Keeping in mind that it’s possible to connect the two orange boxes at each end of the screen using multiple routes so, it doesn’t have just one solution.

I hope it’s clear. I’m still unable to come up with code for this. would appreciate the help
thx

[import]uid: 10542 topic_id: 3418 reply_id: 12467[/import]

an adaptation of the flood fill algorithm maybe?
http://en.wikipedia.org/wiki/Flood_fill

[import]uid: 6645 topic_id: 3418 reply_id: 12469[/import]