Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Tile generator
- SEABASS1234
-
34 posts
Tile generator
Hi there! I was wondering how tile generation works. I think it would really help my game along. Thanks!
- Birdlegs
-
1000+ posts
Tile generator
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 level tile generation. That would be great!
- SEABASS1234
-
34 posts
Tile generator
thanks!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 level tile generation. That would be great!
can u explain it to me?
- Birdlegs
-
1000+ posts
Tile generator
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 tothanks!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 level tile generation. That would be great!
can u explain it to me?
Then, I press space. When I do, it stamps the tile, and it saves its x, y, and costume to a list. So…
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
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.
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
-
34 posts
Tile generator
yah could u explain that part that u were gonna explain? everything elese really helps thoughWell, 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 tothanks!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 level tile generation. That would be great!
can u explain it to me?
Then, I press space. When I do, it stamps the tile, and it saves its x, y, and costume to a list. So…
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
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.
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.

- Birdlegs
-
1000+ posts
Tile generator
-snipses- level tile generation. That would be great!
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
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
-
1000+ posts
Tile generator
And remember to delete all clones before loading. This took me something like a month to debug and perfect.
- Discussion Forums
- » Help with Scripts
-
» Tile generator