Pages: 1
Topic closed
Most people who have been on scratch for a while know how to make scrollers and random world generators, but most ppl just don't know how to put them together.
I want to make one of these scrolling random generators but idk how to
Can someone tell me how to make one?
Offline
If you want a completely random terrain obtained using maths, you're going to have to make do with a wire scrolling. Basically, a pen line that redraws on every frame following some positioning data from a list, giving the illusion that the terrain is actually one long infinite line.
Otherwise, you can use the simpler "building blocks" method where you have a preset amount of costumes that are displayed by two continuously scrolling sprites, randomly picking between costumes.
Offline
Well, you need several "Generating" Sprites to update whenever you move... and to store the places of the blocks or whatever... Which is rather difficult.
For recovering from the list...
if <(x) > [0]> //wait a minute just testing this... switch to costume (item ((([Max Height + BlockSize] - (y)) / [Block size]) + ((((x) / [Block size]) - [1]) * [Height of world / Block Size])) of [positive x world v]) stamp //height of the world: eg y10 to y-10 = 20 height. else switch to costume (item ([0] - ((([Max Height + BlockSize] - (y)) / [Block size]) + (((x) / [Block size]) * [Height of world / Block Size]))) of [negative x world (and 0) v]) stamp endIt'll need to do this for every block on the screen every time the player moves. (use multiple sprites)
Last edited by Splodgey (2012-04-10 09:19:17)
Offline
Splodgey wrote:
Well, you need several "Generating" Sprites to update whenever you move... and to store the places of the blocks or whatever... Which is rather difficult.
For recovering from the list...if <(x) > [0]> //wait a minute just testing this... switch to costume (item ((([Max Height + 1] - (y)) / [Block size]) + (((x) - [1]) * [Height of world])) of [positive x world v]) stamp //height of the world: eg y10 to y-10 = 20 height. else switch to costume (item ([0] - ((([Max Height + 1] - (y)) / [Block size]) + ((x) * [Height of world]))) of [negative x world (and 0) v]) stamp endIt'll need to do this for every block on the screen every time the player moves. (use multiple sprites)
When generating it'll have to start at x: 1 * block size and y: max height and generate downwards. Each time adding the costume (or "current block") to the list.
Then, when it has generated -> at least 1.5* the length of the screen, it should do the same but negative starting at x: 0. If you see what I mean... If the player is closer to "un-generated" world than 1.5* the length of the screen, it'll need to generate more.
I will try to make an example project in case you don't understand... (also so I can correct myself if I'm wrong)
I think this would work infinitely (no world x limit - but there's a y limit).
I dont get it...
Offline
LOLIPOP1136 wrote:
Splodgey wrote:
Well, you need several "Generating" Sprites to update whenever you move... and to store the places of the blocks or whatever... Which is rather difficult.
For recovering from the list...
ABOVE SCRIPTif <(x) > [0]> //wait a minute just testing this... switch to costume (item ((([Max Height + BlockSize] - (y)) / [Block size]) + ((((x) / [Block size]) - [1]) * [Height of world / Block Size])) of [positive x world v]) stamp //height of the world: eg y10 to y-10 = 20 height. else switch to costume (item ([0] - ((([Max Height + BlockSize] - (y)) / [Block size]) + (((x) / [Block size]) * [Height of world / Block Size]))) of [negative x world (and 0) v]) stamp endIt'll need to do this for every block on the screen every time the player moves. (use multiple sprites)
When generating it'll have to start at x: 1 * block size and y: max height and generate downwards. Each time adding the costume (or "current block") to the list.
Then, when it has generated -> at least 1.5* the length of the screen, it should do the same but negative starting at x: 0. If you see what I mean... If the player is closer to "un-generated" world than 1.5* the length of the screen, it'll need to generate more.
I will try to make an example project in case you don't understand... (also so I can correct myself if I'm wrong)
I think this would work infinitely (no world x limit - but there's a y limit).I dont get it...
No, I didn't think I explained it well.
In this explanation, the size of each block is 16*16, the maximum height is 64 and the minimum height is -64.
There are 2 sections of the world, positive and negative (positive is anything with an x > 0 and negative, <1) It will save the blocks to 2 lists, "positive x world" and "negative x world".
Each item of the lists will have a coordinate that is represents.
Item 1 of the "positive x world" list will have coordinate of (16,64). Item 2, will be 1 block further down (16,48).
Item 3 (16,32)
4 (16,16)
5 (16,0)
6 (16,-16)
7 (16,-32)
8 (16,-48)
9 (16,-64)
Item 10 will not be (16,-80) because the minimum height is -64. Instead, it is (32,64). 1 block to the right of item 1. items 10-18 will be the same as items 1-9 except they will be 1 block to the right.
This will keep going as many times as you like.
The "negative x world" list will be the same, but with the x as a negative (-16, -32 ect.) This list will also include 0 on the x axis.
1 (0,64)
2 (0,48)
.....
10 (-16,64)
11 (-16,48)
etc
The item of the list will be a number. This number is the costume number of the block.
(costume#)So, if the coordinate (16,-16) was grass, and the costume number of grass was 2, then
<(item [6 v] of [positive x world v]) = [2]> //trueSo, when our generator updates because the player has moved, it will need to use the above script on every block on the screen. That will make it switch to the saved costume and place it there.
Last edited by Splodgey (2012-04-10 09:19:50)
Offline
Splodgey wrote:
LOLIPOP1136 wrote:
Splodgey wrote:
Well, you need several "Generating" Sprites to update whenever you move... and to store the places of the blocks or whatever... Which is rather difficult.
For recovering from the list...
ABOVE SCRIPTif <(x) > [0]> //wait a minute just testing this... switch to costume (item ((([Max Height + BlockSize] - (y)) / [Block size]) + ((((x) / [Block size]) - [1]) * [Height of world / Block Size])) of [positive x world v]) stamp //height of the world: eg y10 to y-10 = 20 height. else switch to costume (item ([0] - ((([Max Height + BlockSize] - (y)) / [Block size]) + (((x) / [Block size]) * [Height of world / Block Size]))) of [negative x world (and 0) v]) stamp endIt'll need to do this for every block on the screen every time the player moves. (use multiple sprites)
When generating it'll have to start at x: 1 * block size and y: max height and generate downwards. Each time adding the costume (or "current block") to the list.
Then, when it has generated -> at least 1.5* the length of the screen, it should do the same but negative starting at x: 0. If you see what I mean... If the player is closer to "un-generated" world than 1.5* the length of the screen, it'll need to generate more.
I will try to make an example project in case you don't understand... (also so I can correct myself if I'm wrong)
I think this would work infinitely (no world x limit - but there's a y limit).I dont get it...
No, I didn't think I explained it well.
In this explanation, the size of each block is 16*16, the maximum height is 64 and the minimum height is -64.
There are 2 sections of the world, positive and negative (positive is anything with an x > 0 and negative, <1) It will save the blocks to 2 lists, "positive x world" and "negative x world".
Each item of the lists will have a coordinate that is represents.
Item 1 of the "positive x world" list will have coordinate of (16,64). Item 2, will be 1 block further down (16,48).
Item 3 (16,32)
4 (16,16)
5 (16,0)
6 (16,-16)
7 (16,-32)
8 (16,-48)
9 (16,-64)
Item 10 will not be (16,-80) because the minimum height is -64. Instead, it is (32,64). 1 block to the right of item 1. items 10-18 will be the same as items 1-9 except they will be 1 block to the right.
This will keep going as many times as you like.
The "negative x world" list will be the same, but with the x as a negative (-16, -32 ect.) This list will also include 0 on the x axis.
1 (0,64)
2 (0,48)
.....
10 (-16,64)
11 (-16,48)
etc
The item of the list will be a number. This number is the costume number of the block.(costume#)So, if the coordinate (16,-16) was grass, and the costume number of grass was 2, then<(item [6 v] of [positive x world v]) = [2]> //trueSo, when our generator updates because the player has moved, it will need to use the above script on every block on the screen. That will make it switch to the saved costume and place it there.
Let me know if this isn't enough explanation
Think a project would be a good idea...
Offline
LOLIPOP1136 wrote:
Splodgey wrote:
LOLIPOP1136 wrote:
I dont get it...No, I didn't think I explained it well.
In this explanation, the size of each block is 16*16, the maximum height is 64 and the minimum height is -64.
There are 2 sections of the world, positive and negative (positive is anything with an x > 0 and negative, <1) It will save the blocks to 2 lists, "positive x world" and "negative x world".
Each item of the lists will have a coordinate that is represents.
Item 1 of the "positive x world" list will have coordinate of (16,64). Item 2, will be 1 block further down (16,48).
Item 3 (16,32)
4 (16,16)
5 (16,0)
6 (16,-16)
7 (16,-32)
8 (16,-48)
9 (16,-64)
Item 10 will not be (16,-80) because the minimum height is -64. Instead, it is (32,64). 1 block to the right of item 1. items 10-18 will be the same as items 1-9 except they will be 1 block to the right.
This will keep going as many times as you like.
The "negative x world" list will be the same, but with the x as a negative (-16, -32 ect.) This list will also include 0 on the x axis.
1 (0,64)
2 (0,48)
.....
10 (-16,64)
11 (-16,48)
etc
The item of the list will be a number. This number is the costume number of the block.(costume#)So, if the coordinate (16,-16) was grass, and the costume number of grass was 2, then<(item [6 v] of [positive x world v]) = [2]> //trueSo, when our generator updates because the player has moved, it will need to use the above script on every block on the screen. That will make it switch to the saved costume and place it there.
Let me know if this isn't enough explanationThink a project would be a good idea...
I'll be making a "demo" project...
Offline
Splodgey wrote:
LOLIPOP1136 wrote:
Splodgey wrote:
No, I didn't think I explained it well.
In this explanation, the size of each block is 16*16, the maximum height is 64 and the minimum height is -64.
There are 2 sections of the world, positive and negative (positive is anything with an x > 0 and negative, <1) It will save the blocks to 2 lists, "positive x world" and "negative x world".
Each item of the lists will have a coordinate that is represents.
Item 1 of the "positive x world" list will have coordinate of (16,64). Item 2, will be 1 block further down (16,48).
Item 3 (16,32)
4 (16,16)
5 (16,0)
6 (16,-16)
7 (16,-32)
8 (16,-48)
9 (16,-64)
Item 10 will not be (16,-80) because the minimum height is -64. Instead, it is (32,64). 1 block to the right of item 1. items 10-18 will be the same as items 1-9 except they will be 1 block to the right.
This will keep going as many times as you like.
The "negative x world" list will be the same, but with the x as a negative (-16, -32 ect.) This list will also include 0 on the x axis.
1 (0,64)
2 (0,48)
.....
10 (-16,64)
11 (-16,48)
etc
The item of the list will be a number. This number is the costume number of the block.(costume#)So, if the coordinate (16,-16) was grass, and the costume number of grass was 2, then<(item [6 v] of [positive x world v]) = [2]> //trueSo, when our generator updates because the player has moved, it will need to use the above script on every block on the screen. That will make it switch to the saved costume and place it there.
Let me know if this isn't enough explanationThink a project would be a good idea...
I'll be making a "demo" project...
ty
Offline
LOLIPOP1136 wrote:
Splodgey wrote:
LOLIPOP1136 wrote:
Think a project would be a good idea...
I'll be making a "demo" project...
ty
I think I've got it working, so I'll test it and upload it after tea.
I kinda feel like a genius making this...
Offline
Splodgey wrote:
LOLIPOP1136 wrote:
Splodgey wrote:
No, I didn't think I explained it well.
In this explanation, the size of each block is 16*16, the maximum height is 64 and the minimum height is -64.
There are 2 sections of the world, positive and negative (positive is anything with an x > 0 and negative, <1) It will save the blocks to 2 lists, "positive x world" and "negative x world".
Each item of the lists will have a coordinate that is represents.
Item 1 of the "positive x world" list will have coordinate of (16,64). Item 2, will be 1 block further down (16,48).
Item 3 (16,32)
4 (16,16)
5 (16,0)
6 (16,-16)
7 (16,-32)
8 (16,-48)
9 (16,-64)
Item 10 will not be (16,-80) because the minimum height is -64. Instead, it is (32,64). 1 block to the right of item 1. items 10-18 will be the same as items 1-9 except they will be 1 block to the right.
This will keep going as many times as you like.
The "negative x world" list will be the same, but with the x as a negative (-16, -32 ect.) This list will also include 0 on the x axis.
1 (0,64)
2 (0,48)
.....
10 (-16,64)
11 (-16,48)
etc
The item of the list will be a number. This number is the costume number of the block.(costume#)So, if the coordinate (16,-16) was grass, and the costume number of grass was 2, then<(item [6 v] of [positive x world v]) = [2]> //trueSo, when our generator updates because the player has moved, it will need to use the above script on every block on the screen. That will make it switch to the saved costume and place it there.
Let me know if this isn't enough explanationThink a project would be a good idea...
I'll be making a "demo" project...
Offline
Splodgey wrote:
Well, you need several "Generating" Sprites to update whenever you move... and to store the places of the blocks or whatever... Which is rather difficult.
For recovering from the list...if <(x) > [0]> //wait a minute just testing this... switch to costume (item ((([Max Height + BlockSize] - (y)) / [Block size]) + ((((x) / [Block size]) - [1]) * [Height of world / Block Size])) of [positive x world v]) stamp //height of the world: eg y10 to y-10 = 20 height. else switch to costume (item ([0] - ((([Max Height + BlockSize] - (y)) / [Block size]) + (((x) / [Block size]) * [Height of world / Block Size]))) of [negative x world (and 0) v]) stamp endIt'll need to do this for every block on the screen every time the player moves. (use multiple sprites)
When generating it'll have to start at x: 1 * block size and y: max height and generate downwards. Each time adding the costume (or "current block") to the list.
Then, when it has generated -> at least 1.5* the length of the screen, it should do the same but negative starting at x: 0. If you see what I mean... If the player is closer to "un-generated" world than 1.5* the length of the screen, it'll need to generate more.
I will try to make an example project in case you don't understand... (also so I can correct myself if I'm wrong)
I think this would work infinitely (no world x limit - but there's a y limit).
Scary . . .
Offline
Just add them to lists. I believe there is a project on my test account (cmpm_test) that has infinite slopes.
Offline
Topic closed
Pages: 1