-
Snake Problems
I started making a script for a snake-ish game, but I cant make it so that you get a "tail" after you eat the food things, also I can't make it so that it continues going in the last given direction after you let go of the arrow button, I tried Key.isToggled instead of Key.isDown, but that messed up the directions which the snake was going in somehow.
(Yes, it's got no point system etc. so far, but i'll add that on later)
Edit: Nvm, i found out what istoggled is and its useles...
stop()
// Stops Animation
'Snake movement'
speed = 5
// Speed... obviously
function onEnterFrame(){
//When it gets to this frame then...
if (Key.isDown(KEY.UP)){
_root.snake._y -= speed
//Press up then move snake up
}
//ends if
if (Key.isDown(KEY.DOWN)){
snake._y += speed
// Press down to make snake move down
}
//ends if
if (Key.isDown(KEY.LEFT)){
snake._x -= speed
// Press left to make snake move left
}
//ends if
if (Key.isDown(KEY.RIGHT)){
snake._x += speed
}
//Press right to make snake go right
if (_root.snake.hitTest(_root.food._x, _root.food._y, true)){
_root.food._x = Math.floor(Math.random() * 550);
_root.food._y = Math.floor(Math.random() * 400);
}}
Last edited by Xeugor; 02-02-2007 at 07:43 PM.
-
World Kit Vote Holder
I gonna try to make a snippet of code and let you know...
It might not look much like ehat you are doing tho, but I'll try to have the snake bend on corners when direction is changed, keeping it is simple as possible.
-
Yea, it's my first time making an actual game with actionscript in flash, I've made animations before, and I've done stuff on Visual Basic, but first game on flash, so the coding probably sucks T_T
-
-
World Kit Vote Holder
ROFL... still working on it, I have real life coding to do as well
-
well, I added more to it, basically points & death http://www.esnips.com/doc/d3be35e3-6...2e935413/Snake
Edit: one question, how do you detect the last key pressed instead of the key being pressed down?
Last edited by Xeugor; 02-02-2007 at 06:34 PM.
-
-
Ok, nevermind, I'm almost done, now the only thing i need is a tail which i have no idea how to do, anyone wanna teach me?
You can get the fla here http://www.esnips.com/doc/3684ea95-9...1e4faf/SnakeFK
doubt anyone would steal my crappy coding, but please dont neway =]
The numbers on the screen are just co-ordinates of food and snake for my own sake while i was trying to fix the collision detection.
Last edited by Xeugor; 02-03-2007 at 07:33 PM.
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|