Added alot of things, waypoints, grid for editor, game camera system, enemy moving on pre defined waypoint (path)
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import pygame as pg
|
||||
|
||||
class Camera():
|
||||
def __init__(self):
|
||||
self.zoom = 1
|
||||
self.offset = pg.math.Vector2(0, 0)
|
||||
|
||||
def world_to_screen(self, pos):
|
||||
return (
|
||||
int((pos[0] - self.offset.x) * self.zoom),
|
||||
int((pos[1] - self.offset.y) * self.zoom)
|
||||
)
|
||||
|
||||
def screen_to_world(self, pos):
|
||||
return (
|
||||
pos[0] / self.zoom + self.offset.x,
|
||||
pos[1] / self.zoom + self.offset.y
|
||||
)
|
||||
|
||||
def move(self, dx, dy):
|
||||
self.offset.x += dx
|
||||
self.offset.y += dy
|
||||
|
||||
def change_zoom(self, amount):
|
||||
self.zoom += amount
|
||||
self.zoom = max(0.5, min(self.zoom, 4.0))
|
||||
Reference in New Issue
Block a user