py_yugi_clone/scripts/camera.py

20 lines
778 B
Python

import pygame
import numpy as np
from scripts.utils import to_isometric_pixel
class CameraPlayerLess:
def __init__(self, game, scroll = np.array([0.,0.])):
self.scroll = scroll
self.game = game
def update(self, delta):
self.scroll += delta
class Camera(CameraPlayerLess):
#def __init__(self, game, scroll = np.array([0.,0.])):
# self.scroll = scroll
# self.game = game
def update(self):
super().update((to_isometric_pixel(self.game.player.pos-np.array([48,80]))*np.array([1,0.5]) - np.array(self.game.display.get_size())/2 - self.scroll)/30)
#self.scroll += (to_isometric_pixel(self.game.player.pos-np.array([48,80]))*np.array([1,0.5]) - np.array(self.game.display.get_size())/2 - self.scroll)/30