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

#1 2011-06-08 10:07:36

aznxpwr
New Scratcher
Registered: 2011-06-08
Posts: 1

Coding Snake

I'm trying to code the classic snake game, but I'm having these problems:
1. How do I make the body grow using just one sprite as the body?
2. How do I make the body sprite know to appear behind the head?
3. How do I make the body segments follow the segment ahead's movements?
The snake head, body and pellets in my project are just one pixel pieces, I don't need to make it more complex than that.

Offline

 

#2 2011-06-08 11:42:43

AtomicBawm3
Scratcher
Registered: 2009-06-27
Posts: 1000+

Re: Coding Snake

You'll need lists and stamping.  The list length should remain the same as a variable value.  That variable should change whenever you pick something up, or just with time.  Your stamping script should have this repeated a good number of times (64+)

set # to 0         (don't repeat this line)
if (#<length):             (length should be your variable for the length of the snake)
change # by 1
go to (x: item # of (x) ) (y: item # of (y) )        (x and y are two lists that store every body segment)
stamp
end if

If that isn't quite as helpful as you wanted, I'll make a sample project.

Last edited by AtomicBawm3 (2011-06-08 11:43:00)


http://i50.tinypic.com/j0yw0p.jpg

Offline

 

Board footer