B
Butterfly6
Guest
Hello everyone,
I don't have a lot of experience in using game maker yet, so I hope you can help me out with the following problem. I am making a game in which a person in walking around in a supermarket and gains points by colliding with healthy foods and loses points by colliding with junk food. I want a new piece of food to appear randomly in the room every time the other piece gets eaten. My problem is that the new piece of food sometimes appears on top of another object in the room (for example on top of a craddle or a check out desk). The person in the game is than is not able to eat that piece of food anymore.
The step event of obj_controller:
The create event of the parent of all the junk foods:
I tried this code above so that the food would not appear closer than 100 to that object, but it still does. I have no idea how to fix this.
I really hope that someone can help me out with this!
Thank you in advance!
I don't have a lot of experience in using game maker yet, so I hope you can help me out with the following problem. I am making a game in which a person in walking around in a supermarket and gains points by colliding with healthy foods and loses points by colliding with junk food. I want a new piece of food to appear randomly in the room every time the other piece gets eaten. My problem is that the new piece of food sometimes appears on top of another object in the room (for example on top of a craddle or a check out desk). The person in the game is than is not able to eat that piece of food anymore.
The step event of obj_controller:
Code:
if !instance_exists(obj_pizza)
{
instance_create(random(room_width), random(room_height),obj_pizza)
x = random(room_width);
y = random(room_height);
}
if !instance_exists(obj_pancakes)
{
instance_create(random(room_width), random(room_height),obj_pancakes)
x = random(room_width);
y = random(room_height);
}
Code:
while (distance_to_object(obj_krataubergines) <100)
{
x=random(room_width);
y=random(room_height);
}
while (distance_to_object(obj_krattomaat) <100)
{
x=random(room_width);
y=random(room_height);
}
while (distance_to_object(obj_krataardpl) <100)
{
x=random(room_width);
y=random(room_height);
}
while (distance_to_object(obj_krat) <100)
{
x=random(room_width);
y=random(room_height);
}
while (distance_to_object(obj_kratmais) <100)
{
x=random(room_width);
y=random(room_height);
}
while (distance_to_object(obj_bankerella) <100)
{
x=random(room_width);
y=random(room_height);
}
while (distance_to_object(obj_kassa) <100)
{
x=random(room_width);
y=random(room_height);
}
while (distance_to_object(obj_kast) <100)
{
x=random(room_width);
y=random(room_height);
}
while (distance_to_object(obj_wijn) <100)
{
x=random(room_width);
y=random(room_height);
}
while (distance_to_object(obj_brood) <100)
{
x=random(room_width);
y=random(room_height);
}
I really hope that someone can help me out with this!
Thank you in advance!
Last edited by a moderator: