JacoBot/jacovirt/jacovirt/pad/token.py

50 lines
1.3 KiB
Python

import arcade
from importlib import resources
class Token(arcade.Sprite):
""" Token sprite """
def __init__(self, token_type, scale=1):
# Attributes for token type
self.token_type = token_type
with resources.path("jacovirt", 'Img') as img_folder :
self.image_file_name = f"{img_folder}/pad/token/{self.token_type}.png"
# Call the parent
super().__init__(self.image_file_name, scale, hit_box_algorithm="None")
class Token_generator(arcade.Sprite):
""" Token generator sprite """
def __init__(self, token_type, scale=1):
# Attributes for token type
self.type = token_type
self.image_file_name = ":resources:images/tiles/boxCrate_double.png"
self.tokens = arcade.SpriteList()
# Call the parent
super().__init__(self.image_file_name, scale, hit_box_algorithm="None")
def create_token(self, x, y):
# Create a token
token = Token(self.type)
token.position = x, y
self.tokens.append(token)
return token
def draw_tokens(self):
self.tokens.draw()
class Token_trash(arcade.SpriteSolidColor):
def __init__(self, height, width, color=arcade.color.AMERICAN_ROSE):
super().__init__(width, height, color)
def remove_token(self, held_token):
held_token.remove_from_sprite_lists()