Is it Possible To Check For Objects Position?

Get help using Construct 2

Post » Mon Jul 01, 2013 4:53 am

Hi Everyone,

I want to clarify the title,I want to know is it possible to check if Objects are right next to eachother without Arrays?

In my case im looking to make my plain dirt tile turn into a grass covered dirt tile after a breif wait period,But only if it is already next to a grass covered dirt tile.

Thats why i needed to know how to check if tiles are side by side.I also have plans to use this same style of events in different parts of this project.
Thanks everyone i hope i was detailed enough.RookieDev2013-07-01 04:54:43
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Mon Jul 01, 2013 5:58 am

For something like mapping in your case, you will want to use array.

Sure, there are other ways, but if everything is in a grid, then you could check for adjacent tile right away.

But if you prefer, one possibility is, you could adjust the collision mask of any frame of any sprite in the sprite editor. Perhaps, you could try expand the collision mask of your plain dirt tile a bit more, and then check whether it is overlapping other objects in question or not. But again, you will also want to check for performance in this. Having many of these at once might not be a good idea.
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,469

Post » Mon Jul 01, 2013 6:00 am

Overlap at offset would work in your case. It checks if objects overlap at defined offset.
B
24
S
9
G
7
Posts: 756
Reputation: 7,312

Post » Mon Jul 01, 2013 6:05 am

@keroberos the thing about arrays is that its just to complicated for me to grasp at this time.I have gotten no sleep because of arrays.I was hoping to find alternate ways of checking if a tile is next to another tile.I will try your way and i have heard of a different from a friend on the forums.Thanks you keroberos

@vee41 So would i just make my collison mask bigger? and if i did make it bigger it would make my solid collision with my player funky aswell wouldnt it?
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Mon Jul 01, 2013 6:09 am

You can go old-school and check the bounding-box values.
ImageImageImage
B
71
S
22
G
247
Posts: 3,753
Reputation: 137,552

Post » Mon Jul 01, 2013 6:09 am

[quote] So would i just make my collison mask bigger? and if i did make it bigger it would make my solid collision with my player funky aswell wouldnt it? [/quote]

Yes, it will affect the player object as well.

You could try another trick like this:

On the start of layout, for all of your objects that are plain dirt tile, create an invisible object that has collision mask bigger than your tiles. Now, with this, you refer and check to this invisible object for overlapping and check whether those tiles that overlapped are plain dirt tile or not. If so, ...you know what to do. ;)
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,469

Post » Mon Jul 01, 2013 6:15 am

@blackhornet i would love to know more about checking for the bounding box values.I never heard of doing such a thing.

@keroberos i like this idea of creating an invisible sprite,I could be more precise with where i want to check for the overlapping collision.But also it has a fall back,Wouldnt i really be generating twice as many sprites than really needed? If i cant find another route i will have to use the double sprite techniqe.Thanks for replying so fast.RookieDev2013-07-01 06:16:05
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Mon Jul 01, 2013 6:18 am

You only create the invisible object on the tile that has respective frame that you want to check. You do this in one go. The number of objects won't be doubled, but yes, it will still increase.

Actually, ...how many tiles objects do you have anyway? And which device are you actually trying to put this game on?
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,469

Post » Mon Jul 01, 2013 6:26 am

[QUOTE=keroberos] You only create the invisible object on the tile that has respective frame that you want to check. You do this in one go. The number of objects won't be doubled, but yes, it will still increase.

Actually, ...how many tiles objects do you have anyway? And which device are you actually trying to put this game on?[/QUOTE]


@keroberos im generating one hundred tiles and im making this game for tablets and high end phones

I plan on reusing the function for different layouts.I just need a for sure way to check if tiles are right next to each other which seems it is possible to do without arrays.RookieDev2013-07-01 06:29:26
GMO FOOD = DEATH
B
23
S
9
G
5
Posts: 567
Reputation: 6,378

Post » Mon Jul 01, 2013 6:32 am

Here just a quicky showing the bounding box expressions.
bbox-print.capx

The Top and Bottom values are the same, and the Right value = Left value of the adjacent tile. (You may want a buffer of a pixel or two when calculating).

The algorithm is simply, pick the tile to compare, and cycle through every other tile to see if it's Top and Right equal the Top and Left of the other tile. If so, they are adjacent (on the right). You can do the opposite to check the left-side.blackhornet2013-07-01 06:58:05
ImageImageImage
B
71
S
22
G
247
Posts: 3,753
Reputation: 137,552

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 14 guests