Code Monkey home page Code Monkey logo

Comments (5)

straker avatar straker commented on May 10, 2024 1

Would setting ctx.scale before drawing work?

The main problem is that only the TileEngine is set up with a "camera" setting to handle larger maps (and it's just there to tell it where to start drawing the map), but there isn't anything in the rest of the library that understands that since most of the time the library has you do everything (like when to draw things and in what order). Having a system that understands camera, viewport, and scale would need to communicate that info to every sprite and tilemap.

As such, I'm not sure it fits in the system as it would require too much interdependency. You could try making it a plugin though, or maybe a sub-system that can work with Kontra.

from kontra.

straker avatar straker commented on May 10, 2024

I'm not sure I quite follow. Is the idea similar to what TileMap does with its sx and sy properties for larger maps?

from kontra.

Rayne avatar Rayne commented on May 10, 2024

If I understand the request correctly, it would add an option to zoom in and out of the map by defining a custom viewport width and height.

from kontra.

straker avatar straker commented on May 10, 2024

So with the most recent update to the library, Sprites now understand camera positions using sx and sy. You can add objects to the tile engine and it will sync the camera position to the sprite so the sprite will draw itself in the correct spot even while the camera moves.

This now opens the door for viewport control as moving all the sprites would be just a matter of setting all their sx and sy positions.

from kontra.

straker avatar straker commented on May 10, 2024

Closed via #169

from kontra.

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.