S
Skivenous
Guest
I have an optimization issue: I'm making a game that builds bricks across a line, and when the line is full it destroys them. But when testing the game, I get 10 or so lines in and the game slows massively. In debug it shows that tons of instances of the brick object are still in the game, even though they should be deleted. I also have code that should be preventing bricks to be placed if one is there already. Help! I have a lot of code and am not sure which to post, so I'll just show the delete row code: (ignore syntax I'm typing this on a phone)
xx=x;
yy=y;
row_full = true;
while (place_meeting (xx-32, y, objwall) ==false) {
Xx-=32;
If (place_meeting(xx,y,objbricks)==0){
Row_full=false;
Break;
}}
while (place_meeting (xx+32, y, objwall) ==false) {
Xx+=32;
If (place_meeting(xx,y,objbricks)==0){
Row_full=false;
Break;
}}
If (row_full == true) {
Global.rows_cleared +=1;
With objbricks {
Instance_destroy()
Var inst;
Inst = instance_place(x,y,obj);
If inst = no one
Instance_create((objbricks layer.x div 32)*32, (objstarter.y),objbricks);
}}
Objstarter doesn't get deleted but lays a brick when the objbricklayer touches it so bricks can keep being placed after they are cleared, but apparently bricks are not actually being removed...
xx=x;
yy=y;
row_full = true;
while (place_meeting (xx-32, y, objwall) ==false) {
Xx-=32;
If (place_meeting(xx,y,objbricks)==0){
Row_full=false;
Break;
}}
while (place_meeting (xx+32, y, objwall) ==false) {
Xx+=32;
If (place_meeting(xx,y,objbricks)==0){
Row_full=false;
Break;
}}
If (row_full == true) {
Global.rows_cleared +=1;
With objbricks {
Instance_destroy()
Var inst;
Inst = instance_place(x,y,obj);
If inst = no one
Instance_create((objbricks layer.x div 32)*32, (objstarter.y),objbricks);
}}
Objstarter doesn't get deleted but lays a brick when the objbricklayer touches it so bricks can keep being placed after they are cleared, but apparently bricks are not actually being removed...