mirror of
https://github.com/csd4ni3l/connect-the-current.git
synced 2026-01-01 04:13:41 +01:00
Commit from game template + added basic power line and difficulty selector
This commit is contained in:
33
game/power_line.py
Normal file
33
game/power_line.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import arcade, arcade.gui
|
||||
|
||||
from utils.preload import button_texture, button_hovered_texture
|
||||
from utils.constants import button_style
|
||||
|
||||
from typing import Literal
|
||||
|
||||
ROTATIONS = ["right", "down", "left", "up"]
|
||||
|
||||
class PowerLine(arcade.gui.UITextureButton):
|
||||
def __init__(self):
|
||||
super().__init__(text="--->", style=button_style, texture=button_texture, texture_hovered=button_hovered_texture)
|
||||
|
||||
self.rotation: Literal["right", "down", "left", "up"] = "right"
|
||||
|
||||
self.on_click = lambda e: self.next_rotation()
|
||||
|
||||
def next_rotation(self):
|
||||
current_index = ROTATIONS.index(self.rotation)
|
||||
|
||||
if current_index + 1 == len(ROTATIONS):
|
||||
self.rotation = ROTATIONS[0]
|
||||
else:
|
||||
self.rotation = ROTATIONS[current_index + 1]
|
||||
|
||||
if self.rotation == "up":
|
||||
self.text = "^"
|
||||
elif self.rotation == "down":
|
||||
self.text = "ˇ"
|
||||
elif self.rotation == "left":
|
||||
self.text = "<---"
|
||||
elif self.rotation == "right":
|
||||
self.text = "--->"
|
||||
Reference in New Issue
Block a user