A Flash Developer Resource Site

Results 1 to 9 of 9

Thread: Snake Problems

  1. #1
    Junior Member
    Join Date
    Feb 2007
    Posts
    13

    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.

  2. #2
    World Kit Vote Holder Abelius's Avatar
    Join Date
    Feb 2002
    Location
    US
    Posts
    963
    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.
    Cordially,
    Abelius
    www.worldkit.com

  3. #3
    Junior Member
    Join Date
    Feb 2007
    Posts
    13
    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

  4. #4
    Junior Member
    Join Date
    Feb 2007
    Posts
    13
    yea.. anyone?...

  5. #5
    World Kit Vote Holder Abelius's Avatar
    Join Date
    Feb 2002
    Location
    US
    Posts
    963
    ROFL... still working on it, I have real life coding to do as well
    Cordially,
    Abelius
    www.worldkit.com

  6. #6
    Junior Member
    Join Date
    Feb 2007
    Posts
    13
    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.

  7. #7
    Im still young
    Join Date
    Mar 2006
    Location
    world
    Posts
    38
    You can see a similar snake game at:
    http://www.flashkit.com/movies/Games...1591/index.php

  8. #8
    Junior Member
    Join Date
    Feb 2007
    Posts
    13
    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.

  9. #9
    Junior Member
    Join Date
    Feb 2007
    Posts
    13
    uhm... yea... anyone?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center