-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcamera.py
32 lines (23 loc) · 789 Bytes
/
camera.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import config
class Camera:
def __init__(self):
self.pos = [0, 0]
self.zoom = 1
def setPos(self, pos):
self.pos = list(pos)
def adjustPos(self, x, y):
self.pos[0] += x
self.pos[1] += y
def adjustZoom(self, amt):
self.zoom = max(self.zoom + amt, 0)
def wts(self, pos):
# wts = world to screen
return (pos[0] + self.pos[0], pos[1] + self.pos[1])
def wtsRect(self, rect):
return [rect[0] + self.pos[0], rect[1] + self.pos[1], rect[2], rect[3]]
def stw(self, pos):
# stw = screen to world
return (pos[0] - self.pos[0], pos[1] - self.pos[1])
def stwRect(self, rect):
return [rect[0] - self.pos[0], rect[1] - self.pos[1], rect[2], rect[3]]
GAMECAM = Camera()