preload images at the start to feel snappier

This commit is contained in:
2026-10-09 11:17:09 -04:00
parent 8d742b89cf
commit 5eefcd9f3b
2 changed files with 40 additions and 5 deletions
+39 -4
View File
@@ -27,6 +27,35 @@ gmouseY = 0
# the data source (TSV path, save path) can change without touching gameplay.
# =============================================================================
#hopefully this will help with lag
def preLoadImages(app):
print("PRELOADING images")
IMAGES = [
"fail",
"fisherman",
"salesman",
"surprise",
"bait-icons/bass",
"bait-icons/prawn",
"bait-icons/tuna",
"bait-icons/worm",
"fish/aubrey-fish",
"fish/bone-fish",
"fish/book",
"fish/hammerhead",
"fish/lobster",
"fish/mudge-fish",
"fish/pufferfish",
"fish/rainbow-fish",
"fish/shrimp",
"fish/turtle"
]
for img_name in IMAGES:
print("loading: " + BASE_IMAGE_URL + img_name + ".png")
drawImage(BASE_IMAGE_URL + img_name + ".png", 0, 0, visible=False)
def loadCreatures(path="creatures.tsv"):
# Read creatures.tsv (tab-separated) and parse it into a usable structure.
# Suggested return: a list of dicts, one per creature, with keys matching
@@ -120,7 +149,6 @@ def onAppStart(app):
# - skill-check state placeholders (cursor angle, bars, speed, result)
# - app.stepsPerSecond for the game loop cadence
# Delegates to the smaller setup helpers below to keep this readable.
app.debug = True
#DRAWING CONSTANTS
@@ -374,13 +402,14 @@ def onKeyPress(app, key):
#decidedly unused for now, i prefer mouse-only. ill keep the definition here in case i need debug tools.
if key == "escape":
writeSave(app.save)
os._exit(0) #suggested by AI, instantly exits without hanging like sys.exit(0)
# DEBUG
if not app.debug: return
if key == "m":
app.save["cash"] = 1000000
if key == "escape":
writeSave(app.save)
os._exit(0) #suggested by AI, instantly exits without hanging like sys.exit(0)
if key == "r":
#reset save
app.save = loadSave("thisisntarealsavefile.stupid")
@@ -514,6 +543,9 @@ def redrawAll(app):
# - the active skill-check overlay, or
# - the catch-display popup.
# Delegates each piece to the helpers below.
if(app.timeSinceInit < 1):
preLoadImages(app)
drawBackground(app)
if app.scene == "waiting-for-bite":
drawBobber(app)
@@ -732,6 +764,9 @@ def drawDebug(app):
for i in range(len(debugLines)):
drawLabel(debugLines[i], 0, app.height - 125 + size * i, fill="white", size=size, align = "left")
#debug keys
drawLabel("' m ' = give cash, ' r ' = reset save, ' f ' = skip fishing timer, ' d ' = trigger breakpoint", 5, 5, size=12, align = "top-left")
# =============================================================================
# SECTION 6: PROGRAM ENTRY