A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [F8] Can't find good random motion tutorial ANYWHERE!

  1. #1
    purple lizard
    Join Date
    Jan 2007
    Location
    somewhere in the world
    Posts
    85

    [F8] Can't find good random motion tutorial ANYWHERE!

    Please can someone help? I've looked everywhere for a good random motion tutorial, and i've found quite a few! But none of them get the object to face in the direction it is moving. I am currently making a cool game called Pligas. It's going to be a bit like the microlife game, and that's exactly the sort of random motion I want. Please?

  2. #2
    14yr old Member shavingcream's Avatar
    Join Date
    Jun 2007
    Location
    Santa Cruz CA
    Posts
    272
    please download the attached .fla
    Attached Files Attached Files

  3. #3
    14yr old Member shavingcream's Avatar
    Join Date
    Jun 2007
    Location
    Santa Cruz CA
    Posts
    272
    do your characters already randomly move like in micro life? if they do can you please tell me how to do that?
    ps: thats not a lizard its a pokemon

  4. #4
    purple lizard
    Join Date
    Jan 2007
    Location
    somewhere in the world
    Posts
    85
    Thanks, that kind of helps... but if we could mix that with a random motion script like this:
    Code:
    onClipEvent (load) { 
    //data you may want to change 
    width = 550; 
    height = 400; 
    speed = Math.round(Math.random()*2)+1; 
    //initial positions 
    x = this._x=Math.random()*width; 
    y = this._y=Math.random()*height; 
    x_new = Math.random()*width; 
    y_new = Math.random()*height; 
    } 
    onClipEvent (enterFrame) { 
    //x movement 
    if (x_new>this._x) { 
    sign_x = 1; 
    } else { 
    sign_x = -1; 
    } 
    dx = Math.abs(x_new-this._x); 
    if ((dx>speed) || (dx<-speed)) { 
    this._x += sign_x*speed; 
    } else { 
    x_new = Math.random()*width; 
    } 
    //y movement 
    if (y_new>this._y) { 
    sign_y = 1; 
    } else { 
    sign_y = -1; 
    } 
    dy = Math.abs(y_new-this._y); 
    if ((dy>speed) || (dy<-speed)) { 
    this._y += sign_y*speed; 
    } else { 
    y_new = Math.random()*height; 
    } 
    }
    It would be PERFECT!
    The thing is, I'm only 11 years old, so I'm not the best scripter, but we could TRY to get it working.

    Also, I know that thing is a pokemon, but, it's like a lizard pokemon lizardy thingy. I'm mad about lizard's, I even have a pet one!

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