This is a read-only archive of the old Scratch 1.x Forums.
Try searching the current Scratch discussion forums.

#1 2012-04-03 20:41:07

coolhogs
Scratcher
Registered: 2011-07-26
Posts: 1000+

World Generator

Hi Scratchers,
I am trying to make a world generator.
Here are some facts:
What type?: Planetary (Completely 360 World Generator), 2D
ow many types of ore? 5: Diamond, Gold, Granite, Rock, and Soil
Should some be rarer than others?  How much rarer?: It's in order from rare to  most common
Should the rarer ores be more common as you go deeper? Yes they should.


Get ready for domination of:  tongue

Offline

 

#2 2012-04-03 20:59:36

MoreGamesNow
Scratcher
Registered: 2009-10-12
Posts: 1000+

Re: World Generator

This looks amazingly similar to another thread I've seen today.  Anyway, something like this will store it in an array:

delete [all v] of [grid v]
set [i] to (0)
repeat ((width) * (height))
change [i v] by (1)
set [depth v] to (round((i/width)-[0.5]))
set [# v] to (pick random (1) to ((depth)*(100)))
if<(#) < [40]> // play around with these numbers for rarity.
add [dirt] to [grid v]
else
if<(#) < [170]>
add [stone] to [grid v]
else
if<(#) < [200]>
add [granite] to [grid v]
end
end
end
Just keep adding more if statements in order of least rare to most rare.  You'll get a grid that is basically 2 dimensional.  To access an item on the grid, use this:

(item (((y)*(width))+(x)) of [grid v])
item zero has the coordinates (1,0) (remember, "y" begins at zero, and "x" begins at one)

Last edited by MoreGamesNow (2012-04-03 21:01:13)


http://images2.layoutsparks.com/1/218929/rubiks-cube-animated-rotating.gif
"Cogito ergo sum" --  I think, therefore I am

Offline

 

Board footer