A Flash Developer Resource Site

Results 1 to 20 of 24

Thread: [Game] Krashin' Karts (Our First Game)

Threaded View

  1. #21
    M.D. mr_malee's Avatar
    Join Date
    Dec 2002
    Location
    Shelter
    Posts
    4,139
    ok hopefully i can make up for my comments in your last thread with some helpful feedback.

    Simplest and crapiest solution. Create a set of AI animations, about 6. Let each one be different on each course, that's 18 different possible AI paths. Then all you have to do is play their animations based on a timer. e.g

    var frame += .3
    AI.gotoAndStop(Math.floor(frame))

    Complecated solution. I'm guessing that this is art based, the solution would be much simpler if it were tile based but here goes.

    create invisible boxes on all corner's of your maps, name them corner1, corner2, corner3 etc.

    add this code to your AI.
    code:

    var currentCorner = 1;
    var speed = 5;
    onEnterFrame = function () {
    var cornerClip = "corner"+currentCorner;
    if (this.hitTest(cornerClip)) {
    currentCorner++;
    }
    var ax = cornerClip._x-_x;
    var ay = cornerClip._y-_y;
    var angle = Math.atan2(ay, ax);
    _rotation = angle/(Math.PI/180);
    _x += speed*Math.cos(angle);
    _y += speed*Math.sin(angle);
    };


    It should work, but it might look unrealistic, the AI's always going to look at the next corner perfectly, you could modify this by checking if the angle's greater or less than our current rotation. If so move the rotation based on an increment. If you use this method, you'll have to modify these codes:
    _x += speed*Math.cos(_rotation*(Math.PI/180))
    _y += speed*Math.sin(_rotation*(Math.PI/180))
    Last edited by mr_malee; 10-17-2005 at 05:30 AM.
    lather yourself up with soap - soap arcade

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