Coding Day 5: Managing Data and Object interaction

I didn’t do a lot today, but I did create some more interactivity for my Virtual Pet.  I want my pet to look different based on his mood.  I had already accomplished making it look like it was sleeping, but to do so, I had repeated a lot of code, so I needed to figure out what to return from the method that drew the pet in the first place.  I started by returning just the head graphic, but, then I got to the point where I needed to interact with more than just the head.  I ended up creating a dictionary and then storing each graphic object (head, mouth, etc.) in the dictionary with a string identifier as the key.  Then, if I want to interact with that object, I just pull it from the dictionary.  It works so far with the sleeping pet, but I created a bored pet where he is supposed to yawn.  That’s not working, and I’m not sure why.  The old mouth won’t go away, and the new one won’t draw either.  Once I have that working, I’ll have the others working.  And then maybe I’ll tackle saving the game.

Leave a Reply

Your email address will not be published. Required fields are marked *