Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/draw tile objects #248

Closed
wants to merge 2 commits into from
Closed

Conversation

wolf81
Copy link

@wolf81 wolf81 commented Jan 22, 2021

Fix drawing tile objects in isometric projection.

Please note this is not a perfect fix, but the result is much closer to what is shown in Tiled. A small offset seems to be required perfectly position the tile objects, but as of not I'm not really sure how this offset should be calculated. Also other objects (e.g. rectangles) in object layer seem to need some small adjustments in order for them to be shown in the proper position (however this PR only focuses on tile objects in object layers in isometric projection).

@wolf81
Copy link
Author

wolf81 commented Jan 22, 2021

I should add that the following code improves the isometric drawing even more, but I am not 100% sure if this approach is valid always, so the following code is not (yet) part of the PR.

function Map:setObjectCoordinates(layer)
   -- ...
	elseif object.shape == "rectangle" and object.gid then -- a tile object
		if self.orientation == "isometric" then
			object.x, object.y = utils.convert_isometric_to_screen(
				self, 
				object.x + self.tileheight * 2 + w / 2, 
				object.y + self.tileheight * 2
			)
		end
	end
   -- ...
end

In the above code I am not really sure why I need to add self.tileheight * 2 in order for the x and y positions to be drawn properly, which is why I didn't add that code to the PR. But locally (on my machine) I use this approach right now. However this comment also does some tile position modification and that's probably in some way related to the above fix.

By the way, this PR might fix the issues mentioned here, but not 100% sure:

@karai17
Copy link
Owner

karai17 commented Jan 22, 2021 via email

@wolf81
Copy link
Author

wolf81 commented Jan 22, 2021

Could you provide a few test maps that show this code fix working in various cases? screenshots are fine~

I'll try to add some examples tomorrow.

@wolf81 wolf81 closed this Jan 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants