## Discuss Scratch

fdreerf
Scratcher
100+ posts

### things on a grid

okay so we have a grid and it moves around the stage and can be zoomed in and out of
and we have things like roads and zones that can be placed on the grid and that works (sort of; we'll get to that later)
when you move the grid everything moves on it fine i guess. but when you zoom out all distances are now disproportionate.
i.e. zooming out from zoom level 2 to 1, things that were 3 tiles apart are now 6.
plus, placing things are wonky. they are place at your mouse except x and y coordinates are multiplied by the zoom level
i.e. placing something at zoom level 2 at mouse x 22, y 44 will become 44, 88

help

`when I start as a cloneset [road x v] to ([x position v] of [cursor v])set [road y v] to ([y position v] of [cursor v])go to x ((road x)+([x position v] of [grid v])) y ((road y)+([y position v] of [grid v]))forevergo to frontgo to x ((road x)+([x position v] of [grid v])) y ((road y)+([y position v] of [grid v]))set size to ((100)*(zoom level))...end`

Did you know?
deck26
Scratcher
1000+ posts

### things on a grid

Not sure why zooming out change the distances in terms of tiles - surely the tiles also increase in size?

You also have to decide what coordinate system you're using to store where things are. If you want to record where things are using coordinates based on the non-zoomed map then when you're unzoomed screen coordinates and map coordinates can match with possible adjustments for scrolling. Then when you're at zoom level 2 the map coords are unchanged but the screen coords are two times the map coords (plus any scroll adjustment).

Sharing what you have might make it easier to help.
fdreerf
Scratcher
100+ posts

### things on a grid

deck26 wrote:

Not sure why zooming out change the distances in terms of tiles - surely the tiles also increase in size?
They do. Okay… let's say at zoom level 2, tiles are 66 pixels (3 tiles at z.l. 2). However, at zoom level 1, tiles are half their size; but the distance is still 66 pixels, which is 6 tiles.

Did you know?
asivi
Scratcher
1000+ posts

### things on a grid

Since “grid” is a Sprite the size of “grid” doesn`t affect to his x/y coordinates. You need variables (offset) increasing/decreasing accordingly to size of “grid” to say your clones where to go

`go to x (((road x)+([x position v] of [grid v])) + (Xoffset)) y (((road y)+([y position v] of [grid v])) + (Yoffset))`

That in case that i've understood you.

Edit: it is possible that “offset” not being the correct word/nane. Sorry for my bad English.

Last edited by asivi (March 8, 2018 20:15:59)

fdreerf
Scratcher
100+ posts

### things on a grid

asivi wrote:

You need variables (offset) increasing/decreasing accordingly to size of “grid” to say your clones where to go

What number do I set the variables to?

Did you know?
asivi
Scratcher
1000+ posts

### things on a grid

I have not idea, you need to calculate how much it shrinks or grows in terms of X and Y boundaries depending its size(Including clones size, i suppose).

Last edited by asivi (March 8, 2018 21:02:54)

deck26
Scratcher
1000+ posts

### things on a grid

I'm struggling to understand your description so can't help further without seeing what you have.
asivi
Scratcher
1000+ posts

### things on a grid

Since we don`t know anything about your project this https://scratch.mit.edu/projects/208882474/ could not be exactly that what you need but it could give you some idea.
fdreerf
Scratcher
100+ posts

### things on a grid

deck26 wrote:

I'm struggling to understand your description so can't help further without seeing what you have.
It does not help me on what you are having trouble understanding.

Did you know?
deck26
Scratcher
1000+ posts

### things on a grid

fdreerf wrote:

deck26 wrote:

I'm struggling to understand your description so can't help further without seeing what you have.
It does not help me on what you are having trouble understanding.
When that is the case the best thing to do is share the project. When a project is shared to get help here it will usually be resolved much more quickly than when it isn't.