Tuesday, May 14, 2013

Use Pseudocode And Commented Code

My game in pseudocode...

Match all of the cards to advance to the maze. Get to the end of the maze while avoiding the enemies. Repeat the matching of the cards then the maze. You have won the game.

stop();
//tells frame to stop
var score = 0;
//the fake score
onEnterFrame = function(){
    if ( (MatchE.hitTest(MatchA) && Match2.hitTest(Match4) && MatchC.hitTest(Match6) && Match3.hitTest(MatchB) && Match5.hitTest(MatchD) && MatchF.hitTest(Match1) ) ){
    gotoAndStop(2);
    }
//our matches
    if (MatchE.hitTest(MatchA)){
        MatchE.gotoAndStop(11);
    }
    if (Match2.hitTest(Match4)){
        Match2.gotoAndStop(11);
    }
    if (MatchC.hitTest(Match6)){
        MatchC.gotoAndStop(11);
    }
    if (Match3.hitTest(MatchB)){
        Match3.gotoAndStop(11);
    }
    if (Match5.hitTest(MatchD)){
        Match5.gotoAndStop(11);
    }
    if (MatchF.hitTest(Match1)){
        MatchF.gotoAndStop(11);
    }
//if it hits then it is a pair
        if(score == 6){
            gotoAndStop(11)
//if you won then go here
        }
}

MatchE.onPress = function(){
startDrag(this);
}
MatchE.onRelease = MatchE.onReleaseOutside = function(){
this.stopDrag();
score = score + 1;
}

Match2.onPress = function(){
startDrag(this);
}
Match2.onRelease = Match2.onReleaseOutside = function(){
this.stopDrag();
score = score + 1;
}

MatchC.onPress = function(){
startDrag(this);
}
MatchC.onRelease = MatchC.onReleaseOutside = function(){
this.stopDrag();
score = score + 1;
}

Match3.onPress = function(){
startDrag(this);
}
Match3.onRelease = Match3.onReleaseOutside = function(){
this.stopDrag();
score = score + 1;
}

Match5.onPress = function(){
startDrag(this);
}
Match5.onRelease = Match5.onReleaseOutside = function(){
this.stopDrag();
score = score + 1;
}

MatchF.onPress = function(){
startDrag(this);
}
MatchF.onRelease = MatchF.onReleaseOutside = function(){
this.stopDrag();
score = score + 1;
}
//actual score

stop();
var score = 0;
onEnterFrame = function() {
   
     if(hero.hitTest(enemy1)){
         gotoAndPlay(7);
     }
     if(hero.hitTest(enemy2)){
         gotoAndPlay(7);
     }
     if(hero.hitTest(enemy3)){
         gotoAndPlay(7);
     }
     if(hero.hitTest(enemy4)){
         gotoAndPlay(7);
     }
     if(hero.hitTest(enemy5)){
         gotoAndPlay(7);
     }
     if(hero.hitTest(home)){
         gotoAndPlay(8);
       
     }
     if(hero.hitTest(coin)) {
        score = score + 1; 
       scoreDisplay.text = score;
       unloadMovie(coin);
     }
      if(hero.hitTest(coin2)) {
        score = score + 1; 
       scoreDisplay.text = score;
       unloadMovie(coin2);
     }
       if(hero.hitTest(coin3)) {
        score = score + 1; 
       scoreDisplay.text = score;
       unloadMovie(coin3);
     }
       if(hero.hitTest(coin4)) {
        score = score + 1; 
       scoreDisplay.text = score;
       unloadMovie(coin4);
     }
      if(hero.hitTest(coin5)) {
        score = score + 1; 
       scoreDisplay.text = score;
       unloadMovie(coin5);
     }
           if(hero.hitTest(coin6)) {
        score = score + 1; 
       scoreDisplay.text = score;
       unloadMovie(coin6);
     }
            if(hero.hitTest(coin7)) {
        score = score + 1; 
       scoreDisplay.text = score;
       unloadMovie(coin7);
     }
//if it hits the coin you get points and a solider is game over

   
}

1 comment: