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:
@@ -26,3 +26,31 @@ def tile_to_pixel(waypoint, tile_size, center=False):
|
||||
waypoint[0] * tile_size,
|
||||
waypoint[1] * tile_size
|
||||
)
|
||||
|
||||
def pixel_to_tile(waypoint, tile_size):
|
||||
return (
|
||||
waypoint[0] / tile_size,
|
||||
waypoint[1] / tile_size
|
||||
)
|
||||
|
||||
class Animation:
|
||||
def __init__(self, images, img_dur=5, loop=True):
|
||||
self.images = images
|
||||
self.loop = loop
|
||||
self.img_duration = img_dur
|
||||
self.done = False
|
||||
self.frame = 0
|
||||
|
||||
def copy(self):
|
||||
return Animation(self.images, self.img_duration, self.loop)
|
||||
|
||||
def update(self):
|
||||
if self.loop:
|
||||
self.frame = (self.frame + 1) % (self.img_duration * len(self.images))
|
||||
else:
|
||||
self.frame = min(self.frame + 1, self.img_duration * len(self.images))
|
||||
if self.frame >= self.img_duration * len(self.images) - 1:
|
||||
self.done = True
|
||||
|
||||
def img(self):
|
||||
return self.images[int(self.frame / self.img_duration) - 1]
|
||||
Reference in New Issue
Block a user