Grid Question

Get help using Construct 2

Post » Wed Apr 04, 2012 4:58 pm

Hello Again Dear Community :)
So yes, I am here again with a quick question;
I used to goof around with Construct Classic and making some kind of Terraria / Minecraft 2D clone (for own entertainment, not for sharing really) And I thought I'd make a newer version in Construct 2.
So, I was wondering how to make sure "blocks" (sprites) spawns in an exact pattern (or grid)? I tried my (well, not "my" haha) mathematical equation that used to work the classic version, but it didn't work Construct 2.

A very quick CAP where I tried to make it: http://dl.dropbox.com/u/58042250/cap.capx

The Mathematical equation that I used in classic: floor(MouseX/global('grid'))*global('grid')+global('grid')/2

floor(MouseY/global('grid'))*global('grid')+global('grid')/2

Thanks for any attention / help in advance haha :Dhelehole2012-04-04 17:32:18
B
6
G
2
Posts: 39
Reputation: 1,280

Post » Wed Apr 04, 2012 5:27 pm

Dropbox doesn't require the end user to register to download a file and doesn't slow connexions with advertising and unecessary pages.

Also your equation uses the syntax of construct classic which isn't the case anymore in C2 (don't need the global() stuff, your global variable is named 'grid' ? just write "grid").

Have a look at this topic (found in the how do I FAQ under the "Tiling/Grid" section), it should help you spawning a grid.

In the same FAQ you can find examples of tiling/digging game like terraria and loads of other relative stuff.Kyatric2012-04-04 17:29:02
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,999
Reputation: 57,793

Post » Wed Apr 04, 2012 5:33 pm

Thank you very much for the helpfull advice, and sorry for my rookie mistakes there haha updated the link to a dropbox link (even though I most likely will be able to solve it using the guide haha) :D
B
6
G
2
Posts: 39
Reputation: 1,280

Post » Wed Apr 04, 2012 5:39 pm

if your blocks are all square (like minecraft and terraria) then just place em every width/height of the block. If your blocks are 16x16 and the origin is the top left then x+16 would be to the right of the block y+16 would be below it. You dont need complicated formulas or anythin like that all you need is a starting position and a loop to fill any size space with any size blocks.

If your placin em with a mouse or somethin then you take the mouse position multiply it by the grid size then divide it by the gridsize to force somethin to a grid. Really simple
B
13
S
5
G
2
Posts: 306
Reputation: 3,262

Post » Wed Apr 04, 2012 5:42 pm

Ah haha thanks :D I was wondering how I should write that out then, like "Mouse.x..." kind of thing, sorry for my newbiness here, I am just clueless haha :D
B
6
G
2
Posts: 39
Reputation: 1,280

Post » Wed Apr 04, 2012 5:48 pm

if you still haven't figured it out, use int(mouse.x/16)*16 assuming your tiles are 16x16. This force the position to snap to a 16 by 16 grid
B
83
S
21
G
15
Posts: 1,039
Reputation: 15,134

Post » Wed Apr 04, 2012 5:51 pm

Ah thanks haha *feels quite stupid for not figuring it out* Thank you all for the advice and help :) it does seem a little un-precise though, like, clicking on a certain tile and it creates it on the tile above, this happens if I am slightly close to the tile above (yet not fully clicking on the tile above) if you see what I mean haha helehole2012-04-04 18:09:26
B
6
G
2
Posts: 39
Reputation: 1,280


Return to How do I....?

Who is online

Users browsing this forum: Timedoor Indones and 25 guests