How do I make grid positioned objects over another object ?

Get help using Construct 2

Post » Sun Nov 09, 2014 10:02 pm

Please look at the following image:
Image
I want to create grid positioned objects (the blue squares) only where they would overlap another object (the red circle).

How can I do this ?
B
49
S
15
G
6
Posts: 534
Reputation: 7,195

Post » Mon Nov 10, 2014 8:50 am

Hey TGeorgeMihai, :)

You could try covering the circle's entire bounding box with a solid grid of squares, (using a pair of nested X Y loops). Once you're done, destroy any squares that are not overlapping the circle. You should be left with only the overlapping squares.
B
27
S
18
G
8
Posts: 327
Reputation: 6,154

Post » Mon Nov 10, 2014 2:25 pm

@fisholith
Thanks, but I want the blue squares to be grid positioned based on layer, not the object itself, the red circle would only detect the collision with these blue squares.

I tried to use a TileMap, but I can't figure how to check each tile if is colliding with the red circle ... Any idea how can I do this ?
B
49
S
15
G
6
Posts: 534
Reputation: 7,195

Post » Mon Nov 10, 2014 5:39 pm

not the cleanest way, but, you could have a collision checker sprite, make it move through every cell in one tick (via loops), if it overlaps, create the tile at this position, else do not create it, might be able to pull off an exemple if you need it.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Mon Nov 10, 2014 6:30 pm

@TGeorgeMihai here is an exemple, the magic appears with the "place tiles" function. I execute it every 3 ticks just so you can drag n drop the circles to see it at runtime.
You do not have the required permissions to view the files attached to this post.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Mon Nov 10, 2014 7:30 pm

@Aphrodite
Thank you very much. Exactly what I needed :D
B
49
S
15
G
6
Posts: 534
Reputation: 7,195

Post » Mon Nov 10, 2014 10:20 pm

@Aphrodite , excellent example! Thank you!
composer - multimedia artist
www.eli0s.com/en/
B
69
S
26
G
5
Posts: 1,146
Reputation: 9,829

Post » Wed Nov 12, 2014 4:27 am

Hey again TGeorgeMihai. :)
I'd actually assumed you wanted it to be a layer relative grid, though I didn't realize you were also interested in using a TileMap.

What I was originally thinking was that you could paper over the object's bounding box with grid tile objects (aligned to the layer), and then, with a single condition, remove the ones that don't overlap.

With a tile map, you'll need to use an overlap-check object like Aphrodite suggested. Though you can still use the bounding box method I described, to search only the area over the circle's bounding box, instead of the entire tile map.

Although instead of looping over the bounding box to remove non-overlapping tiles, you would simply add overlapping tiles. That's because there's no way to remove all non-overlapping tiles with a single condition, when using a TileMap object. (Which is not a bad thing at all, TileMap is actually more efficient for what you want, it just doesn't natively support collision checking, as far as I know.)

So, I also built an example capx, though Aphrodite beat me to it. :3

fi_demo_TileOverlap.capx
You do not have the required permissions to view the files attached to this post.
B
27
S
18
G
8
Posts: 327
Reputation: 6,154

Post » Wed Nov 12, 2014 6:16 am

@fisholith , what's wrong with all you geniuses in this forum? Are you trying to make us (I speak for my self) feel even more stupid? Throwing around so casually amazing capxs and having no regrets on how complicated those things are for the average Joe. Have you got no mercy??? Daaaamnnnn youououou jeniuseeeeesss! ! ! ! ! ! - a lot of echo- ! ! ! ! !

:D
composer - multimedia artist
www.eli0s.com/en/
B
69
S
26
G
5
Posts: 1,146
Reputation: 9,829

Post » Wed Nov 12, 2014 5:42 pm

@fisholith

Awesome :D I've done something like this (check only the square region of the object instead of the full layer) after I got the example from @Aphrodite , but yours better and more organized.

Image

Thank you all for your help ;)
B
49
S
15
G
6
Posts: 534
Reputation: 7,195


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, Buddhika, R0J0hound and 15 guests