Skip to main content
March 12, 2013
Answered

Flash Board Game - If a player's destination space has a player on it already, move one more space.

  • March 12, 2013
  • 1 reply
  • 319 views

I have been struggeling with this for sometime and I am totally stuck. In my flash boardgame I am trying to make players unable to land ontop of each other. The code I am currently using compares the current space of Red Player comparing it to where the other player is. What I need to know, is how do I make it compare Red Player's target space to the other player's current space.

function moveRedPiece():void

{

          trace("Spin Complete");

          for (var i:int = 0; i < numberOfMoves; i++){

                    currentSpaceRed += 1;

                    if (redArray[currentSpaceRed].x == p1.x && redArray[currentSpaceRed].y == p1.y && i == numberOfMoves - 1) {

                                          currentSpaceRed +=1;

                                          trace("RED BUMP");

                    }

                    else {

                                          trace("not landing on blue");

                    }

                    while (currentSpaceRed >= redArray.length) {

                                          currentSpaceRed -= redArray.length;

                    }

                    redtargetX = redArray[currentSpaceRed].x;

                    redtargetY = redArray[currentSpaceRed].y;

                    plasticUpSound.play();

                    var redTween:TweenMax = new TweenMax(p2, 1.5, {x:redtargetX+3,y:redtargetY+4,ease:Expo.easeInOut, onComplete:dropMeRed});

          }

}

This topic has been closed for replies.
Correct answer kglad

each space should have a variable that indicates if it is unoccupied or occupied by red or occupied by the other player.

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
March 12, 2013

each space should have a variable that indicates if it is unoccupied or occupied by red or occupied by the other player.