1. Hey! Guest! The 36th GMC Jam will take place between February 27th, 12:00 UTC - March 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice
  2. NOTICE: We will be applying a Xenforo update on Tuesday 25th of February. This means that from approximately 10:00 to 14:00 BST the forums will be offline (or possibly longer). Sorry for the inconvenience! Official Announcement here.

GM:S 1.4 card mechanic problem

Discussion in 'Programming' started by phillipPbor, Jul 19, 2017.

  1. phillipPbor

    phillipPbor Member

    Joined:
    Jun 21, 2016
    Posts:
    223
    I went to look for help and with out the help of discord I would not make something like this.

    the cards are action cards...
    giving player an opportunity to perform.
    like kingdom hearts chains of memories.
    has 3 buttons, I use 2.
    there use, skip, and hold.

    but I came up with problems, one of them is about the reload card...
    after used up all the cards, when I press reload, all the cards came back leaving one from a start gone missing... :(
    and worse because I cant reach the reload button after used up attack magic cards.

    help.PNG
    reload card is I thought was ment to be at the far end always but it proves I was wrong...
    the reload card will be amongs a cards... the truth is that I did not make such mechanic alone...

    deck_controller
    create
    Code:
    usebutton = true;
    /// the deck set up WIP
    global.card_index = 0
    global.use = 0
    //card set.........................
    current_cards = ds_list_create();   perma_cards = ds_list_create(); //v
    //                     v                         |
                   tempa_used = ds_list_create();//  |
    //                                    v          |
                       deck = ds_list_create();// <<<
    //permacards
    ds_list_add(perma_cards,19);//blade
    ds_list_add(perma_cards,27);
    //tempacards
    ds_list_add(current_cards,4);
    ds_list_add(current_cards,3);
    ds_list_add(current_cards,1);
    //battle start
    for (var i = 0; i < ds_list_size(perma_cards); i++) {
         ds_list_add(deck,perma_cards[| i])
    }
    for (var i = 0; i < ds_list_size(current_cards); i++) {
         ds_list_add(tempa_used,current_cards[| i])
    }
    for (var i = 0; i < ds_list_size(tempa_used); i++) {
         ds_list_add(deck,tempa_used[| i])
    }
    //setup.................&
    num_of_cards = ds_list_size(deck);
    xPos = 32
    yPos = 184
    for(var i = 0; i <=num_of_cards; i++)
    {
    //place cards
        var curr_card = instance_create(xPos,yPos,card_obj);
        if (i == 0)
        {
         global.card_index = ds_list_find_value(deck,i);
        }
        curr_card.image_index = ds_list_find_value(deck,i);
        xPos -= 4;
        yPos -= 1;
    }
    alarm 5
    usebutton = true;

    step event
    Code:
    if keyboard_check_pressed(vk_right)
    {
    if usebutton = true
    {
    ///Use card
     xPos = 32
     yPos = 184
    //////////execute actions for the specified card////////
     card_use();
     var card_value = ds_list_find_value(deck, 0);
    //////////////////////
    audio_play_sound( sound1, 0, 0 );
     ds_list_delete(deck,0)
     num_of_cards = ds_list_size(deck);
     with(card_obj)
     {instance_destroy();}
    //////////////////////
      for(var i = 0; i <= num_of_cards; i++)
     {
      var curr_card = instance_create(xPos,yPos,card_obj);
      if (i==0)
      {
       global.card_index = ds_list_find_value(deck,i);
      }
        curr_card.image_index = ds_list_find_value(deck,i);
      xPos -= 4;
      yPos -= 1;
      if (num_of_cards==0)
      {
         global.card_index = 0;
      }
     }
    usebutton = false;
    }
    else
    {}}
    
    
    if keyboard_check_pressed(vk_left)
    {
    ///skip the card
    ds_list_add(deck,ds_list_find_value(deck,0))
    ds_list_delete(deck,0)
    with(card_obj)
        {
        instance_destroy();
        }
    num_of_cards = ds_list_size(deck);
    xPos = 32
    yPos = 184
    for(var i = 0; i <=num_of_cards; i++)
    {
        var curr_card = instance_create(xPos,yPos,card_obj);
         if (i==0)
         {
          global.card_index = ds_list_find_value(deck,i);
         }
         curr_card.image_index = ds_list_find_value(deck,i);
         if (num_of_cards==0)
         {
         global.card_index = 0;
         }
        xPos -= 4;
        yPos -= 1;
    }}
    card_use script
    Code:
    ///card_use()
     switch(global.card_index)
     {
     //reload deck________________________________________________
       case (0):
       show_debug_message("reload")
       audio_play_sound( sound0, 0, 0 );
       ds_list_copy(deck, tempa_used);
       for (var i = 0; i < ds_list_size(perma_cards); i++) {
       ds_list_add(deck,perma_cards[| i])
       }
       alarm[5] = 1;
                   break;
     //item deck_________________________________________________
    
       case (1):
       show_debug_message("potion.med")
       obj_player.sprite_index = P2_B_U;
       obj_player.image_speed = 0.5
       obj_player.image_index = 0
       obj_player.alarm[0] = 10;
       deck_controller.alarm[5] = 5;
       obj_player.HP += 50;
      //
                     break;
    etc
    each number comes with image.
    
    
    2017-07-19 (2).png

    now you see that reload was like a (reload) (reset) but after card_use triggered reload card,
    all the perma_cards and current_cards came back in hand. but the code moves on, it deletes a after current card.
     
    Last edited: Jul 19, 2017

Share This Page