Discuss Scratch

veryskinnybug101
Scratcher
18 posts

Random generation that's actually good

I'm making a Minecraft game that I want to have good world gen in. I so far only have this mess https://scratch.mit.edu/projects/253787405/#player . Could someone tell me how to make it better?

Hey
Sinaboo
Scratcher
100+ posts

Random generation that's actually good

The way i'd do world gen stuff for 2D games is something like this: https://scratch.mit.edu/projects/148851492/#player
I've disabled the loading screen so you can see what's going on when the world's generating.
I'll probably work on this sometime later and add lumps and bumps in the terrain that would be random.

There's 1 sprite that's cloning and making all the terrain. There's costumes for each block/texture (Grass, dirt, stone, etc.).

How it's making the terrain is first the sprite switches to the grass texture and goes to the left of the screen then there's a repeat that's cloning the sprite and then moving the x position so that it's just to the right of it.

switch costume to [Grass01 v]
repeat (22)
create clone of [myself v]
change x by (22)
end

Then after the repeat it's creating another clone (If it didn't create a clone after the repeat there would be holes on both sides where the clones are missing).

For the next 4 rows I'm going to be using dirt in this example.
Then the y position is changing by -21 (Moving down).
This time the x is going to be decreasing so the blocks are going to be moving to the left this time instead of the right.

Since I'm going to be making 4 rows of dirt i'm going to use a repeat (2) because the dirt blocks are going to be moving left AND right (If they were only moving left or only going right, they would just end up at the left or right side of the screen and not do anything else).

switch costume to [Dirt01 v]
change y by (-21)
repeat (2)
repeat (22)
create clone of [myself v]
change x by (-21)
end
create clone of [myself v]
change y by (-21)
repeat (22)
create clone of [myself v]
change x by (21)
end
create clone of [myself v]
change y by (-21)
end

For the next layers i'm going to be using dirt and stone to mix it up.
These layers will be very similar to the last ones but i'm going to be using the “pick random (1) to (10)”.
I'm also going to be using a repeat of 2 since I want 4 more layers.
For this example imagine the costume number for dirt is 2 and for stone it's 3.

repeat (2)
repeat (22)
switch costume to (pick random (2) to (3))
create clone of [myself v]
change x by (-21)
end
create clone of [myself v]
change y by (-21)
repeat (22)
switch costume to (pick random (2) to (3))
create clone of [myself v]
change x by (21)
end
create clone of [myself v]
change y by (-21)
end

The rest of the world generation is pretty self-explanatory.
If you still don't understand how to do them on your own, just copy other code blocks but change the costumes to what you want.


For this world generation the only option you have is to break the blocks. For this I did a “When this sprite clicked” with “if costume # = () then”
and then made variables for each block/item you can break and collect.

when this sprite clicked
if <(costume #) = [1]> then
change [Dirt v] by (1)
delete this clone
end

Sorry if this was too confusing.

Last edited by Sinaboo (Oct. 19, 2018 04:59:19)

Sinaboo
Scratcher
100+ posts

Random generation that's actually good

I'll make another world generation project for you that doesn't have as much stuff and junk everywhere
Sinaboo
Scratcher
100+ posts

Random generation that's actually good

Here's the cleaned up one

https://scratch.mit.edu/projects/253892051/

If you've got any questions, just ask
veryskinnybug101
Scratcher
18 posts

Random generation that's actually good

Sinaboo wrote:

Here's the cleaned up one

https://scratch.mit.edu/projects/253892051/

If you've got any questions, just ask
I would really like for there to be hills or bumps but have grass only on the highest blocks. Do you think you could help with that?

Hey
Sinaboo
Scratcher
100+ posts

Random generation that's actually good

veryskinnybug101 wrote:

Sinaboo wrote:

Here's the cleaned up one

https://scratch.mit.edu/projects/253892051/

If you've got any questions, just ask
I would really like for there to be hills or bumps but have grass only on the highest blocks. Do you think you could help with that?
Sure. I'll try to add hills.
Sinaboo
Scratcher
100+ posts

Random generation that's actually good

For now they're only 1 tile taller than regular ground. If you want I could try making them taller.

https://scratch.mit.edu/projects/254086589/
veryskinnybug101
Scratcher
18 posts

Random generation that's actually good

Sinaboo wrote:

For now they're only 1 tile taller than regular ground. If you want I could try making them taller.

https://scratch.mit.edu/projects/254086589/
Thanks! This is perfect!

Hey
Sinaboo
Scratcher
100+ posts

Random generation that's actually good

veryskinnybug101 wrote:

Sinaboo wrote:

For now they're only 1 tile taller than regular ground. If you want I could try making them taller.

https://scratch.mit.edu/projects/254086589/
Thanks! This is perfect!
You're welcome

Powered by DjangoBB