mirror of
https://github.com/csd4ni3l/connect-the-current.git
synced 2026-01-01 04:13:41 +01:00
Add textured lines and fix directions, add back buttons, remove unused imports
This commit is contained in:
14
game/play.py
14
game/play.py
@@ -1,7 +1,8 @@
|
||||
import arcade, arcade.gui, pyglet
|
||||
import arcade, arcade.gui
|
||||
|
||||
from utils.constants import button_style
|
||||
from utils.preload import button_texture, button_hovered_texture
|
||||
|
||||
from game.power_line import PowerLine
|
||||
|
||||
class Game(arcade.gui.UIView):
|
||||
@@ -9,7 +10,7 @@ class Game(arcade.gui.UIView):
|
||||
super().__init__()
|
||||
|
||||
self.pypresence_client = pypresence_client
|
||||
self.pypresence_client.update(state="In Game")
|
||||
self.pypresence_client.update(state='In Game', start=self.pypresence_client.start_time)
|
||||
|
||||
self.difficulty = difficulty
|
||||
|
||||
@@ -17,10 +18,17 @@ class Game(arcade.gui.UIView):
|
||||
self.grid_size = list(map(int, difficulty.split("x")))
|
||||
self.power_grid = self.anchor.add(arcade.gui.UIGridLayout(horizontal_spacing=0, vertical_spacing=0, row_count=self.grid_size[0], column_count=self.grid_size[1]))
|
||||
|
||||
|
||||
def on_show_view(self):
|
||||
super().on_show_view()
|
||||
|
||||
self.back_button = arcade.gui.UITextureButton(texture=button_texture, texture_hovered=button_hovered_texture, text='<--', style=button_style, width=100, height=50)
|
||||
self.back_button.on_click = lambda event: self.main_exit()
|
||||
self.anchor.add(self.back_button, anchor_x="left", anchor_y="top", align_x=5, align_y=-5)
|
||||
|
||||
for row in range(self.grid_size[0]):
|
||||
for col in range(self.grid_size[1]):
|
||||
self.power_grid.add(PowerLine(), row=row, column=col)
|
||||
|
||||
def main_exit(self):
|
||||
from menus.main import Main
|
||||
self.window.show_view(Main(self.pypresence_client))
|
||||
@@ -1,33 +1,26 @@
|
||||
import arcade, arcade.gui
|
||||
|
||||
from utils.preload import button_texture, button_hovered_texture
|
||||
from utils.constants import button_style
|
||||
from utils.preload import vertical_connected, vertical_unconnected, horizontal_connected, horizontal_unconnected
|
||||
|
||||
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)
|
||||
super().__init__(texture=vertical_unconnected)
|
||||
|
||||
self.rotation: Literal["right", "down", "left", "up"] = "right"
|
||||
self.rotation: Literal["vertical", "horizontal"] = "vertical"
|
||||
self.connected = False
|
||||
|
||||
self.on_click = lambda e: self.next_rotation()
|
||||
|
||||
def next_rotation(self):
|
||||
current_index = ROTATIONS.index(self.rotation)
|
||||
if self.rotation == "vertical":
|
||||
self.rotation = "horizontal"
|
||||
self.texture = horizontal_connected if self.connected else horizontal_unconnected
|
||||
self.texture_hovered = horizontal_connected if self.connected else horizontal_unconnected
|
||||
elif self.rotation == "horizontal":
|
||||
self.rotation = "vertical"
|
||||
self.texture = vertical_connected if self.connected else vertical_unconnected
|
||||
self.texture_hovered = vertical_connected if self.connected else vertical_unconnected
|
||||
|
||||
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 = "--->"
|
||||
self._requires_render = True
|
||||
Reference in New Issue
Block a user