Skip to main content
  1. /classes/
  2. Classes, Spring 2024/
  3. CS 2370 Spring 2024: Course Site/

cs2370 Notes: 22 Going too Far with Objects

·38 words·1 min·

Interfaces vs Inheritence

Animals:

class Bat:
    image = "bat.png"
    
    def __init__(self):
        self.sprite = ... construct sprite
    
    def moveTo(self, x, y):
        self.sprite.update(...)

    def draw(self):
        self.sprite.draw()
    
    def hit(self, x, y):
        # circle as bounding box
    
    def tick(self, x, y):
        pass
Nat Tuck
Author
Nat Tuck