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

#1 2007-05-16 18:34:56

ronalddezino
Scratcher
Registered: 2007-05-16
Posts: 4

How to make a game like Snake

Hello,
I have recently downloaded Scratch and am familiar with its interface.
I wanted to know how to make a game like Snake.

I want the cat to move around with controls from the keyboard.
I want there to be a little kitty bowl somewhere on the screen.
When the cat touches the kitty bowl, the score goes up by 1.
The kitty bowl then moves to another place. (just like Snake)

How would I do this?

Offline

 

#2 2007-05-16 19:13:44

gamerfreak
Scratcher
Registered: 2007-05-15
Posts: 7

Re: How to make a game like Snake

Each time the player collides with the bowl, generate a random x and y value for it, and increment the score by 1.

Offline

 

#3 2007-05-16 20:13:25

ronalddezino
Scratcher
Registered: 2007-05-16
Posts: 4

Re: How to make a game like Snake

How do I generate a random x and y value?

Offline

 

#4 2007-05-16 20:18:42

ronalddezino
Scratcher
Registered: 2007-05-16
Posts: 4

Re: How to make a game like Snake

Oh and also,
if anyone knows how?
Say there is a dog going back and forth on the screen (i know how to do that)
I want to have it so if the cat hits the dog, the lives decrease by one, but after
you lose a life, you become sorta transparent which prevents you from losing like 60 lives in one shot if the dog is on top of you... thanks so much!!! and thank you gamerfreak for your earlier help!!  smile

Offline

 

#5 2007-05-16 21:02:50

paulmedwal
Scratcher
Registered: 2007-03-09
Posts: 100+

Re: How to make a game like Snake

To make an object go to a random spot on the screen, use a move to block with random numbers inside.
http://paulmedwal.com/randomxy2.png

For the second problem, I would make a variable called transparent, and let it be 0 when the cat is not transparent and let it be 1 when the cat is not transparent. For the cat to lose a life, you check to make sure that the cat is not transparent (using an if block).

Have fun making Snake.

Paulmedwal


clutter.scratch.mit.edu Visit the Clutter site to create multi-scene stories and multi-level games with Scratch.

Offline

 

#6 2007-05-16 23:02:01

Shrimpster
Scratcher
Registered: 2007-05-16
Posts: 3

Re: How to make a game like Snake

I just tried making snake and I ran into a bit of a problem.

Usually when I make snake, I use an array to keep an array or list to keep track of the snakes previous x,y coordinates so the game knows which points to clean up on the snake's tail.

Scratch doesn't support data structures, so is there another way to do this?

Offline

 

#7 2007-05-17 07:07:57

Dthen
Scratcher
Registered: 2007-05-16
Posts: 26

Re: How to make a game like Snake

hmm, Read your idea, and deicded to make something along the lines... Is this anything like what you were thinking of? By that way, I'm only trying to find ideas so i can practise my skills so i can get better  smile


http://scratch.mit.edu/projects/Dthen/3801

Offline

 

#8 2007-05-17 09:29:16

paulmedwal
Scratcher
Registered: 2007-03-09
Posts: 100+

Re: How to make a game like Snake

I made a snake game for scratch a while ago (in December I think)...I'll see if I can find it on my computer. Basically, I had each of the elements of the tail to have its own variable (x,y coordinates). Then when the bug moved, each part of the tail took the place of the one before it by just changing all of the variables. Unfortunately, this severally limited the total length of the tail before scratch got extremely slow (I could only have 3 mini circles as the tail). I had obstacles randomly pop up on the screen after you got a "happy face", so the game became interesting by avoiding the obstacles and not going backwards (because of your tail), but the length of the tail did not play much of a role.

Paulmedwal


clutter.scratch.mit.edu Visit the Clutter site to create multi-scene stories and multi-level games with Scratch.

Offline

 

#9 2008-03-13 16:47:03

joyjoy67576
Scratcher
Registered: 2008-03-13
Posts: 1

Re: How to make a game like Snake

I want to know how in genral make a game were enemys try to get you and you have to get to a camera and every time you get to the camera you go to another level. and you get 5 lives.

Offline

 

#10 2008-06-16 12:23:51

stevii
Scratcher
Registered: 2008-01-19
Posts: 10

Re: How to make a game like Snake

ronalddezino wrote:

How do I generate a random x and y value?

<when green flag clicked><go to x sad  <pick random( 100 )to( -100 )y sad  <pick random( 100 )to( -100

Offline

 

#11 2008-06-18 18:34:55

leapord
Scratcher
Registered: 2008-06-18
Posts: 1

Re: How to make a game like Snake

this website rocks. who made this up?

Offline

 

#12 2008-07-21 07:48:49

mbm
Scratcher
Registered: 2008-07-21
Posts: 1

Re: How to make a game like Snake

i dont know how to make games in general
can someone help me ?

Offline

 

#13 2008-11-21 15:30:36

nikolas555
Scratcher
Registered: 2008-08-23
Posts: 5

Re: How to make a game like Snake

<when[  ]key pressed>  for cat = <when[ up ]key pressed>
                  <change y by(1)>

                 <when[ down ]key pressed>
                  <change y by( 1)>

<when green flag clicked>
<forever><wait until><touching[sprite]>
<broadcast[ something ]>

for cheese puffs = <when I receive[ somthing ]>
                                <go to x sad <pick random(  )to(  )y sad  <pick random(  )to( )>

Offline

 

#14 2008-12-06 21:59:16

miniminer205
Scratcher
Registered: 2008-12-06
Posts: 1

Re: How to make a game like Snake

i would really like to learn how to make a game out of scratch and i <clear>ly dont know

Offline

 

#15 2008-12-07 11:23:51

yambanshee
Scratcher
Registered: 2007-11-06
Posts: 500+

Re: How to make a game like Snake

nikolas555 wrote:

<when[  ]key pressed>  for cat = <when[ up ]key pressed>
                  <change y by(1)>

                 <when[ down ]key pressed>
                  <change y by( 1)>

anoying mistake there. The <when[ up ]key pressed> block is the worst block to use for games. Let me try explain. This type of block is more used for typing styled things. for example as im typing now, if i hold down a key, lets say S, it pritns the letter S and then pauses for a second before printing loads of S's. The same works if you use that block, it has a pause. for games you want something like this: [blocks]
<when green flag clicked>
<forever>
   <if><key[ Up ]pressed?>
   <end>
<end>

As for your problem for snakes (on the food bowl):
<when green flag clicked>
<forever>
  <if><touching[ snake ]>
    <change{ score }by( 1 )>
    <set x to( <pick random( -240 )to( 240 ) )>
    <set y to( <pick random( -140 )to( 140 ) )>
  <end>
<end>
[/blocks]

If you want invisability when the dog touches the cat (asked by someone else) simply when you touch the dog change the variable and then <wait until><<  <not> <touching[ dog ]  >>

Last edited by yambanshee (2008-12-07 11:27:00)

Offline

 

#16 2009-10-02 04:40:12

snaker
Scratcher
Registered: 2009-10-02
Posts: 1

Re: How to make a game like Snake

Hi,

I wanted to ask how to I make this snake game with speech commands? (up, down, left, right). How do I make the change the controls from keyboard to something else?

I am new to all this - some pointers please. .

Offline

 

#17 2009-10-03 02:31:36

urhungry
Scratcher
Registered: 2009-07-03
Posts: 1000+

Re: How to make a game like Snake

Try this http://scratch.mit.edu/projects/urhungry/593373 downoad for scripts

Offline

 

#18 2009-10-03 20:26:07

urhungry
Scratcher
Registered: 2009-07-03
Posts: 1000+

Re: How to make a game like Snake

Wait speech? Never mind

Offline

 

#19 2009-10-04 05:29:53

dogly
Scratcher
Registered: 2009-10-04
Posts: 1

Re: How to make a game like Snake

how do i make the snakes tail individually move?

Offline

 

#20 2009-10-04 12:17:42

Irratator
Scratcher
Registered: 2009-10-02
Posts: 1

Re: How to make a game like Snake

http://scratch.mit.edu/forums/viewtopic.php?pid=235090#req_messagehttp://scratch.mit.edu/fo<change{  }by( <change{  }by( <change{  }by( http://scratch.mit.edu/forums/viewtopic.php?pid=235090#req_messagerums/viewtopic.php?pid=235090#req_message

Offline

 

#21 2010-03-10 04:56:56

papadam
Scratcher
Registered: 2010-03-09
Posts: 1

Re: How to make a game like Snake

how do you aoutomatically make a game pause at the beginning of each elvel for one second so that the user has an idea of where the spsrite is before taking control of the sprite itself? Could someone help me please?

Offline

 

Board footer