A Flash Developer Resource Site

Results 1 to 20 of 24

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

Hybrid View

  1. #1
    *insert clever title* SergeantK's Avatar
    Join Date
    Nov 2004
    Location
    Akron, Ohio
    Posts
    506
    Nothing new, but pretty solid.


  2. #2
    Senior Member
    Join Date
    Aug 2004
    Location
    San Diego, California
    Posts
    421
    You could have an animated car, but then it would be to repetitive. IMO the easier and smarter route to go is a.i. cars.

    How would you go about building an a.i car though? First, think about what the human player thinks about when controlling a top-view car. He is usuall pressing the gas key and making sure he/she doesn't hit the curbs using the right and left keys. So base the a.i. algorithm on that assumption. Enable the a.i. to detect the curbs and thus letting it decide which direction to turn to avoid hitting the curbs.

    Because a.i. calculate distances and math operations very quickly compared to the human brain, they will most likely drive perfectly. So take advantage of the fact that the a.i. is using the pc processor and don't be afraid to give it complex calculations.

  3. #3
    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