Skip to content

Commit

Permalink
fix: idle game kinda working
Browse files Browse the repository at this point in the history
needs frame rate upgrade. ('area refresh' anyone?) Also needs better graphics...
  • Loading branch information
mariobodemann authored and Mario Bodemann committed May 21, 2024
1 parent f9d843a commit 47beac5
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 15 deletions.
Binary file modified zehardware/resources/idle_resources.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 35 additions & 15 deletions zehardware/src/app_developer_idle_clicker.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, name: str, costs: list[int], output: int, index: int):
Item("switch one class from java to kotlin", [320], 2, 7),
]

_SYMBOL_PIXEL_SIZE = 8
_SYMBOL_PIXEL_SIZE = 16
_SCREEN_WIDTH = 296
_SCREEN_HEIGHT = 128
_HORIZONTAL_SYMBOL_COUNT = 17
Expand Down Expand Up @@ -75,7 +75,6 @@ def __init__(self, os: zeos.ZeBadgeOs):
self.lines_of_code = 0
self.needs_refresh = True

# TODO: REMOVE ME ONCE VISUALIZATION IS FINE
self.inventory: list[Item] = [_ITEMS_[0]]

self._subscription_ids = []
Expand Down Expand Up @@ -109,12 +108,32 @@ def _buttons_changed(self, changed_keys):
self._up_released()
if 'down' in changed_keys and not changed_keys['down']:
self._down_released()
if 'c' in changed_keys and not changed_keys['c']:
self._refresh()

def _up_released(self):
self.needs_refresh = True
# replace with function or something
item = _ITEMS_[0]

# replace with cost calculation function
cost = item.costs[0]

if self.lines_of_code > cost:
self.lines_of_code -= cost
self.inventory += [item]
self.needs_refresh = True

def _down_released(self):
self.needs_refresh = True
# replace with function or something
item = _ITEMS_[-1]

# replace with cost calculation function
cost = item.costs[0]

if self.lines_of_code > cost:
self.lines_of_code -= cost
self.inventory += [item]
self.needs_refresh = True

def _refresh(self):
group = displayio.Group()
Expand All @@ -138,17 +157,6 @@ def _refresh(self):
)
group.append(symbol)

# symbol = item.symbol
# symbol = f"{index:03d}"
# text_area = label.Label(
# font,
# text=symbol,
# color=0xFFFFFF,
# )
#
#
# group.append(text_area)

score_area = label.Label(
font,
scale=2,
Expand All @@ -161,6 +169,18 @@ def _refresh(self):
score_area.y = 113
group.append(score_area)

purchase_labels = label.Label(
font,
scale=1,
text=f"p:\n\n\n\nx:",
anchor_point=(0.5, 0.5),
background_color=0x000000,
color=0xFFFFFF,
)
purchase_labels.x = 296 - 15
purchase_labels.y = int(128 / 4)
group.append(purchase_labels)

self.os.messages.append(Message(ui.MessageKey.SHOW_GROUP, group))
self.needs_refresh = False

Expand Down

0 comments on commit 47beac5

Please sign in to comment.