Code Monkey home page Code Monkey logo

Comments (7)

bitinn avatar bitinn commented on August 20, 2024

I actually prefer the way gamera work, which leaves us a way to avoid float number translation.

https://github.com/kikito/gamera/blob/master/gamera.lua#L100-L106
https://github.com/kikito/gamera/blob/master/gamera.lua#L179-L181

from hump.

vrld avatar vrld commented on August 20, 2024

The problem is that hump.camera translates to a fractional position, which causes artifacts between the tiles, correct?
Rounding the position to the nearest integer by default would work, but introduces two other issues:

  1. It does only work for scale = 1, and
  2. Moving the camera becomes jittery.

A quick and dirty solution would add a parameter to camera:attach() to transform the calculated screen center, e.g. camera:attach(math.floor) - but I am not yet sure how I feel about that.

The "correct" way would be to add margins in the tile set, but as you said, that might not be practical.
Another solution might be to try the FilterMode 'nearest'.

from hump.

bitinn avatar bitinn commented on August 20, 2024

Another solution might be to try the FilterMode 'nearest'.

As far as I know STI uses nearest when loading tileset, but that doesn't seem to help. Which puzzles me.

from hump.

vrld avatar vrld commented on August 20, 2024

Can you provide a .love that shows the issue so that I can have a look myself?

from hump.

bitinn avatar bitinn commented on August 20, 2024

Actually let me close this for now, I needed a visible viewport anyway so I switched to gamera.

I don't think it's that necessary for hump.camera to support my use-case, while my project do fit into your 2 conditions (we don't scale map, we don't need smooth camera movement), I think it complicates your code quite a bit to support strict non-float position, so yeah if I ran into the issue again I will re-open this with an example .love file.

from hump.

vrld avatar vrld commented on August 20, 2024

Reopening this: defining a custom viewport when attaching the camera is straightforward to implement and should cover your use-case. Something along the lines of this:

cam:attach(20, 10, 400, 400) -- x,y,width,height
foo()
cam:detach()

from hump.

bitinn avatar bitinn commented on August 20, 2024

very cool, I will check it out when available

from hump.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.