Skip to content

Commit 69b8264

Browse files
committed
fixed static methods
1 parent 94511f1 commit 69b8264

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

Magic_AI_Storybook/book.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,8 @@ def __init__(self, x, y, image, action):
7777
self._width = self.image.get_width()
7878
self._height = self.image.get_height()
7979

80-
def is_in_bounds(self, x, y):
80+
def is_in_bounds(self, position):
81+
x, y = position
8182
return (
8283
self.x <= x <= self.x + self.width and self.y <= y <= self.y + self.height
8384
)
@@ -184,6 +185,8 @@ def handle_events(self):
184185
# If clicked in text area and book is still rendering, skip to the end
185186
print(f"Left mouse button pressed at {event.pos}")
186187
# If button pressed while visible, trigger action
188+
if self.back_button.is_in_bounds(event.pos):
189+
self.back_button.action()
187190
elif event.type == pygame.MOUSEBUTTONUP:
188191
# Not sure if we will need this
189192
print("Mouse button has been released")
@@ -345,7 +348,8 @@ def display_page_text(self):
345348
self.add_page(paragraph_number, word_number)
346349
return
347350

348-
def create_transparent_buffer(self, size):
351+
@staticmethod
352+
def create_transparent_buffer(size):
349353
if isinstance(size, (tuple, list)):
350354
(width, height) = size
351355
elif isinstance(size, dict):
@@ -374,7 +378,8 @@ def render_title(self):
374378

375379
return new_buffer
376380

377-
def wrap_text(self, text, font, width):
381+
@staticmethod
382+
def wrap_text(text, font, width):
378383
lines = []
379384
line = ""
380385
for word in text.split(" "):

0 commit comments

Comments
 (0)