Early Days on my 2nd Game for Defold

Wow. I’m so glad I switched to using the tilemap to control my polyominos. This is so easy and it’s easier to do upgrades and stuff. It was a bit tricky to have it allow me to spawn two polyominos as the touch was only wanting to recognize the last one spawned. But after a bunch of debugging I fixed it by just doing an original_position_1 and originale_position_2 type variable. And then duplicated the same code for each. It’s not pretty but it works. If I need to ever spawn more than 2 I’ll need to rethink the logic here.

I plan for that to be a “relic” type upgrade. You start by only getting one polyomino to select. But via an upgrade you can start to get two to select and even two to place.

Also I now have an easy way to reset them based on what they are touching. Another relic will allow you to overwrite the polyomino that is under it but at first you won’t be able to replace an already played polyomino.

local forbidden_tile_ids = {2, 3, 4, 5, 6, 10, 11, 12, 13, 14, 17, 29, 30, 40, 44, 45}
local polyomino_tile_ids = {44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59}

function is_position_valid(self)
	for _, pos in ipairs(self.new_positions) do
		local tile_id = tilemap.get_tile("/tilemap#map1", "game_layer", pos.x, pos.y)
		if contains(forbidden_tile_ids, tile_id) then
			return false
		end
		--later I will add a flag to allow this to be skipped if the player had a certain relic that allows it
		if contains(polyomino_tile_ids, tile_id) then
			return false
		end
	end
	return true
end

The trees and rocks and grass are all forbiden_tile_ids. You can’t place tiles there. Also other polyomino tiles are not allowed to be covered (unless you have a relic…code is coming later). So this works nicely for me.

Also all graphics are just temp graphics to get the base game play down.

2 Likes