I am randomly generating a level and trying to get it to randomly pick the bricks color each time it creates another brick put while it a randomly select a color it will only be one color through out the entire thing I can't figure out why relevant code below
the level obj in the create event
the brick in the draw event
the level obj in the create event
Code:
randomize();
columon=irandom_range(5,35)
for(i=1;i<columon;i++){
starttile=irandom_range(0,4)
if(starttile=0){
xxstart=0
}
else
{
if(starttile=1){
xxstart=29
}
else
{
if(starttile=2){
xxstart=58
}
else
{
if(starttile=3){
xxstart=87
}
else
{
if(starttile=4){
xxstart=116
}
}
}
}
}
row=irandom_range(1,65)
for(j=1;j<row;j++){
xx=(j-1)*29
yy=(i-1)*14
global.tilecolor=irandom_range(1,3)
instance_create_layer(xx+xxstart,yy,"Instances",obj_tile)
}
}
Code:
if(global.tilecolor == 1)
{
draw_self();
}
else
{
if(global.tilecolor == 2)
{
draw_sprite(spr_tileblue,0,x,y)
}
else
{
if(global.tilecolor==3){
draw_sprite(spr_tilegreen,0,x,y)
}
}
}