• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

PCG item placement issue(Solved)

R

Rizlad

Guest
I wrote a pseudo/test script to test how many surrounding walls there are and if there are the appropriate amount put items in corners and nooks of my generated map, it is putting items almost everywhere. o.o".
Please come to my aid Almighty Programming-Elders!



Floor-tile Script-

///scr_fill_room
poss = 0;

inst = instance_place(x-32,y,obj_cwall);
if inst != noone {
poss++;
}
inst = instance_place(x+32,y,obj_cwall);
if inst != noone {
poss++
}
inst = instance_place(x,y-32,obj_cwall);
if inst != noone {
poss++
}
inst = instance_place(x,y+32,obj_cwall);
if inst != noone {
poss++
}

if (poss >= 3) {
instance_create(x,y,choose(obj_rock,obj_torch));
}
if (poss = 2) {
instance_create(x,y,choose(obj_rock,obj_torch,obj_none,obj_barrel));
}
 
Last edited by a moderator:

2Dcube

Member
What are the sprites/masks of obj_cwall and teh floor tile like? It could be an issue with overlapping where you'd get lots of collisions.
 
R

Rizlad

Guest
What are the sprites/masks of obj_cwall and teh floor tile like? It could be an issue with overlapping where you'd get lots of collisions.
Floor tile is not a physics object and wall takes up it's full 32x32 for a mask.
 
R

Rizlad

Guest
Floor-tile Script-

///scr_fill_room
poss = 0;

inst = instance_place(x-32,y,obj_cwall);
if inst != noone {
poss++;
}
inst = instance_place(x+32,y,obj_cwall);
if inst != noone {
poss++
}
inst = instance_place(x,y-32,obj_cwall);
if inst != noone {
poss++
}
inst = instance_place(x,y+32,obj_cwall);
if inst != noone {
poss++
}

if (poss >= 3) {
instance_create(x,y,choose(obj_rock,obj_torch));
}
if (poss = 2) {
instance_create(x,y,choose(obj_rock,obj_torch,obj_none,obj_barrel));
}

Fixed my own problem.
as it was running in a script not the object itself had to phase last part as:


if (poss >= 3) {
instance_create(
self.x,self.y,choose(obj_rock,obj_torch));
}
if (poss = 2) {
instance_create(
self.x,self.y,choose(obj_rock,obj_torch,obj_none,obj_barrel));
}
 
Top