forked from MDL29/JacoBot
parent
0708cfb319
commit
8a60d943fd
16
jacovirt/jacovirt/pad/token.py
Normal file
16
jacovirt/jacovirt/pad/token.py
Normal 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")
|
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue
Block a user