D
Delta19ß5
Guest
I'm relative new in GMS and wanted to start with a jump n' run. I want to spawn objects on 5 different locations. Which location one of the object spawn is random. To avoid an overflow of instances I want max 6 instances of the object. Here's my problem I don't really know how to perform this. I have some piece of code but it don't work and I don't know why. I don't get any error. (In the create event of obj_rock rockamount is set to 0)
Here's the code:
I got an alternative code that work but the instances only spawn at random y and set x. But i want only spawns at 5 different set locations :/
Here's it:
I hope you can help me with my program
Here's the code:
///Spawnsystem
spawnpoint = random(4);
if rockamount < 6
{
if spawnpoint = 0
{
instance_create(575, 64, obj_rock);
rockamount += 1;
}
else
{
if spawnpoint = 1
{
instance_create(575, 96, obj_rock);
rockamount += 1;
}
else
{
if spawnpoint = 2
{
instance_create(575, 128, obj_rock);
rockamount += 1;
}
else
{
if spawnpoint = 3
{
instance_create(575, 160, obj_rock);
rockamount += 1;
}
else
{
if spawnpoint = 4
{
instance_create(575, 192, obj_rock)
rockamount += 1;
}
}
}
}
}
}
spawnpoint = random(4);
if rockamount < 6
{
if spawnpoint = 0
{
instance_create(575, 64, obj_rock);
rockamount += 1;
}
else
{
if spawnpoint = 1
{
instance_create(575, 96, obj_rock);
rockamount += 1;
}
else
{
if spawnpoint = 2
{
instance_create(575, 128, obj_rock);
rockamount += 1;
}
else
{
if spawnpoint = 3
{
instance_create(575, 160, obj_rock);
rockamount += 1;
}
else
{
if spawnpoint = 4
{
instance_create(575, 192, obj_rock)
rockamount += 1;
}
}
}
}
}
}
I got an alternative code that work but the instances only spawn at random y and set x. But i want only spawns at 5 different set locations :/
Here's it:
///Spawnsystem
if global.rockamount < 6
{
instance_create(575, random_range(64, 192), obj_rock);
global.rockamount += 1;
}
if global.rockamount < 6
{
instance_create(575, random_range(64, 192), obj_rock);
global.rockamount += 1;
}
I hope you can help me with my program