1. Port your implementation of assignment 4 to Python. (Mario, the tubes, fireballs, and Goombas should all behave as in your other versions. Don't worry about porting the AI.) Here's some starter code. If you save it to a file named "", then you can execute it with the command "python".
    import pygame
    import time
    from pygame.locals import*
    from time import sleep
    class Model():
    	def __init__(self):
    		self.dest_x = 0
    		self.dest_y = 0
    	def update(self):
    		if self.rect.left < self.dest_x:
    			self.rect.left += 1
    		if self.rect.left > self.dest_x:
    			self.rect.left -= 1
    		if < self.dest_y: += 1
    		if > self.dest_y: -= 1
    	def set_dest(self, pos):
    		self.dest_x = pos[0]
    		self.dest_y = pos[1]
    class View():
    	def __init__(self, model):
    		screen_size = (800,600)
    		self.screen = pygame.display.set_mode(screen_size, 32)
    		self.turtle_image = pygame.image.load("turtle.png")
    		self.model = model
    		self.model.rect = self.turtle_image.get_rect()
    	def update(self):    
    	        self.screen.blit(self.turtle_image, self.model.rect)
    class Controller():
    	def __init__(self, model):
    		self.model = model
    		self.keep_going = True
    	def update(self):
    		for event in pygame.event.get():
    			if event.type == QUIT:
    				self.keep_going = False
    			elif event.type == KEYDOWN:
    				if event.key == K_ESCAPE:
    					self.keep_going = False
    			elif event.type == pygame.MOUSEBUTTONUP:
    		keys = pygame.key.get_pressed()
    		if keys[K_LEFT]:
    			self.model.dest_x -= 1
    		if keys[K_RIGHT]:
    			self.model.dest_x += 1
    		if keys[K_UP]:
    			self.model.dest_y -= 1
    		if keys[K_DOWN]:
    			self.model.dest_y += 1
    print("Use the arrow keys to move. Press Esc to quit.")
    m = Model()
    v = View(m)
    c = Controller(m)
    while c.keep_going:


  1. Q: I'm getting a message about "pygame" not being found. What can I do about that? A: Oh yeah, I used a package called "pygame". I think you have to use "pip" to install it. I don't remember the exact command right now, but I'm sure you could find it using a search engine.