import pygame import random import core.view from model import Fish, Shark class FishSprite(core.view.AgentSprite): def draw(self): self.image.fill((0, 255, 128)) pygame.draw.circle(self.image, (random.randint(0, 255), random.randint(0, 100), 255), (5*self.zoom, 5*self.zoom), 4*self.zoom, 0) class SharkSprite(core.view.AgentSprite): def draw(self): self.image.fill((255, random.randint(0, 100), random.randint(0, 100))) class WatorView(core.view.SDLView): def show_agent(self, agent): if isinstance(agent, Fish): FishSprite(agent, self.agent_sprites, self.zoom) elif isinstance(agent, Shark): SharkSprite(agent, self.agent_sprites, self.zoom) def render(self): self.update_agents() core.view.SDLView.render(self)