B
Bogan666
Guest
I have currently got set a map which randomly spawns objects to form the world, using this code to spawn the objects
var i;
for (i = 0; i < 4; i += 1)
{
x = irandom(room_width) div 32 * 32
y = irandom(room_width) div 32 * 32
instance_create(x,y,obj_dirt);
}
So with this it will pick a random place within the room width/height and divide by 32 to keep in the 32x32 grid that I want the game to be played in.
In theory this is great and it works, I've also got a bit of code
"move_wrap(true,true,32);" so if anything gets put out of the map it'll just wrap around to the otherside.
This is where the issues come in, when looking at the world everything looks fine, but I just added a bit of code to spawn a npc at a random object on the map. So say 2/5ths of world are made up for dirt, it picks a random instance of dirt and spawns the player there. But the player can spawn "outside" the map on one of these rouge objects. seemingly up to the size of one 32x32 chunk.
my question is why would the map objects not wrap back once it sees that its outside of the map, is move_wrap not enough for it to see that its out of the map?
in the picture you can see the co ords for the npc, but my room size is 1920x1056.
can explain the world generation if needed.
var i;
for (i = 0; i < 4; i += 1)
{
x = irandom(room_width) div 32 * 32
y = irandom(room_width) div 32 * 32
instance_create(x,y,obj_dirt);
}
So with this it will pick a random place within the room width/height and divide by 32 to keep in the 32x32 grid that I want the game to be played in.
In theory this is great and it works, I've also got a bit of code
"move_wrap(true,true,32);" so if anything gets put out of the map it'll just wrap around to the otherside.
This is where the issues come in, when looking at the world everything looks fine, but I just added a bit of code to spawn a npc at a random object on the map. So say 2/5ths of world are made up for dirt, it picks a random instance of dirt and spawns the player there. But the player can spawn "outside" the map on one of these rouge objects. seemingly up to the size of one 32x32 chunk.
my question is why would the map objects not wrap back once it sees that its outside of the map, is move_wrap not enough for it to see that its out of the map?
in the picture you can see the co ords for the npc, but my room size is 1920x1056.
can explain the world generation if needed.
Attachments
-
2.8 KB Views: 10