M
Matt93
Guest
Hello everyone,
I'm currently attempting to make a solitaire game for coding practice. I've rarely seen card games done with Game Maker, so thought it was a worthy project!
I've been focusing mainly on getting the cards set up in a grid, being able to move them etc. I've created the deck with a ds_list:
I've also put them into a ds_grid:
I'm able to move them around okay, and coding this so I can only move the front card shouldn't be an issue. I'm stuck on how, when I have two or more that are movable in a column, I'm going to code this so both of them move at once? And also so that the ids of both, rather than just one, are stored and the cards will be put down in the correct order? I currently have a variable called global.card which is set to noone in create event, then to the id of the card I click on. This is set back to noone when the card is put down.
I have also had problems snapping the cards to the grid properly. If I could have any advice with any of those things, or any pointers if I'm going about this completely wrong, that'd be great.
Cheers!
I'm currently attempting to make a solitaire game for coding practice. I've rarely seen card games done with Game Maker, so thought it was a worthy project!
I've been focusing mainly on getting the cards set up in a grid, being able to move them etc. I've created the deck with a ds_list:
Code:
//Create the deck
deck = ds_list_create();
//give the list integers from 0 to 51 (52 integers representing 52 playing cards in a deck)
for(var i = 0; i < 52; i++)
{
ds_list_add(deck, i);
}
ds_list_shuffle(deck);//shuffle this list
Code:
//create the grid
width = 7;
height = 1;
height_last_row = 7;
max_height = 13;
x_start_of_gamespace = 64;
y_start_of_gamespace = room_height - 250;
xx = 64;
yy = room_height - 250;
position = 0; //position in deck
play_area = ds_grid_create(width,max_height);
//width
for (var i = 0; i < width; i++)
{
for (var j = 0; j<height; j++)
{
ds_grid_set(play_area,i,j, ds_list_find_value(deck,position))
m = instance_create(xx, yy, obj_card) //see the visual
m.image_index = ds_list_find_value(deck, position);
yy+= 30;
position++
}
yy = room_height - 250;
xx +=80;
height++;
}
I have also had problems snapping the cards to the grid properly. If I could have any advice with any of those things, or any pointers if I'm going about this completely wrong, that'd be great.
Cheers!