Snake game

Yeah, I’ve been trying to make a snake game. You know snake as in the Nokia game, right? Well, so I’ve got this little dot movin by my keymoves across the screen, and smaller dots are randomized across the screen. When the two dots collide, 1+ points and a new randomized dot position. Now, i want the snake to grow one module when a dot is “eaten”. I have used

clone++
duplicateMovieClip("_root.snake", “slave” add clone, clone);

To create clone-modules named slave1, 2, 3 etc etc. Now, these only appears where they were created, how can i make them follow the master module in a line, as in the real game?

Now I’m no masta flasha, and I dont know the action script, but you know the _x and _y stuff? I think it would involve that, but I dont know.

Lol, thatz a conclution i reached myself man, but thanks anyway =D

Im quite a newbie to flash myself actually, and somewhy i thought a snake game would be easy

i think if you add this it should work, but i haven’t tried it and am not a masta flasher. it could hurt to try tho right? anywho, add this to the actions of the dot your cloning
<hr>
onClipEvent(load) {
num = _root.clone;
}

onClipEvent(enterFrame) {
if (this._name != “snake” || this._name != “slave1”) {
this._x = _root[“slave” + (num-1)]._x;
this._y = _root[“slave” + (num-1)]._y;
} else if (this._name == “slave1”) {
this._x = _root.snake._x;
this._y = _root.snake._y;
}
}
<hr>

that should do it. lemme know if you need some explaining or if it doesn’t work and i’ll see what i can do.

Thx for that. I can understand the thinking behind what you have written. There’s just one other thing that came to me, though, if
this._x = _root.snake._x;
and so on, wouldn’t that make the position of Slave1 the EXACT position of the original snake? I might be wrong, though, just a thought. I’m currently accessing this site from my school, however, so I havn’t tried it out yet, but I’ll give it a try. Thanx man!

oh omg! i screwed up this is what i meant:
<hr>
onClipEvent(load) {
num = _root.clone;
}

onClipEvent(enterFrame) {
if (this._name != “snake” || this._name != “slave1”) {
this._x = _root[“slave” + (num-1)]._x-20;
this._y = _root[“slave” + (num-1)]._y-20;
} else if (this._name == “slave1”) {
this._x = _root.snake._x-20;
this._y = _root.snake._y-20;
}
}
<hr>

mess with the value 20 to get the right effect

But then, wont Slave1._x&_y always be snake._x&_y-20 and so on with Slave2 relative to Slave1 etc etc etc?

Then my snake will be leaning like a slashsign all the time nomatter what direction, right?

Cuz you know whent the snake moves to the right, for example, i want the Slave1 coordinates to be x: snake._x-20 y: snake._y
And so on, you follow? Then, a way to solve it could be:

on (keyPress “<Right>”) {
_root.move = “right”;
}

and

if (_root.move == “right”) {
coordinate conditions
}

Then i could set it to different coordinates on different directions, but we’d still have a problem: if I’m situated right next to the left border and press the right button all the slaves would be placed in a straight line directly, they wouldnt move there one by one

hmm…

good question. like i said i haven’t gotten to really try anything like so…

have you tried it out? if so then post the .fla

if you have then i think the best solution would be to mess around with the whole “_root.move = ‘right’” and such. i really can’t figure an easy way out of this one. so just try different things and see what happens. if you get stuck post again and i’ll see what i can do.

gl!