J
James7285
Guest
I wanted to generate some items onto my level but I want them to snap to a specific grid. I tried the code below but nothing appears when you start the game (there are no errors either).
gridx[0] = 96
gridx[1] = 160
gridx[2] = 224
gridx[3] = 288
gridx[4] = 352
gridx[5] = 416
gridy[0] = 96
gridy[1] = 160
gridy[2] = 224
gridy[3] = 288
gridy[4] = 352
gridy[5] = 416
while (instance_number(obj_energy) < 4)
{
randx = irandom(5)
randy = irandom(5)
instance_create(gridx[randx],gridy[randy],obj_energy)
}
My only other thought with that is that I suppose it's possible for 2 of the same item to appear on top of each other. Is it easy to check that first?
Thanks for your time.
James
gridx[0] = 96
gridx[1] = 160
gridx[2] = 224
gridx[3] = 288
gridx[4] = 352
gridx[5] = 416
gridy[0] = 96
gridy[1] = 160
gridy[2] = 224
gridy[3] = 288
gridy[4] = 352
gridy[5] = 416
while (instance_number(obj_energy) < 4)
{
randx = irandom(5)
randy = irandom(5)
instance_create(gridx[randx],gridy[randy],obj_energy)
}
My only other thought with that is that I suppose it's possible for 2 of the same item to appear on top of each other. Is it easy to check that first?
Thanks for your time.
James