Some changes...
This commit is contained in:
27
Animation.py
Normal file
27
Animation.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import pygame
|
||||
|
||||
class Animation(object):
|
||||
def __init__(self, image, start_x, start_y, num, width, height, duration) -> None:
|
||||
self.image = image
|
||||
|
||||
self.start_x = start_x
|
||||
self.start_y = start_y
|
||||
self.num = num
|
||||
self.width = width
|
||||
self.height = height
|
||||
|
||||
self.duration = duration
|
||||
self.time = 0
|
||||
self.current = 0
|
||||
|
||||
def render(self, screen, pos):
|
||||
screen.blit(self.image, pos, pygame.Rect(self.start_x + (self.width * self.current), self.start_y, self.width, self.height))
|
||||
|
||||
def update(self, time=1):
|
||||
self.time += time
|
||||
|
||||
if self.time > self.duration:
|
||||
self.time = 0
|
||||
self.current += 1
|
||||
if self.current >= self.num:
|
||||
self.current = 0
|
||||
Reference in New Issue
Block a user