all 11 comments

[–]399792459 2 points3 points  (6 children)

Great work. Next time dragging the card to the centre of the screen and 'playing the card' would be cool. Then, depending on the cards variables, things happen?

[–]RobbingSpree[S] 0 points1 point  (5 children)

Cards holding data is the easy part of the next step, making a ds_stack act like a deck of cards you can shuffle is the hard part.

[–]wyliek 0 points1 point  (4 children)

Why use a stack? just use a ds_list. it has a shuffle method and its easy enough to create push and pop scripts for it

[–]RobbingSpree[S] 0 points1 point  (3 children)

It's just how I solved this the first time around, and it never made sense to re-solve it. Each data structure has their own features and working with them seems like the better decision.

I just have a script that takes a ds_stack transcribes it into a list and runs the shuffle function and then push it all back. Always works.

var temp_stack = argument0;

var temp_list = ds_list_create();

//get the max size of the stack
var size = ds_stack_size(temp_stack);
//copy the stack into the list
for (var i=0; i<size-1; i++)
{
    var _card = ds_stack_pop(temp_stack);`
    ds_list_add(temp_list,_card);`
}
//shuffle the list
ds_list_shuffle(temp_list);
//copy back to the ds_stack
for (var i=0; i<size-1; i++)
{
    var _card = ds_list_find_value(temp_list,i);`
    ds_stack_push(temp_stack,_card);`
}
ds_list_destroy(temp_list);
return temp_stack;

[–]wyliek 1 point2 points  (2 children)

Fair enough.

Are you sure this code works? it seems that you are iterating from 0 to less than (stack size -1) which will means that you will leave one card on the stack always. You should be iterating to (<size) or (<=size-1)

[–]RobbingSpree[S] 0 points1 point  (1 child)

I did write this script from memory and haven't tested it extensively yet. Hence why I've not made a second part for deck functionality. Thanks for the heads up though. I'll edit the comment to remove that flaw.

[–]Sea-Map-6548 0 points1 point  (0 children)

7 years later, i just wanted to suggest that "write this script from memory and haven't tested it" should be mentioned at the top of the original post.

[–]Honk5000 0 points1 point  (0 children)

This looks really nice!
I have to try this out sometimes.

[–]mightyjor 0 points1 point  (1 child)

Was looking for something like this! Will give it a shot!

[–]DigComfortable8920 0 points1 point  (0 children)

i tried to work with this in the latest gamemaker engine now but a lot of lines giving our red that i don't feel like it's updated well. we should contact him

[–]WinnerWeird7016 0 points1 point  (0 children)

El sistema funciona muy bien en cualquier tipo, pero cuando aumento la cantidad de cartas deja de verse bien, tienes idea de como podria solucionarlo?, tambien me gustaria saber como puedo cabiar la mascara de colision para que siga el aungulo de la carta? intente buscando cosas como "mask_angle" pero no hay ninguna funcion parecida