Yinteger / Jiggy.io

GNU General Public License v3.0
1 stars 1 forks source link

Create some object to translate page coordinates to in-game coordinates #20

Open Yinteger opened 7 years ago

Yinteger commented 7 years ago

It should be able to properly translate the canvas position in the page, which camera's output is in the position, the games fov/zoom level, and the position of the game the camera is looking at, to translate exact coordinates inside the game

breautek commented 7 years ago

Again, we have a Coordinate interface, but would it make sense to have a Coordinate class that has a XY reference point of the Viewport?

And then based on the stored XY reference, it can translate the coordinate depending on the settings of the Viewport?

Yinteger commented 7 years ago

We do now have a Coordinate class which I needed to create to easily convert Coordinates from Cartesian to Isometric. We may be able to use it to convert Screen Coordinates to 'Game' Coordinates, but this would require knowledge of the all the cameras, and the main viewport, in the game, by the Coordinate. Which imo, breaks single responsibility. The Cartesian to/from Iso calculations were just simple math.

Perhaps we need something a bit more concrete like a CoordinateConverter object or something. I'd rather keep Coordinate not dependent on much as by itself it should be a simple data abstraction object.