A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: no, not yet...wait...wait...wait...ok now but only if you fast tnough

Threaded View

  1. #8
    Junior Member
    Join Date
    Sep 2004
    Posts
    23
    Here use this:

    code:

    speedFile = "15|10|20";
    heroSpeeds = speedFile.split("|");
    i = 0;
    fps = 12;
    counter = 2*fps;
    attacking = false;

    function selectAttack() {
    _root["hero"+i].attack = chosenAttack;
    if(_root["hero"+i].attack) {
    i++;
    }
    //^ Waits to give every "hero" an attack ;

    for(j=0; j<i; j++) {
    if(j == i-1) {
    if(_root["hero"+j].attack) {
    startBattle();
    }
    }
    }
    //^ If all heros have an attack, start battle ;
    }


    function startBattle() {
    counter -= 1;
    m = heroSpeeds.length-1;
    if(counter <= 0) {
    heroTurn = heroSpeeds.sortOn();
    //^ Originally posted by slight
    for(k=0; k<i; k++) {
    _root["hero"+k+"speed"] = heroSpeeds[k];
    if(_root["hero"+k+"speed"] == heroTurn[m]) {
    turnAttack = true;
    }
    }
    if(turnAttack && !attacking) {
    heroAttack(_root["hero"+k]);
    attacking = true;
    m--;
    }
    counter = 2*fps;
    }
    //^ This is the meat of the engine. It checks if its
    // the "hero"'s turn to attack and then it does so.
    // If the hero is "attacking" then it does not continue.
    }


    function heroAttack(hero) {
    if(hero.attack == "spear") {
    // Blah Blah make the hero do something to attack ;
    }
    if(hero.attack == "sword") {
    // Blah Blah make the hero do something to attack ;
    }
    attacking = false;
    }

    this.onEnterFrame = function() {
    selectAttack();
    }



    and thats basicly it....

    EDIT: fixed some bugs and now I'm almost postive it works.
    Last edited by PromiNom; 09-25-2004 at 04:21 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