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

#1 2011-03-13 11:53:43

WeirdF
Scratcher
Registered: 2009-05-31
Posts: 1000+

Extreme Snake

I recently made a game and uploaded it (here it is). It's called Extreme Snake (but doesn't have much to do with Snake, just see the project notes for details).

Anyway, I have a couple of problems...

Problem 1: Music
I can't find any music that actually fits the game. I know loads of people use rave-like dance music from Newgrounds, but that's not what I want. I want music that actually fits the game, so if you could help that would be excellent (it can be from Newgrounds, but not the music I described)...  smile

Problem 2: Losing lives if you hit yourself
I want to make it so that snake loses a life if it hits its own trail. But the problem is that it's always touching its trail because it uses a stamping mechanism, so I can't just do this:

Code:

if <touching color []>
change [lives] by [-1]

So what do I do?

Any help is appreciated...  smile


http://i.cr3ation.co.uk/dl/s1/gif/847032b8a331def77529b6a0384db1fe_handfingers.gif

Offline

 

#2 2011-03-13 12:20:11

Harakou
Community Moderator
Registered: 2009-10-11
Posts: 1000+

Re: Extreme Snake

I've made some attempts at snake games before, and I've run into similar problems. I assume you're using lists for the snake's position. I've found that if you store both the x and y positions in one list item, you can keep the position of the snakes "head" in a separate variable and use a script like this:

Code:

if list [snake_positions] contains [head_position]
    broadcast [dedz]
EndIf

http://www.blocks.scratchr.org/API.php?action=random&amp;return=image&amp;link1=http://i.imgur.com/OZn2RD3.png&amp;link2=http://i.imgur.com/duzaGTB.png&amp;link3=http://i.imgur.com/CrDGvvZ.png&amp;link4=http://i.imgur.com/POEpQyZ.png&amp;link5=http://i.imgur.com/ZKJF8ac.png

Offline

 

#3 2011-03-13 12:32:08

Kileymeister
Scratcher
Registered: 2008-04-17
Posts: 1000+

Re: Extreme Snake

Code:

move forward (length of head) steps
if <touching color []>
change [lives] by [-1]
move forward (negative length of head) steps

Now the head is one space ahead of where it should be stamping.  It will now only render your collision as true if you're heading into your trail.  Then it goes back to where it was.

For better results (and to ensure no glitches), maybe make it 1 pixel faster than the length of the head.

Last edited by Kileymeister (2011-03-13 12:33:00)


I'm back, and showcasing two new* projects!  Click left or right on the image below to see!
http://img109.imageshack.us/img109/7905/part1l.pnghttp://img859.imageshack.us/img859/6417/part2bf.png

Offline

 

#4 2011-03-13 14:10:26

LS97
Scratcher
Registered: 2009-06-14
Posts: 1000+

Re: Extreme Snake

What kileymeister suggested should work, but it's very laggy and unprofessional.
I would add a second sprite which is always slightly ahead of the snake, and senses the color there instead.

Offline

 

Board footer