A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: random directions

Threaded View

  1. #1
    Junior Member
    Join Date
    Jun 2004
    Posts
    1

    random directions

    i was making a quick thing where you could use the arrow keys to drive a car around in an arena and wanted to add in other cars that moved around randomly which you could crash into.
    i managed to program the player car,

    code:
    onClipEvent (enterFrame) {
    if (Key.isDown(Key.UP)) {
    speed += 2;
    } else {
    if (Key.isDown(Key.DOWN)) {
    speed -= 1;
    } else {
    speed *= .9;
    }
    }
    if (Math.abs(speed)>25) {
    speed *= .6;
    }
    if (Key.isDown(Key.LEFT)) {
    _rotation -= speed;
    }
    if (Key.isDown(Key.RIGHT)) {
    _rotation += speed;
    }
    speed *= .9;
    x = Math.sin(_rotation*(Math.PI/180))*speed;
    y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
    if (!_root.land.hitTest(_x+x, _y+y, true)) {
    _x += x;
    _y += y;
    } else {
    speed *= -.5;
    }
    }



    but i cant program the computer car to move randomly based upon the same physics.
    working with flash 5, please help
    Last edited by RampnRail; 10-15-2004 at 12:57 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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center