1
0
forked from MDL29/JacoBot

Create token sprite

MDL29/JacoBot#29
This commit is contained in:
Romain 2024-04-24 10:51:33 +02:00
parent 0708cfb319
commit 8a60d943fd
2 changed files with 25 additions and 2 deletions

View File

@ -0,0 +1,16 @@
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")

View File

@ -1,6 +1,7 @@
import arcade
import jacovirt.logger
import logging
from jacovirt.pad.token import Token
# Screen title and size
SCREEN_TITLE = "Jaco Pad"
@ -24,14 +25,20 @@ class Pad(arcade.Window):
def setup(self):
"""Set up the pad"""
logging.info("Set up the pad.")
...
# Create the token
self.token = Token("up", 1*SCREEN_MULTILPLIER)
self.token.position = 500, 500
def on_draw(self):
"""Render the screen"""
# Clear the screen
self.clear()
# Draw the token
self.token.draw()
def on_key_press(self, symbol, modifiers):
"""Called when the user presses key"""
if symbol == arcade.key.R: