mardi 17 janvier 2017

Do I have to write all the possibilities?

I made a memory game

Fishes (it's buttons ) display on the screen and stop,then other fishes ( a wrong fishes ) display on the stage.After a while stops all the scene and player make guess ( click ) right fishes.

For example if player clicked 2 false and 1 true button,or 2 true and 1 false, this results in a loss for the player.And if clicked true 3 fis then this results in a win for the player.

But problem is I have to write code for all possibilities.How can I do as simple.

var clicked1:Boolean = false;
var clicked2:Boolean = false;
var clicked3:Boolean = false;
var clicked4:Boolean = false;
var clicked5:Boolean = false;
var clicked6:Boolean = false;
 
 
btn1.addEventListener(MouseEvent.CLICK, fish1);
function fish1(event:MouseEvent):void
{

    clicked1 = true;
    checkButtonsone()
    }
 
btn2.addEventListener(MouseEvent.CLICK, redButton1a);
function redButton1a(event:MouseEvent):void
{

    clicked2 = true;
    checkButtonsone()
    }
 
btn3.addEventListener(MouseEvent.CLICK, redButton12);
function redButton12(event:MouseEvent):void
{

    clicked3 = true;
    checkButtonsone()
    }
 
btn4.addEventListener(MouseEvent.CLICK, redButton22);
function redButton22(event:MouseEvent):void
{

    clicked4 = true;
    checkButtonsone()
    }
 
btn5.addEventListener(MouseEvent.CLICK, redButton32);
function redButton32(event:MouseEvent):void
{

    clicked5 = true;
    checkButtonsone()
    }
 
btn6.addEventListener(MouseEvent.CLICK, redButton42);
function redButton42(event:MouseEvent):void
{

    clicked6 = true;
    checkButtonsone()
    }
 
//Check true and false

function checkButtonsone():void
var correctcombine = false;
var falsecombine1 = false;
 
{
if(clicked1 && clicked2 && clicked3 )
    {
    correctcombine = true;
    }
 
    {
    if(falsetiklandi && falsetiklandi && falsetiklandi){
       falsecombine1 = true;
    }
 
///Go to true or false
 
if(correctcombine == true)
 
            {
            gotoAndStop(3)
        }   

        if(falsecombine1 == true)
        {
            gotoAndStop(2)
        }
}
}
}



 

Aucun commentaire:

Enregistrer un commentaire