Files
pixel_tower_defense/game/util.py
T

29 lines
710 B
Python

import pygame as pg
import os
img_path='assets/images'
WINDOW_SIZE=(800,600)
def load_image(path, colorkey=(0,0,0)):
img = pg.image.load(img_path + path).convert()
img.set_colorkey(colorkey)
return img
def load_images(dir_path):
images = []
for img_name in os.listdir(img_path + dir_path):
images.append(load_image(dir_path + '/' + img_name))
return images
def tile_to_pixel(waypoint, tile_size, center=False):
if center:
return (
waypoint[0] * tile_size + tile_size // 2,
waypoint[1] * tile_size + tile_size // 2
)
else:
return (
waypoint[0] * tile_size,
waypoint[1] * tile_size
)