Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion arcade/camera.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import math
from typing import TYPE_CHECKING, List, Optional, Tuple, Union

from pyglet.math import Mat4, Vec2, Vec3
from pyglet.math import Mat4, Vec2, Vec3, Vec4

import arcade
from arcade.types import Point
Expand Down Expand Up @@ -552,6 +552,12 @@ def shake(self, velocity: Union[Vec2, tuple], speed: float = 1.5, damping: float
self.shake_damping = damping
self.shaking = True

def get_map_coordinates(self, camera_vector: Union[Vec2, tuple]) -> Vec2:
x, y = camera_vector
_x, _y = (x / self.viewport_width) * 2 - 1, (y / self.viewport_height) * 2 - 1
world_vector = ~(self._combined_matrix) @ Vec4(_x, _y, 1.0, 1.0)
return Vec2(world_vector.x, world_vector.y)

def use(self) -> None:
"""
Select this camera for use. Do this right before you draw.
Expand Down