A Flash Developer Resource Site

Page 1 of 2 12 LastLast
Results 1 to 20 of 34

Thread: solitaire game need help

  1. #1
    Senior Member
    Join Date
    May 2016
    Posts
    276

    solitaire game need help

    hello all
    this is swishmax solitaire game



    i need help

    1- At the beginning of the game, disable the drag and drop feature for all items

    2-When the word appears, it is allowed to drag and drop only

    3-Add a 20-second counter( timer -- ) for each word

    4- When the counter becomes 0, the drag and drop of this item is disabled
    and then it moves to the red player and so on

    thanks for help

    swishmax file:

    https://app.box.com/s/6y1269ithehqga8wbdxsw0gjpe13jtud

  2. #2
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,247
    Inside of solitaire_play where it says onselfevent:

    PHP Code:
    onSelfEvent (load) {

    for(var 
    i=1;i<11;i++){                                      //put this for loop to disable dragging.
     
    _root.solitaire.solitaire_play["black"+i].enabled=false
     _root
    .solitaire.solitaire_play["red"+i].enabled=false
    }


    here is the solution for question 1:
    download 0.2

  3. #3
    Senior Member
    Join Date
    May 2016
    Posts
    276
    I'm sure you have the solutions,
    thank you my friend

  4. #4
    Senior Member
    Join Date
    May 2016
    Posts
    276
    there is an error in solitaire_play line 25

    PHP Code:
    red_Mask[6] = ["red","675","321.45"]; 
    the correct is

    PHP Code:
    red_Mask[6] = ["red6","675","321.45"]; 

  5. #5
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,247
    Ok now words can appear + draggable, In the solitaire_play script for "function pick()" when the tick gets to 40 you can modify the text field _root.solitaire.solitaire_play.data_field

    PHP Code:
    function pick () {

    //etc..


    for(var i=1;i<11;i++){                                      //set to true again
     
    _root.solitaire.solitaire_play["black"+i].enabled=true
     _root
    .solitaire.solitaire_play["red"+i].enabled=true
    }
    _root.solitaire.solitaire_play.data_field.text="Card " +String(i)

    download 0.3
    Last edited by AS3.0; 03-22-2022 at 06:27 AM.

  6. #6
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,247
    Here is a fix for the full script that has pick()
    PHP Code:
    onSelfEvent (load) {
        for(var 
    i=1;i<11;i++){
     
    _root.solitaire.solitaire_play["black"+i].enabled=false
     _root
    .solitaire.solitaire_play["red"+i].enabled=false
        
    }
        
    black_Mask = new Array;
        
    black_Mask[0] = ["black0","178.85","70.3"];  //mc name,_x,_y
        
    black_Mask[1] = ["black1","261.55","70.3"];
        
    black_Mask[2] = ["black2","344.25","70.3"];
        
    black_Mask[3] = ["black3","426.95","70.3"];
        
    black_Mask[4] = ["black4","509.65","70.3"];
        
    black_Mask[5] = ["black5","592.3","70.3"];
        
    black_Mask[6] = ["black6","675","70.3"];
        
    black_Mask[7] = ["black7","757.7","70.3"];
        
    black_Mask[8] = ["black8","840.4","70.3"];
        
    black_Mask[9] = ["black9","923.1","70.3"];
        
    //------------------------------------------------
        
    red_Mask = new Array;
        
    red_Mask[0] = ["red0","178.85","321.45"];  //mc name,_x,_y
        
    red_Mask[1] = ["red1","261.55","321.45"];
        
    red_Mask[2] = ["red2","344.25","321.45"];
        
    red_Mask[3] = ["red3","426.95","321.45"];
        
    red_Mask[4] = ["red4","509.65","321.45"];
        
    red_Mask[5] = ["red5","592.3","321.45"];
        
    red_Mask[6] = ["red6","675","321.45"];
        
    red_Mask[7] = ["red7","757.7","321.45"];
        
    red_Mask[8] = ["red8","840.4","321.45"];
        
    red_Mask[9] = ["red9","923.1","321.45"];
     
    //--------------------------------------------------------  
    }
    function 
    pick () {
       
        
    ticks 0;
        
    this.Mask.gotoAndStop(1)
        
    this.onEnterFrame = function() {
            
    this.ticks ++;
            if (
    this.Mask_Position==1){      
            
    ran Math.random(this.black_Mask.length);              
            
    this.Mask._x this.black_Mask[ran][1];
            
    this.Mask._y this.black_Mask[ran][2];
           
    iint(this.black_Mask[ran][0].substr(5,2));
           
    ii+1;
           
    iString(i)
            if (
    this.ticks == 40) {                           
                
    this.black_Mask.splice(ran,1);
                 
    this.Mask.gotoAndStop(2)
                
    delete this.onEnterFrame
             _root
    .solitaire.solitaire_play.data_field.text="Card " +String(i)    
            for(var 
    i=1;i<11;i++){                                     
     
    _root.solitaire.solitaire_play["black"+i].enabled=true
     _root
    .solitaire.solitaire_play["red"+i].enabled=true
    }
                     
                
                
    _root.solitaire.solitaire_play["black"+String(i)].gotoAndPlay(1);          
            }
        }

    else if (
    this.Mask_Position==2){      
            
    ran Math.random(this.red_Mask.length);              
            
    this.Mask._x this.red_Mask[ran][1];
            
    this.Mask._y this.red_Mask[ran][2];
           
    iint(this.red_Mask[ran][0].substr(3,2));
           
    ii+1;
           
    iString(i)
            if (
    this.ticks == 40) {   
                  
    _root.solitaire.solitaire_play.data_field.text="Card " +String(i)                        
                        for(var 
    i=1;i<11;i++){                                     
     
    _root.solitaire.solitaire_play["black"+i].enabled=true
     _root
    .solitaire.solitaire_play["red"+i].enabled=true
    }

              
                
    this.red_Mask.splice(ran,1);
                 
    this.Mask.gotoAndStop(2)
                
    delete this.onEnterFrame 
                _root
    .solitaire.solitaire_play["red"+String(i)].gotoAndPlay(1);          
            }
        }
    }
        
    }
    //-------------------------------------------------
    function shuffling(original_array:Array):Array{
       
         var 
    shuffle_array:Array = new Array()       
          while (
    original_array.length>0){
                    var 
    n:intint(Math.randomRange (0,original_array.length))
                    
    shuffle_array.push(original_array[n])
                    
    original_array.splice(n1)
                                         }           
          return (
    shuffle_array 
    }
    //----------------------------------------------------
    onFrame (1) {
        
    stop();
        for( 
    i=1;11;i++){
       
    this["black"+i].pic.attachMovie("st1""st1"0);
         
    this["red"+i].pic.attachMovie("st1""st1"0);
       
        }
    //----------------------------------------------
    var words1=["A1","A2","A3","A4","A5","A6","A7","A8","A9","A10"];
    var 
    words2=["B1","B2","B3","B4","B5","B6","B7","B8","B9","B10"];
    var 
    words3=["C1","C2","C3","C4","C5","C6","C7","C8","C9","C10"];
    var 
    words4=["D1","D2","D3","D4","D5","D6","D7","D8","D9","D10"];
    var 
    words5=["E1","E2","E3","E4","E5","E6","E7","E8","E9","E10"];
    var 
    words6=["F1","F2","F3","F4","F5","F6","F7","F8","F9","F10"];
    var 
    words1=["G1","G2","G3","G4","G5","G6","G7","G8","G9","G10"];
    var 
    words2=["H1","H2","H3","H4","H5","H6","H7","H8","H9","H10"];
    var 
    words3=["I1","I2","I3","I4","I5","I6","I7","I8","I9","I10"];
    var 
    words4=["J1","J2","J3","J4","J5","J6","J7","J8","J9","J10"];
    var 
    words5=["K1","K2","K3","K4","K5","K6","K7","K8","K9","K10"];
    //-----------------------------------------------------------
    var selected_array_words=[];    
         if(
    _root.solitaire.h==1){selected_array_words=words1}
    else if(
    _root.solitaire.h==2){selected_array_words=words2}
    else if(
    _root.solitaire.h==3){selected_array_words=words3}
    else if(
    _root.solitaire.h==4){selected_array_words=words4}
    else if(
    _root.solitaire.h==5){selected_array_words=words5}
    else if(
    _root.solitaire.h==6){selected_array_words=words6}
    else if(
    _root.solitaire.h==7){selected_array_words=words7}
    else if(
    _root.solitaire.h==8){selected_array_words=words8}
    else if(
    _root.solitaire.h==9){selected_array_words=words9}
    else if(
    _root.solitaire.h==10){selected_array_words=words10}
    //------------------------------------------------------------

     
    selected_array_words=shuffling(selected_array_words
       

    download 0.4
    Last edited by AS3.0; 03-22-2022 at 09:07 AM.

  7. #7
    Senior Member
    Join Date
    May 2016
    Posts
    276
    hello my friend

    step 1

    Please make a random choice between the black button and the red button
    In other words, every time the first player is chosen at random,
    if the black player is the one who will start first, disable pressing the red button,
    but if the red player is chosen, disable the black player
    This is the beginning of the game
    I am waiting for you to start new additions to this game
    Thank you

  8. #8
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,247
    Ok for the first entrance of the game it will choose red or black & disable the one not in use, when the ticks hit 40, you can slide the cards for the current turn.

    This is what I put in solitaire_play
    PHP Code:
       function randomBetween(a,b){
    return(
    Math.floor(Math.random()*(b-a+1))+a);
    }
    var 
    turn =["Reds turn","Blacks turn"]
    var 
    num_selected=randomBetween(0,1)
     
    _root.solitaire.solitaire_play.data_field.text=turn[num_selected];
     if(
    num_selected==0){
     
    _root.solitaire.solitaire_play.choose_black_btn_Copy.enabled=false
      _root
    .solitaire.solitaire_play.choose_red_btn_Copy.enabled=true
     
    }else{
     
    _root.solitaire.solitaire_play.choose_black_btn_Copy.enabled=true
      _root
    .solitaire.solitaire_play.choose_red_btn_Copy.enabled=false
     

    download 0.5

  9. #9
    Senior Member
    Join Date
    May 2016
    Posts
    276
    step 2

    when i press red button :

    - disable drag and drop for all cards except current card only
    - disable black button and red button ( when i drooped the card enable black button )


  10. #10
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,247
    Here is some progress, tell me what I might of missed though.

    progress 0.6

  11. #11
    Senior Member
    Join Date
    May 2016
    Posts
    276
    when i press a red button


  12. #12
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,247
    The last one that says undefined? the second card will always appear for me.

  13. #13
    Senior Member
    Join Date
    May 2016
    Posts
    276
    i fixed this error



    shiwshmax file:

    https://app.box.com/s/ijpn2yquux15ot2v2tkkdg4djadovtt0

  14. #14
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,247
    So its fine now? or do I add something?

  15. #15
    Senior Member
    Join Date
    May 2016
    Posts
    276
    can you add :

    1- random player start ( black or red )

    if black == disable red
    if red == disable black
    2- add timer
    3- drag and drop word card to number card before time out
    if time out change another player

  16. #16
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,247
    Ok, in solitaire_play script I added randomBetween which picks either black cards or red cards, & disables black cards if red is the first chosen option.

    PHP Code:
    var turn=0;
    var 
    player_turn=["black cards","red cards"]
    turn randomBetween(0,1)
    function 
    randomBetween(a,b){
    return(
    Math.floor(Math.random()*(b-a+1))+a);
    }
    _root.solitaire.solitaire_play.data_field.text="It is " player_turn[turn] + " " "turn."
    for(var i=0;i<10;i++){
     
    _root.solitaire.solitaire_play["black"+i].enabled=false
     _root
    .solitaire.solitaire_play["red"+i].enabled=false
    }
    if(
    turn==0){
        
    _root.solitaire.solitaire_play.red_btn.enabled=false
        _root
    .solitaire.solitaire_play.black_btn.enabled=true
    }else{
        
    _root.solitaire.solitaire_play.red_btn.enabled=true
        _root
    .solitaire.solitaire_play.black_btn.enabled=false

    This is the top text field accessor:

    _root.solitaire.solitaire_play.data_field.text

    download solitaire 0.8


    Ok so should the red player keep getting turns? or it should be black cards turn next if red is the first to start.

    I started a new job recently so I had to do this online training, sorry for the delays.
    Last edited by AS3.0; 04-30-2022 at 01:30 PM.

  17. #17
    Senior Member
    Join Date
    May 2016
    Posts
    276
    When the red player starts the first card then the black player starts

    Can you add timer

    drag and drop word card to number card before time out

  18. #18
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,247
    ok in the script section "solitaire_play" where it says function pick, you need to add this script when tick == 40 to give the next player a turn:

    For the red reaching 40 ticks, this needs to be called next:
    PHP Code:
    _root.solitaire.solitaire_play.data_field.text="It is " "black cards" " " "turn."
    _root.solitaire.solitaire_play.red_btn.enabled=false
    _root
    .solitaire.solitaire_play.black_btn.enabled=true 
    For the black reaching 40 ticks, this needs to be called next:
    PHP Code:
    _root.solitaire.solitaire_play.data_field.text="It is " "red cards" " " "turn."
    _root.solitaire.solitaire_play.red_btn.enabled=true
    _root
    .solitaire.solitaire_play.black_btn.enabled=false 

    download solitaire 9

  19. #19
    Senior Member
    Join Date
    May 2016
    Posts
    276
    this is awesome
    The next step is to add timing and drag and drop work

  20. #20
    Client Software Programmer AS3.0's Avatar
    Join Date
    Apr 2011
    Posts
    1,247
    Ok this version has the timer function set to 12 seconds default for each player

    From line 7-41 on the solitaire_play script the bottom 3 variables & player_time function was added.
    PHP Code:
    var timeout_1=setTimeout(player_time,1000,turn);//on start setTimeout for function below which is a timer subtraction for the text field above the card game.
    var default_timeout=12//default timeout will be set here, I put 12 seconds.
    var time_1=default_timeout;//time_1 gets used alot in the function below "player_time" so it is set to 12 and keeps subtracting each second in "player_time" function

    function player_time(turn_var){//this function gets called each second for the game text field.
    if(turn_var==1){// turn_var 1 = red player, if true we are decreasing & modifying text here else if turn_var==0 down below for black cards.
    _root.solitaire.solitaire_play.data_field.text="It is red cards turn, you have " time_1 " seconds left."
    time_1--;

    if(
    time_1==-1){//if time == -1 inside this section for red cards, time is up, next players turn will be assigned.
    _root.solitaire.solitaire_play.data_field.text="Red card didn't make a move on time, It is black cards turn."
    _root.solitaire.solitaire_play.red_btn.enabled=false
    _root
    .solitaire.solitaire_play.black_btn.enabled=true
    time_1
    =default_timeout;//reset time to default which is 12 seconds
    turn=0//assign turn value to be black cards turn before calling setTimeout for black cards time to start decreasing
    timeout_1=setTimeout(player_time,2500,turn);
    }else{
    timeout_1=setTimeout(player_time,1000,turn);//if time is not -1 yet call setTimeout to its own function in 1 second.
    }

    }else if(
    turn_var==0){//else turn_var == 0 modify text for black cards to decrease each second.
    _root.solitaire.solitaire_play.data_field.text="It is black cards turn, you have " time_1 " seconds left."
    time_1--;
    if(
    time_1==-1){//if time == -1 inside this section for black cards, time is up, next players turn will be assigned.
    _root.solitaire.solitaire_play.data_field.text="Black card didn't make a move on time, It is red cards turn."
    _root.solitaire.solitaire_play.red_btn.enabled=true
    _root
    .solitaire.solitaire_play.black_btn.enabled=false
    time_1
    =default_timeout;//reset time to default which is 12 seconds
    turn=1//assign turn value to be red cards turn before calling setTimeout for red cards time to start decreasing
    timeout_1=setTimeout(player_time,2500,turn);
    }else{
    timeout_1=setTimeout(player_time,1000,turn);//if time is not -1 yet call setTimeout to its own function in 1 second.
    }
    }

    line 121-124 on the solitaire_play script when ticks reaches 40 for black cards we can set a turn for red cards in 1 second.
    PHP Code:
    //we reached 40 ticks so it is next players turn, time to reset variables for the next user.
    this.turn=1//the accessor for var turn starts with this. turn=1 is red turn=0 is black.
    this.time_1=this.default_timeout//since it is the next players turn now we reset this.time_1 back to default which is 12 seconds.
    this.timeout_1=setTimeout(this.player_time,1000,1);//timeout_1 stores the timeout so you can call clearTimeout if needed later. 
    line 147-150 on the solitaire_play script when ticks reaches 40 for red cards we can set a turn for black cards in 1 second.
    PHP Code:
    //we reached 40 ticks so it is next players turn, time to reset variables for the next user.
    this.turn=0//the accessor for var turn starts with this. turn=1 is red turn=0 is black.
    this.time_1=this.default_timeout//since it is the next players turn now we reset this.time_1 back to default which is 12 seconds.
    this.timeout_1=setTimeout(this.player_time,1000,0);//timeout_1 stores the timeout so you can call clearTimeout if needed later. 
    download solitaire 10
    Last edited by AS3.0; 05-17-2022 at 10:10 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