Discuss Scratch

Jemmerl
Scratcher
100+ posts

Coordinates inside scratch coordinates?

I have a dungeon explorer game I am working on, and I have the area of your dungeon limited to an area on the screen, the rest is for info. How do I set up a grid system that I can lock sprites and clones to, so they don't wander off grid. The grid is 320 x 320 px, with 10 tiles of 32x32px each. The tiles themselves are stamps, as to not cause clone lag and for faster room loading, so I cannot use them. And no, sharing the project won't help- all I need is basic grid info, and cord shrinking; think a mini-map. Anything helps!
Laddie12
Scratcher
100+ posts

Coordinates inside scratch coordinates?

define printTiles
set [hoz v] to [0]
set x to (-160)
repeat (32)
set y to (-160)
set [ver v] to [0]
repeat (32)
change [ver v] by (1)
switch costume to (item ((((hoz) - (1)) * (32)) + (ver))of [tileData v])
stamp
change y by (10)
end
change [hoz v] by (1)
change x by (10)
end

I personally think that clones can run much faster than repeated stamping in some scenarios. It really depends on what you are trying to do. Clones are actually relatively fast.

Last edited by Laddie12 (May 2, 2016 21:49:26)

Jemmerl
Scratcher
100+ posts

Coordinates inside scratch coordinates?

Thanks, but what I mean is a grid system for sprites to lock unto. I have tile placement and generation.
Laddie12
Scratcher
100+ posts

Coordinates inside scratch coordinates?

I did that last summer in the enemy sprite in here (I think): https://scratch.mit.edu/projects/73647648/
This probably won't help you out all that much, but to be honest, I have no idea how I did it
BKFighter
Scratcher
1000+ posts

Coordinates inside scratch coordinates?

You can turn the x,y coordinates into a 10x10 tile grid quite easily with a simple equation. Assuming that the center of you board is in the center of the screen:
(((x position) + (192)) / (32))
And same for y position. This would have the bottom left corner being (1,1) but you could always adjust for that. Also, if you want you can round them to get exactly (1,1) instead of, for example, (1.4234,1.00002).

Last edited by BKFighter (May 3, 2016 16:23:50)

Jemmerl
Scratcher
100+ posts

Coordinates inside scratch coordinates?

Oh! Okay! That works! Thankyou!

Powered by DjangoBB