fill out creatures file and implement loadCreatures

This commit is contained in:
2026-10-06 23:56:14 -04:00
parent be3516f9c7
commit 9d14bc56b2
3 changed files with 37 additions and 13 deletions
+9
View File
@@ -0,0 +1,9 @@
###############################################
Prompt to Kiro AI (Default):
Response:
###############################################
+11 -11
View File
@@ -1,11 +1,11 @@
name description price sprite-file difficulty length weight
The Rainbow Fish
Pufferfish
Turtle
Shrimp
Lobster
Aubrey Fish Requested by the artist, my girlfriend.
Hammerhead Shark
Koi Fish
One Fish Two Fish Red Fish Blue Fish Yes, you caught a book.
Bone Fish
name description price sprite-file difficulty length (in) weight (lbs)
The Rainbow Fish The friendliest fish from our childhood 120 rainbow-fish.png 90 8.2 1.4
Pufferfish yeeeeowwwch!! 56 pufferfish.png 50 6.8 3.1
Turtle "Give me some fin. Noggin. Duuuude." - Crush, Finding Nemo 30 turtle.png 40 72 180
Shrimp Yeah, I'm a little small. Whaddaboutit? 18 shrimp.png 20 0.7 0.2
Lobster ROCK LOBSTERRRR OOOO OOOH 82 lobster.png 80 13.3 4.5
Aubrey Fish Requested by the artist, my girlfriend. 65 aubrey-fish.png 60 4.3 1.9
Hammerhead Shark Great for building a shed. Not so great in the ocean 150 hammerhead.png 100 120 560
Koi Fish WHO'S HOUSE?? MUDGE HOUSE!! 26 mudge-fish.png 20 10.4 1.6
One Fish Two Fish Red Fish Blue Fish Yes, you caught a book. 66 book.png 70 8.5 2
Bone Fish He must have needed saltwater... 12 bone-fish.png 10 16.1 0.8
Can't render this file because it contains an unexpected character in line 4 and column 43.
+17 -2
View File
@@ -19,14 +19,29 @@ from cmu_graphics import *
# the data source (TSV path, save path) can change without touching gameplay.
# =============================================================================
def loadCreatures(path):
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
# the header row: name, description, price, sprite-file, difficulty,
# length, weight. Convert numeric columns (price, difficulty, length,
# weight) from strings to int/float here; leave missing fields as sensible
# defaults so partially-filled rows (like the current TSV) don't crash.
pass
creatures = []
with open(path) as f:
lines = f.readlines()
for line in lines[1:]: #ignore header
data = line.split("\t")
creatures.append({
"name": data[0],
"description": data[1],
"price": float(data[2]),
"sprite-file": data[3],
"difficulty": int(data[4]),
"length": float(data[5]), #inches
"weight": float(data[6]) #pounds
})
return creatures
def loadSave(path):