B
bluef
Guest
So im trying to randomize placement of cards. 5 cards along the x axis and 4 cards along the y axis.
wired stuff keeps happening. heres my code
now i am trying to get the gamemaker tto check weather a card is at a posistion x and y . if its not then place a card with random number and place another card of the same number on a random position. if there is a card there then move on to the next position. but it keeps going out of the specified positions and making cards and sometimes not making cards where there should be
wired stuff keeps happening. heres my code
Code:
loop = 1;
xri = 0;
yri = 0;
donuthin = 1;
xi = 32;
yi = 32;
randomize();
global.cur_card_no = random_range(1,6);
for (i = 0; i <= 20; i += 1)
{
if(instance_position(xi,yi,obj_cards))
{
donuthin = 1;
xi += 80;
if (xi > 352)
{
xi = 32;
yi += 80;
}
}
else
{
global.cur_card_no = random_range(1,6);
instance_create_depth(xi,yi,0,obj_cards);
xi += 80;
xri = choose(32,112,192,272,352);
yri = choose(32,112,192,272);
if(!instance_position(xri,yri,obj_cards))
{
while(instance_position(xri,yri,obj_cards)&& loop < 50)
{
loop += 1;
xri = choose(32,112,192,272,352);
yri = choose(32,112,192,272);
}
instance_create_depth(xri,yri,0,obj_cards);
}
}
if (xi >= 352)
{
xi = 32;
yi += 80;
}
}
Attachments
-
46.9 KB Views: 4