Discuss Scratch

SEABASS1234
Scratcher
34 posts

Tile generator

Hi there! I was wondering how tile generation works. I think it would really help my game along. Thanks!
georgeskey
Scratcher
100+ posts

Tile generator

What type of tile generation?
SEABASS1234
Scratcher
34 posts

Tile generator

level tile generation. That would be great!
Birdlegs
Scratcher
1000+ posts

Tile generator

SEABASS1234 wrote:

level tile generation. That would be great!
I'm working with a tile builder right now. It turned out to take a long time… But you can steal it if you want, and if you can understand it ;D
SEABASS1234
Scratcher
34 posts

Tile generator

JoeyTheChicken wrote:

SEABASS1234 wrote:

level tile generation. That would be great!
I'm working with a tile builder right now. It turned out to take a long time… But you can steal it if you want, and if you can understand it ;D
thanks!
can u explain it to me?
Birdlegs
Scratcher
1000+ posts

Tile generator

SEABASS1234 wrote:

JoeyTheChicken wrote:

SEABASS1234 wrote:

level tile generation. That would be great!
I'm working with a tile builder right now. It turned out to take a long time… But you can steal it if you want, and if you can understand it ;D
thanks!
can u explain it to me?
Well, I put together a developer mode where you can place tiles. Here, it stamps them to create a visual representation of the level. My tiles are 20x20 pixels, scaled up by two, so in the viewer, they're 40x40 pixels. Because of this, I can snap them to

gotox:roundmousex/40*40y:thesameasx,butwithmousey

Then, I press space. When I do, it stamps the tile, and it saves its x, y, and costume to a list. So…

addmousexto areaaddmouseyto areaaddCostume#to area

Note that I use the same rounding system for mousex and y, but when placing the tiles, they have to scale back up. Otherwise, they'll all clump in the center. The best thing to do next is to turn the list into one string, so
repeatlengthofareachangesavenumby1setsaveto(join [savejoin;joinitemsavenumof ;)]

I'll finish that after class

Okay, so then you can add the variable “save” to another list, and then show the list. This is so you can easily copy and paste it, as you can copy and paste from a list. Then, I have a custom block that runs when you load a new screen.

onscreen1,0,2,3,loadcopy and paste what you got from the list here

I just stack up a bunch of those. The order doesn't matter. What it does is checks for the first string, which is the coordinates. I have an X, Y, Z, and W coordinate, W is just in case. When you change screens, you have to change the coordinates. I stuff them all into one variable called (Map), so they're separated by commas. Then, you turn the second string back into a list. I can explain that if you need it.

The last thing you need to do is have the tile read over the data in the list, use the data, and clone itself. Mind the 301 clone limit. Running without screen refresh can help a lot here. You can read it all over just one list because the first value will be X, the second Y, and the third the costume number, and that pattern will repeat the whole time, so it can all be one list.

Last edited by Birdlegs (May 5, 2015 14:33:48)

SEABASS1234
Scratcher
34 posts

Tile generator

JoeyTheChicken wrote:

SEABASS1234 wrote:

JoeyTheChicken wrote:

SEABASS1234 wrote:

level tile generation. That would be great!
I'm working with a tile builder right now. It turned out to take a long time… But you can steal it if you want, and if you can understand it ;D
thanks!
can u explain it to me?
Well, I put together a developer mode where you can place tiles. Here, it stamps them to create a visual representation of the level. My tiles are 20x20 pixels, scaled up by two, so in the viewer, they're 40x40 pixels. Because of this, I can snap them to

gotox:roundmousex/40*40y:thesameasx,butwithmousey

Then, I press space. When I do, it stamps the tile, and it saves its x, y, and costume to a list. So…

addmousexto areaaddmouseyto areaaddCostume#to area

Note that I use the same rounding system for mousex and y, but when placing the tiles, they have to scale back up. Otherwise, they'll all clump in the center. The best thing to do next is to turn the list into one string, so
repeatlengthofareachangesavenumby1setsaveto(join [savejoin;joinitemsavenumof ;)]

I'll finish that after class

Okay, so then you can add the variable “save” to another list, and then show the list. This is so you can easily copy and paste it, as you can copy and paste from a list. Then, I have a custom block that runs when you load a new screen.

onscreen1,0,2,3,loadcopy and paste what you got from the list here

I just stack up a bunch of those. The order doesn't matter. What it does is checks for the first string, which is the coordinates. I have an X, Y, Z, and W coordinate, W is just in case. When you change screens, you have to change the coordinates. I stuff them all into one variable called (Map), so they're separated by commas. Then, you turn the second string back into a list. I can explain that if you need it.

The last thing you need to do is have the tile read over the data in the list, use the data, and clone itself. Mind the 301 clone limit. Running without screen refresh can help a lot here. You can read it all over just one list because the first value will be X, the second Y, and the third the costume number, and that pattern will repeat the whole time, so it can all be one list.
yah could u explain that part that u were gonna explain? everything elese really helps though
Birdlegs
Scratcher
1000+ posts

Tile generator

SEABASS1234 wrote:

JoeyTheChicken wrote:

SEABASS1234 wrote:

JoeyTheChicken wrote:

SEABASS1234 wrote:

level tile generation. That would be great!
-snipses-
yah could u explain that part that u were gonna explain? everything elese really helps though

Yep! Here's what I do. I have something read over the string, putting together a value into a variable until it hits a semicolon (; ), at which point it takes the value it has, ejects it into a list, clears itself with

setareanumtoput absolutely nothing in here

and keeps going the whole length of the string. If you run it slowly, you can actually see the value being built, like

-
-1
-12

and then when it clears, you know it's hit a semicolon, and that it's added what it was just a moment ago to a list. Also, it's important to initialize everything before it starts.

Last edited by Birdlegs (May 5, 2015 14:58:05)

Birdlegs
Scratcher
1000+ posts

Tile generator

And remember to delete all clones before loading. This took me something like a month to debug and perfect.

Powered by DjangoBB