preload images at the start to feel snappier
This commit is contained in:
@@ -27,6 +27,35 @@ gmouseY = 0
|
|||||||
# the data source (TSV path, save path) can change without touching gameplay.
|
# 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"):
|
def loadCreatures(path="creatures.tsv"):
|
||||||
# Read creatures.tsv (tab-separated) and parse it into a usable structure.
|
# Read creatures.tsv (tab-separated) and parse it into a usable structure.
|
||||||
# Suggested return: a list of dicts, one per creature, with keys matching
|
# 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)
|
# - skill-check state placeholders (cursor angle, bars, speed, result)
|
||||||
# - app.stepsPerSecond for the game loop cadence
|
# - app.stepsPerSecond for the game loop cadence
|
||||||
# Delegates to the smaller setup helpers below to keep this readable.
|
# Delegates to the smaller setup helpers below to keep this readable.
|
||||||
|
|
||||||
app.debug = True
|
app.debug = True
|
||||||
|
|
||||||
#DRAWING CONSTANTS
|
#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.
|
#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
|
# DEBUG
|
||||||
if not app.debug: return
|
if not app.debug: return
|
||||||
if key == "m":
|
if key == "m":
|
||||||
app.save["cash"] = 1000000
|
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":
|
if key == "r":
|
||||||
#reset save
|
#reset save
|
||||||
app.save = loadSave("thisisntarealsavefile.stupid")
|
app.save = loadSave("thisisntarealsavefile.stupid")
|
||||||
@@ -514,6 +543,9 @@ def redrawAll(app):
|
|||||||
# - the active skill-check overlay, or
|
# - the active skill-check overlay, or
|
||||||
# - the catch-display popup.
|
# - the catch-display popup.
|
||||||
# Delegates each piece to the helpers below.
|
# Delegates each piece to the helpers below.
|
||||||
|
if(app.timeSinceInit < 1):
|
||||||
|
preLoadImages(app)
|
||||||
|
|
||||||
drawBackground(app)
|
drawBackground(app)
|
||||||
if app.scene == "waiting-for-bite":
|
if app.scene == "waiting-for-bite":
|
||||||
drawBobber(app)
|
drawBobber(app)
|
||||||
@@ -732,6 +764,9 @@ def drawDebug(app):
|
|||||||
for i in range(len(debugLines)):
|
for i in range(len(debugLines)):
|
||||||
drawLabel(debugLines[i], 0, app.height - 125 + size * i, fill="white", size=size, align = "left")
|
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
|
# SECTION 6: PROGRAM ENTRY
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"cash": 906214.0, "owned_baits": ["Worms", "Prawns", "Tuna", "Bass"], "owned_upgrades": ["Massive Bobber", "Huge Bobber", "Large Bobber", "Medium Bobber", "Galaxy Rod", "Glowing Rod", "Spectral Rod", "Shiny Rod"], "current_bait": "Bass"}
|
{"cash": 44.0, "owned_baits": ["Worms"], "owned_upgrades": [], "current_bait": "Worms"}
|
||||||
Reference in New Issue
Block a user