CS21 Lab 11: Extra Challenge: Neko Swatsumi with Zelle Graphics
For those of you who love graphics and/or cats, we salute you!
The code and images should be extracted to your labs/11 folder!
background, cats, and items
We have created images to represent the scene, cats, and items for you.
In nekoatsumi-graphics.py
, we give you the skeleton for the graphics
version of the game. To complete it, you need to implement the
following functions:
-
shop(store, yard,fishes)
-
show(album)
-
update (same implementation as your code assignment)
-
makeTextButton (same implementation as in assignment 6: blobilism)
-
clickInButton (same implementation as in assignment 6: blobilism)
If you’ve completed the main assignment, you do not need to write any
new code for the main window the work. Copy your implementations for
makeTextButton and clickInButton to buttonUtils.py
. Then copy your
implementation of update
to nekoatsumi-graphics.py
.
Cat images have the naming convention <Cat Name>-<Item Name>.gif
.
Items have the naming convention Item-<Item Name>.gif
. Feel free
to add your own cats and items. Images should be in the /images directory.
Then add your new cats and items to cats-graphics.txt
and items-graphics.txt
respectively.
Shop graphics
If you re-use your assignment code, you can use the console to shop.
To display the shop visually, create a new zelle window in the shop
function.
shopWin = GraphWin("Shop", 600, 600)
for item in store.items:
# Create text objects, images, button for item
pos = shopWin.getMouse()
# check if the user clicks a button
# if desired: use a while loop to wait until the close button is clicked
The coordinates are given relative to the top (x,y) corner of each item panel. For example, the first item has its corner at (10,20). The first item’s image is at location (10,20) + (70,50). By using coordinates relative to the corner, you can create panels using a for loop over each item.
Album graphics
If you re-use your assignment code, you can print the album of cats to the console. To display the album visually, create a new zelle window and draw panels for each cat
catWin = GraphWin("Cat Album", 600, 640)
for cat in album:
# Create text objects and images to display each cat
# if desired: use a while loop to wait until the close button is clicked