py_yugi_clone/scripts/entities.py

16 lines
491 B
Python
Raw Normal View History

2024-07-10 20:08:18 +02:00
import pygame
import numpy as np
class Entity:
def __init__(self, game, e_type, pos, size):
self.game = game
self.type = e_type
self.pos = np.array(pos)
self.size = size
self.velocity = np.array([0,0], dtype=np.float32)
def update(self, movement = np.array([0,0])):
frame_movement = self.velocity + movement
self.pos += frame_movement
def render(self, surface):
surface.blit(self.game.assets[self.type], self.pos)