Log In  
Follow
windigo

Cart #37984 | 2017-03-01 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

0 comments



Hi,

I get an out of memory when calling this function (recursive)

when i click a button, i will call select_ball(4,4,3) -> now all objects with the same index (neighbours) wil get index 7
This works perfectly fine, but no matter how many objects will be selected, in the end there is an out of memory exception

balls is a 16x10 multidimensional array.

arrow keys to move the cursor and 'z' to click on a ball

function select_ball(x,y,index)
 	if balls[x][y].index==index then
  		balls[x][y]={index=7}
 		if x>1 and balls[x-1][y].index==index then
 	 		select_ball(x-1,y,index)
 		end
 		if x<width and balls[x+1][y].index==index then
  			select_ball(x+1,y,index)
 		end
 		if y>1 and balls[x][y-1].index==index then
 			select_ball(x,y-1,index)
		end
 		if y<height and balls[x][y+1].index==index then
 			select_ball(x,y+1,index)
		end
	end
end

[ Continue Reading.. ]

2 comments



Cart #37701 | 2017-02-22 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA
1

Not very original to make a snake game, but it's my first attempt to finish something :-)

1
2 comments