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

#1 2012-11-08 23:27:47

janderson01
Scratcher
Registered: 2010-04-02
Posts: 18

Need help with infinite terrain and mob spawning

I'm working on a minecraft game and i'll need help spawning mobs and infinite terrain
how do i do this?

Offline

 

#2 2012-11-09 08:16:31

Velocities
New Scratcher
Registered: 2012-10-31
Posts: 29

Re: Need help with infinite terrain and mob spawning

You will need lots of lists and stamping/cloning (in 2.0). Your question needs to be more specific though. What scripts do you need help with?

Offline

 

#3 2012-11-09 08:38:59

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

Re: Need help with infinite terrain and mob spawning

Infinite terrain basically requires a list that will get VERY long quite quickly OR a more clever method, the basics of which I'm still organizing in my head.  The most basic way to generate terrain would be a "2D" array, in which you add to either the end or beginning depending on whether you're moving left or right (it's just 2D right?)


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

Offline

 

#4 2012-11-09 09:00:54

Velocities
New Scratcher
Registered: 2012-10-31
Posts: 29

Re: Need help with infinite terrain and mob spawning

MoreGamesNow wrote:

Infinite terrain basically requires a list that will get VERY long quite quickly OR a more clever method, the basics of which I'm still organizing in my head.  The most basic way to generate terrain would be a "2D" array, in which you add to either the end or beginning depending on whether you're moving left or right (it's just 2D right?)

I wonder who would make a 3D one. xD

Offline

 

#5 2012-11-09 09:10:58

janderson01
Scratcher
Registered: 2010-04-02
Posts: 18

Re: Need help with infinite terrain and mob spawning

Just 2D

i need help with spawning mobs

so at random a pig will apear or something

Offline

 

#6 2012-11-09 13:39:14

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

Re: Need help with infinite terrain and mob spawning

I'd personally be more concerned with mob AI.  Spawning mobs should be a matter of picking a random x position and spawning it on the highest block of that x position.

I would personally store your list like this:

x1: (item 1, item 2, item 3, item 4, item 5)
x2: (item 6, item 7, item 8, item 9, item 10)
x3: (item 11, item 12, item 13, item 14, item 15)
x4: (item 16, item 17, item 18, item 19, item 20)
etc.

So that, to add land either to the left or to the right, it is only a matter of inserting at the beginning or adding at the end, rather than inserting items throughout your list.

Then, to see that the x and y position (on the grid, not on the screen) of the pig should be when spawned, choose a random x and, starting at the first item of the list of items, run through it.

Example:

set [spawn_x v] to (3) // random number
set [y v] to (1)
repeat until <(item ((spawn_x*height_of_grid)+(y)) of [grid v]) = ["empty"]>
change [y v] by (1)
end
BTW, I'm assuming you're using a pseudo 2D list.  The wiki article here describes a method similar to what I'm using, but I believe I am flipping the x and y around (hence "x*height" instead of "y*width").

Last edited by MoreGamesNow (2012-11-09 21:26:16)


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

Offline

 

#7 2012-11-09 17:57:52

janderson01
Scratcher
Registered: 2010-04-02
Posts: 18

Re: Need help with infinite terrain and mob spawning

*looks at your reply

What!?

what's the i variable for?

Offline

 

#8 2012-11-09 18:00:03

janderson01
Scratcher
Registered: 2010-04-02
Posts: 18

Re: Need help with infinite terrain and mob spawning

what are items?

i do not understand

Offline

 

#9 2012-11-09 18:05:07

janderson01
Scratcher
Registered: 2010-04-02
Posts: 18

Re: Need help with infinite terrain and mob spawning

i wish there was a way to make a
spawn new sprite block

Last edited by janderson01 (2012-11-09 18:05:30)

Offline

 

#10 2012-11-09 21:27:28

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

Re: Need help with infinite terrain and mob spawning

Sorry, I edited the post, it should make more sense now.  Essentially, anytime you want to spawn a pig, you choose the x position ("spawn_x") and the above script should give you the y position (on the grid, not on the screen).


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

Offline

 

#11 2012-11-13 17:46:08

janderson01
Scratcher
Registered: 2010-04-02
Posts: 18

Re: Need help with infinite terrain and mob spawning

I think scratch won't be able to do what i want
i'll have to use greenfoot which is a java based step up from scratch

Offline

 

#12 2012-11-14 12:19:57

joefarebrother
Scratcher
Registered: 2011-04-08
Posts: 1000+

Re: Need help with infinite terrain and mob spawning

You could make a terrain that loops after you get a certain distance.


My latest project is called http://tinyurl.com/d2m8hne! It has http://tinyurl.com/d395ygk views, http://tinyurl.com/cnasmt7 love-its, and http://tinyurl.com/bwjy8xs comments.
http://tinyurl.com/756anbk   http://tinyurl.com/iplaychess

Offline

 

Board footer