CSC 127A Lecture Notes - Lecture 31: Init
Document Summary
Rock stays still because it is a rock: basic critter. If the critter runs into the food (dot) it will have an eat function: return true or false if it eats. In order to make any of the critter classes work, be sure to import. Add the critter to the end of the class names in the main while. If the critter cannot find the critter, it will default to a question mark. Tick = move one space at a time. To reference other meathods inside the class, use the __init__(self: def __init__(self): self. fought = false def getcolor(self): if(not self. fought): else: return (cid:498)blue(cid:499) return (cid:498)red(cid:499) # this class represents a rock type of critter. # it stays still, doesn"t eat and pounces for an attack from critter import * class rock(critter): # returns that it doesn"t eat def eat(self): return false. # always pounces when attacked def fight(self, opponent): return attack_pounce. # displays as black def get_color(self): return black