• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Multiple Object Help

C

CRob1974

Guest
Hi, could someone please tell me if there is a way I can create one object and place it in a room multiple times and then give each its own individuality. At the moment I am using the id and object_index commands but having to duplicate the object as many times as required and then use the position_meeting. This way can be very tedious if you want to create (for example) a snap card game as the object has to be duplicated 52 times.

Thank you
 

TheouAegis

Member
Create Event:
Code:
global.deck = ds_list_create();
i = 0;
repeat 52 ds_list_add(global.deck,i++);
randomize();
ds_list_shuffle(global.deck);
i = 0;
global.hand[number_of_players - 1] = ds_stack_create();
alarm[0] = 60;
global.phase = 0;
Alarm 0 Event:
Code:
if ds_list_size(global.deck)
{
    ds_stack_push(global.hand[++i], ds_list_find_value(global.deck, 0) );
    ds_list_delete(global.deck,0);
    if i==number_of_players 
        i = 0;
    alarm[0] = 30;
}
else
global.phase += 1;
Each player will have a stack (global.hand[player]) and that list will just hold a bunch of random random numbers. Each number represents a card.

value mod 13 is the card's face value
value div 13 is the card's suit
If value div 13 == 4, the card is a joker

The phase of the game (deal, turn 1, turn 2, whatever) is kept track of with the global.phase variable.

There, something to get you started.
 
C

CRob1974

Guest
Thank you, I shall use the repeat command and the code makes sense. Just what I was looking for :)
 
Top