Can't figure out how clear tilemap

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By asgdsfdfsdfsd

I’m trying to make a tetris game. When I run my program and check which cells in the tilemap are active with show_used_cells, it says it is clearing the cells in complete lines as I’d expect, but they are still visible on the screen.

Here’s a gif of what I’m talking about:

They stack on top of each other just fine. When a line is cleared, the cells in that line are able to be reoccupied, but it looks like the previous tile is still there.

I’ve included the parts of my code that I think may be relevant.

func _check_set_ttrm(): # ttrm = tetromino
	ttrm_coords = _get_ttrm_coords()
	for i in ttrm_coords:
		if i.y >= 19:
			for j in ttrm_coords:
				set_cellv(j,chosen_ttrm)
				spawn_ttrm = true
		for k in get_used_cells():
			if i.y+1 == k.y and i.x == k.x:
				for l in ttrm_coords:
					set_cellv(l,chosen_ttrm)
					spawn_ttrm = true

func _check_clear_line():
	for j in range(0, grid_size.y):
		complete_line = true
		for i in range(0, grid_size.x):
			if get_cell(i,j) == -1:
				complete_line = false
		if complete_line:
			_clear_line(j)
			print(j)

func _clear_line(y):
	print("a")
	for i in range(0, grid_size.x):
		set_cell(i,y,-1)
		pass
	pass

func _process(delta):
	_check_set_ttrm()
	_check_clear_line()
	get_used_cells()

I would really appreciate it if somebody could help me figure out what I’m doing wrong.

It’s hard to tell, what your algorithm does without proper explanation :-/

RenenerG | 2019-02-20 23:10

Can you try printing what grid_size.x is in _clear_lines()?

Eric Ellingson | 2019-02-21 06:16