To much gap between last commit
Im now working next on shoorting for turret Added new sand map and new cannon tower images aswell as function to play animations, showing range, placing turrets on allowed tiles for towers Buy and cancel button to buy towers
This commit is contained in:
+13
-2
@@ -2,7 +2,7 @@ import pygame as pg
|
||||
|
||||
class Camera():
|
||||
def __init__(self):
|
||||
self.zoom = 1
|
||||
self.zoom = 2
|
||||
self.offset = pg.math.Vector2(0, 0)
|
||||
|
||||
def world_to_screen(self, pos):
|
||||
@@ -23,4 +23,15 @@ class Camera():
|
||||
|
||||
def change_zoom(self, amount):
|
||||
self.zoom += amount
|
||||
self.zoom = max(0.5, min(self.zoom, 4.0))
|
||||
self.zoom = max(0.5, min(self.zoom, 4.0))
|
||||
|
||||
|
||||
def zoom_offset(self, screen_pos, zoom_factor):
|
||||
world_before = self.screen_to_world(screen_pos)
|
||||
|
||||
self.change_zoom(zoom_factor)
|
||||
|
||||
world_after = self.screen_to_world(screen_pos)
|
||||
|
||||
self.offset.x += world_before[0] - world_after[0]
|
||||
self.offset.y += world_before[1] - world_after[1]
|
||||
Reference in New Issue
Block a user