• 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!

Legacy GM make a card mechanic

phillipPbor

Member
deck
```deck = ds_list_create();
tempDeck = ds_list_create();
ds_list_add(deck,3);
ds_list_add(deck,3);
ds_list_add(deck,3);
ds_list_add(deck,3);
ds_list_add(deck,4);
ds_list_add(deck,4);
ds_list_add(deck,1);
ds_list_add(deck,2);
ds_list_add(tempDeck,ds_list_find_value(deck,0));

num_of_cards = ds_list_size(deck);
xPos = 96
yPos = 184

for(var i = 0; i <=num_of_cards; i++)
{
//place cards
var curr_card = instance_create(xPos,yPos,card_obj);
curr_card.image_index = ds_list_find_value(deck,i);
xPos -= 16;
}```

to delete card. (use card)
Code:
ds_list_delete(deck,0)
with (card_obj)
    {
    instance_destroy();
    }
num_of_cards = ds_list_size(deck);
xPos = 96
yPos = 184
for(var i = 0; i <=num_of_cards; i++)
{
    var curr_card = instance_create(xPos,yPos,card_obj);
    curr_card.image_index = ds_list_find_value(deck,i);
    xPos -= 16;
}
jive credit to flitzekatze
we helped make deck, use button, skip button. but...
is use button usefull?

card mechanic.gif


how do I make card active when I press use?

like making the 0 into "fire" or "blade" ?
 
The way that my deck system works is that I use a ds_grid for the card storage instead of a list and I use the rows of the list to store details about the card, so when I click on the card to use it, it searches up the column that card is and then runs the script that I have stored in the 'activate row' (which will perform the cards use). So, to simplify the grid it's basically:
Code:
Card    |    Activate Row
------------------------------------------
Card 1  |    scr_card_1
Card 2  |    scr_card_2
Etc...
 

phillipPbor

Member
The way that my deck system works is that I use a ds_grid for the card storage instead of a list and I use the rows of the list to store details about the card, so when I click on the card to use it, it searches up the column that card is and then runs the script that I have stored in the 'activate row' (which will perform the cards use). So, to simplify the grid it's basically:
Code:
Card    |    Activate Row
------------------------------------------
Card 1  |    scr_card_1
Card 2  |    scr_card_2
Etc...
yah, but I want those cards buttons.
unity later.
I never use them. I just want to know.

the code for use cards is
other.use=true;
posted it before the ds_list_delete
didn't work.

and the cards
upload_2017-6-9_8-38-17.png
 
use=true needs to be inside the with (card_obj) { code to make it work. other.use=true means nothing unless you have it inside a collision event (or inside a with statement, but for your needs, you simply need use=true inside of the with statement).
 

phillipPbor

Member
use=true needs to be inside the with (card_obj) { code to make it work. other.use=true means nothing unless you have it inside a collision event (or inside a with statement, but for your needs, you simply need use=true inside of the with statement).
it is inside of it
image_speed = 0
use=false
 
You need to structure your sentences better for me to understand what you want. I wasn't talking about you having to need the variable in the Create Event, btw. But if you can structure what you're asking better then I can probably help you with it.
 

phillipPbor

Member
You need to structure your sentences better for me to understand what you want. I wasn't talking about you having to need the variable in the Create Event, btw. But if you can structure what you're asking better then I can probably help you with it.
then what should I do then?
 
Last edited:

phillipPbor

Member
You need to structure your sentences better for me to understand what you want. I wasn't talking about you having to need the variable in the Create Event, btw. But if you can structure what you're asking better then I can probably help you with it.
I mean I want to know how to make cards active when pressing Z.

but whats the code for it?
 
I don't know how your code is set up properly from what you have posted, but it would be something like this:

Deck Controller Object Step Event:
Code:
if (keyboard_check_pressed(ord('Z'))) {
    with (curr_card) {
        use = true;
    }
}
You have to have a variable that is tracking the currently selected card (in the code above, that variable would be curr_card) stored in a controller object (it looks like you have a deck controller object from the code in your first post) and then you can use the keyboard_check to see if you've pressed Z, which then uses a with statement to set the curr_card 'use' variable to true (I'm using 'use' because I see in one of your other posts that you check if 'use' = true in the step event of the card object).

I can't give exact code for your project though, you have to take what I've given you and adapt it to fit into your game. Just make sure you're using a variable to keep track of the currently selected card somehow and then use a with statement on that variable to change the currently selected card's 'use' variable to true.
 
Top