How do I generate a grid automatically

Get help using Construct 2

Post » Thu Sep 25, 2014 7:35 pm

hi guys, i want to generate a grid on a 2048x1200 layout (the visible is 1024x600 but i need the entire layout)

in that grid i will create some random items later...


any tutorial?...
B
7
S
2
Posts: 57
Reputation: 591

Post » Thu Sep 25, 2014 11:17 pm

Check my example here:
how-do-i-check-instance-y-position_t110979

It's a file with the name Grid_of_square
ImageImage
B
108
S
49
G
23
Posts: 783
Reputation: 22,611

Post » Thu Sep 25, 2014 11:46 pm

@alextro
i have your example but i don't know how to adapt it to my 2048x1280 layout

i would need to distribute it in 9 rows and 12 columns or something like that...

then in random instances i will create some stuff, it's not for movement to be precise
B
7
S
2
Posts: 57
Reputation: 591

Post » Fri Sep 26, 2014 4:08 am

That's relative simple task, just adjust some code.
Below I provided the 12x9 grid, the rest would be your customization
You do not have the required permissions to view the files attached to this post.
ImageImage
B
108
S
49
G
23
Posts: 783
Reputation: 22,611

Post » Fri Sep 26, 2014 6:35 pm

@alextro
it worked perfectly!! i suggest to add this to the tutorial section!!

Changing the for loops i can create extra rows and columns, and also the spacing.

Thanks!!!
B
7
S
2
Posts: 57
Reputation: 591

Post » Fri Sep 26, 2014 7:15 pm

Great to hear that from you.
I'm no near professional coder but when something working around my logic, why not?

Forgot to mention that total squares was 120 which isn't 12x9=108
Hope you can figure out to fix that amount.
ImageImage
B
108
S
49
G
23
Posts: 783
Reputation: 22,611

Post » Sat Sep 27, 2014 6:07 am

i only had to change the number of loops and it worked!

here i uploaded a screenshot, i created the grid, then i picked random grid tiles and spawned several plants at random grids until there were a certain number of plants (like 100) :)


Now i can spawn plants, treasure chests,monsters and more with the tiles.


thanks! :)
You do not have the required permissions to view the files attached to this post.
B
7
S
2
Posts: 57
Reputation: 591


Return to How do I....?

Who is online

Users browsing this forum: RalleRoyal and 28 guests