A Flash Developer Resource Site

Page 2 of 2 FirstFirst 12
Results 21 to 24 of 24

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

  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

  2. #22
    An FKer
    Join Date
    Sep 2005
    Location
    Ontario
    Posts
    1,167
    Hey thanks alot mr malee - dont worry about the other thread, its over anyways

    I appreciate the suggestions, but as I am horrible at anything closely or directly related to math , the second suggestion doesnt appeal to me (though its most likely the best of the two)

    On the other hand, the first seems easy enough for two new flash users to accomplish so I believe we're going to attempt that one instead

    Thanks alot for the help

  3. #23
    Senior Member Gloo pot's Avatar
    Join Date
    Aug 2005
    Location
    Australia Mate!
    Posts
    874
    nice game... how long that take ya?
    92.7 Fresh FM for all your South Aussies - Doof Doof music FTW people!

  4. #24
    An FKer
    Join Date
    Sep 2005
    Location
    Ontario
    Posts
    1,167
    Gloo Pot
    We made an older version of the game and thats the one that took us a while since we had to learn and find help to make hit test and such

    But this 'new' version of the game required the same code so it was just a matter of making better graphics (which we did)

    The original took about 3 weeks since it was also a side project and since we had no clue what we were doing before we got help and this one took just a few days

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