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

Isometric map with collision layer does not render #546

Closed
mfpierre opened this issue Aug 4, 2014 · 10 comments
Closed

Isometric map with collision layer does not render #546

mfpierre opened this issue Aug 4, 2014 · 10 comments
Milestone

Comments

@mfpierre
Copy link

mfpierre commented Aug 4, 2014

Hi,

On MelonJS 1.1.0-beta.1, isometric map with a collision layer does not render anymore. There is an error on the GetTile function.

Cannot read property '2.734375' of undefined

If I remove the collision layer from the TMX file, the map is rendered normally.

@mfpierre mfpierre changed the title Isometric map with collision layer do not render Isometric map with collision layer does not render Aug 4, 2014
@parasyte
Copy link
Collaborator

parasyte commented Aug 5, 2014

@mfpierre Nice find, thank you!

@obiot, This looks like your bug: febe231 Originally from: #537

@obiot
Copy link
Member

obiot commented Aug 5, 2014

This one is on me, looks like a stupid mistake where I forgot to floor the value after i changed the function ... I'll fix that within 1 hour and will post you a patch here.

Thank you for the report !!

@obiot obiot added this to the 1.1.0 milestone Aug 5, 2014
@obiot
Copy link
Member

obiot commented Aug 5, 2014

@mfpierre done, if you could apply the same changes on your side (or pull the last commit if you cloned the repo) and confirm it is now working back, that would be great !

@parasyte I'm still unsure of what is the right thing to do with all these function when calculating the tile position based on x/y coordinates, and where the final value should be rounded/ceiled : do we let the the function returns a float (like now), or do we floor or round or ceil it by default ?

(note: when TMXLayer is drawing the given rect, the renderer floors the value for the top-left coordinates, but ceils them for the bottom-right ones)

@parasyte
Copy link
Collaborator

parasyte commented Aug 5, 2014

That's pretty weird. It should really be flooring all sub-pixel values, or you get weird artifacts during scrolling. The only time the floor-upper-left/ceil-bottom-right thing will help is when you have rectangles that are going to be less than 1px wide or high.

And actually the renderer can handle sub-pixel draw destinations, and is preferable for smooth scrolling at frequencies that aren't evenly divisible by the frame rate. If that makes sense ... The easiest way to imagine is a slow scroll that shifts the map position by a fraction of a pixel per frame. Instead of a nice smooth scroll with antialiasing, it will move by one pixel at a time with several frames of pause between each.

@obiot
Copy link
Member

obiot commented Aug 5, 2014

well the only place where i'm really ceiling the value is at the following place :
https://github.com/melonjs/melonJS/blob/master/src/level/TMXRenderer.js#L111
to make sure that I fill the whole given rect :
https://github.com/melonjs/melonJS/blob/master/src/level/TMXRenderer.js#L105

but this might be unnecessary extra protection.....

Then about sub-pixel yes, but i'm not sure i'm getting your point as anyway we use a double array internally to store all tiles, and we cannot use a floating value when accessing it. Also is sub-pixel not a performance killer on some browser (it used to be on Safari in a massive way)

@mfpierre
Copy link
Author

mfpierre commented Aug 5, 2014

@obiot Thanks for the quick fix, I can confirm it's working on my side, the map is now rendered properly 👍

However I seem to have another issue with the same function when moving the player around, I will try to identify it

Cannot read property '-1' of undefined 

@obiot
Copy link
Member

obiot commented Aug 5, 2014

@mfpierre Thanks ! (Merci Pierre?)

they are certainly some limit test missing in the getTile function, as if the given coordinates are out of the map size, it should just return null :
https://github.com/melonjs/melonJS/blob/master/src/level/TMXLayer.js#L496

@mfpierre
Copy link
Author

mfpierre commented Aug 5, 2014

@obiot De rien ;)

You were right, it occurs when the player goes out of the map boundaries.

@obiot
Copy link
Member

obiot commented Aug 11, 2014

shall I close this one, about the last point (out of map boundaries) this will be fixed in the next release through ticket #538, I'm not sure then that we should fix it here, except if this is really a blocking point for you (@mfpierre) ?

@mfpierre
Copy link
Author

@obiot no it's fine I'm closing the issue

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

No branches or pull requests

3 participants