N
noino
Guest
I'm struggling a little bit with implementing water into my game. I understand vaguely how it should work, but I fail to execute it at any decent level.
It works for the most part, but in large volumes it just floods the whole area without deflating from the source. this video should explain it a bit:
Any help with perfecting the water mechanics is greatly appreciated and dont hesitate to ask more questions if my post is too unclear.
It works for the most part, but in large volumes it just floods the whole area without deflating from the source. this video should explain it a bit:
Any help with perfecting the water mechanics is greatly appreciated and dont hesitate to ask more questions if my post is too unclear.
Code:
for(var xx = (view_xview-175) div 35; xx < (view_xview+view_wview+175) div 35; xx++;){
for(var yy = (view_yview) div 35; yy < (view_yview+(view_hview)) div 35; yy++;){
if(xx*35 > 35 and yy*35 > 35 and xx*35 < room_width-35 and yy*35 < room_height-35){
if(watergrid[# xx,yy] > 0){
var rand = choose(-1,1);
if(watergrid[# xx,yy] > 7) watergrid[# xx,yy] = 7;
if(obj_grid.collidegrid[# xx,yy+1] = 0 and watergrid[# xx,yy+1] < 7){
if(watergrid[# xx,yy+1] <= 0){
watergrid[# xx,yy+1] = watergrid[# xx,yy];
watergrid[# xx,yy] = 0;
}else{
while(watergrid[# xx,yy+1] < 7 and watergrid[# xx,yy] > 0){
watergrid[# xx,yy+1] += 1;
watergrid[# xx,yy] -= 1;
}
}
}else if(obj_grid.collidegrid[# xx-(1*rand),yy] = 0 and watergrid[# xx-(1*rand),yy] < 7 and watergrid[# xx,yy] != watergrid[# xx-(1*rand),yy] and watergrid[# xx,yy] > 0){
if(watergrid[# xx-(1*rand),yy] <= 0){
watergrid[# xx-(1*rand),yy] = watergrid[# xx,yy]/2;
watergrid[# xx,yy] = watergrid[# xx-(1*rand),yy];
}else{
while(watergrid[# xx-(1*rand),yy] < watergrid[# xx,yy]){
watergrid[# xx-(1*rand),yy] += 1;
watergrid[# xx,yy] -= 1;
}
}
}else if(obj_grid.collidegrid[# xx+(1*rand),yy] = 0 and watergrid[# xx+(1*rand),yy] < 7 and watergrid[# xx,yy] != watergrid[# xx+(1*rand),yy] and watergrid[# xx,yy] > 0){
if(watergrid[# xx+(1*rand),yy] <= 0){
watergrid[# xx+(1*rand),yy] = watergrid[# xx,yy]/2;
watergrid[# xx,yy] = watergrid[# xx-(1*rand),yy];
}else if(watergrid[# xx+(1*rand),yy] < watergrid[# xx,yy]){
while(watergrid[# xx+(1*rand),yy] < watergrid[# xx,yy]){
watergrid[# xx+(1*rand),yy] += 1;
watergrid[# xx,yy] -= 1;
}
}else{
if(watergrid[# xx,yy] >= 7){
watergrid[# xx,yy] -= 1;
}
}
}
if(watergrid[# xx,yy] < 7 and watergrid[# xx,yy] >= 6 and watergrid[# xx,yy-1] > 0){
watergrid[# xx,yy] = 7;
}
}
}
}
}
Last edited by a moderator: