def coinLife(self): self.appearsFor -= 1 if self.appearsFor == 0: shadowMatrix(self.row, self.col) coins.remove(self) return 1 return 0
def happilyEverAfter(self): os.system('aplay smb_stage_clear.wav&') print("Thanks for playing!") for i in range(9): shadowMatrix(self.row, self.col) self.col += 1 # time.sleep(0.4) fillMatrix(self)
def moveLeft(self): if self.col == 0: pass elif self.checkCollision(self.row, self.col - 1) == 2: self.dead = 1 elif self.checkCollision(self.row, self.col - 1) != 0: pass else: shadowMatrix(self.returnRow(), self.returnCol()) self.col -= 1 fillMatrix(self)
def moveRight(self): # if self.col == int(config.columns): if self.col == map_col_blocks: pass elif self.checkCollision(self.row, self.col + 1) == 2: self.dead = 1 elif self.checkCollision(self.row, self.col + 1) != 0: pass else: shadowMatrix(self.returnRow(), self.returnCol()) self.col += 1 fillMatrix(self)
def jump(self): if self.checkCollision(self.row - 1, self.col) != 0: self.inJump = False self.jumpTime = 0 elif self.jumpTime == 3: self.inJump = False self.jumpTime = 0 else: shadowMatrix(self.returnRow(), self.returnCol()) self.inJump = True self.jumpTime += 1 self.row -= 1 fillMatrix(self)
def moveDown(self): if self.checkCollision(self.row + 1, self.col) == 3 and self.code == 13: return 1 elif self.checkCollision(self.row + 1, self.col) == 0: # time.sleep(0.8) shadowMatrix(self.returnRow(), self.returnCol()) self.row += 1 fillMatrix(self) #death by canyon elif self.row > map_row_blocks - 1: self.dead = 1 return 0
def moveDown(self): #kill enemies if mario drops on a shroom or an orc if self.checkCollision(self.row + 1, self.col) == 2 and self.code == 11: if killEnemies(self.row + 1, self.col) is True: self.kills += 1 elif self.checkCollision(self.row + 1, self.col) == 0: # time.sleep(0.8) shadowMatrix(self.returnRow(), self.returnCol()) self.row += 1 fillMatrix(self) #death by canyon elif self.row > map_row_blocks - 1: self.dead = 1 return 0
def move(self, mario_xcoord): var = 0 if mario_xcoord > self.row: #go right var = 1 elif mario_xcoord < self.row: #go left var = -1 if self.checkCollision(self.row, self.col + var) == 0: shadowMatrix(self.returnRow(), self.returnCol()) self.col += var fillMatrix(self) elif self.checkCollision(self.row, self.col + var) == 3: return 1 return 0
def killEnemies(mrow, mcol): if matrix[mrow][mcol] == 12: print("found minion") #kill shroom for enemy in enemies: if enemy.returnRow() == mrow and enemy.returnCol() == mcol: os.system('aplay smb_kick.wav&') shadowMatrix(mrow, mcol) enemies.remove(enemy) return True elif matrix[mrow][mcol] == 13: # print ("found orc") # shadowMatrix(mrow, mcol) os.system('aplay smb_kick.wav&') enemy_object = mushroomMinion(mrow, mcol) fillMatrix(enemy_object) return True return False
def jump(self): # os.system('aplay smb_jump-small.wav&') #also checks if Mario lands on any enemies try: if self.checkCollision(self.row - 1, self.col) == 4: breakBricks(self.row - 1, self.col) self.inJump = False self.jumpTime = 0 elif self.checkCollision(self.row - 1, self.col) != 0: self.inJump = False self.jumpTime = 0 elif self.jumpTime == 3: self.inJump = False self.jumpTime = 0 else: shadowMatrix(self.returnRow(), self.returnCol()) self.inJump = True self.jumpTime += 1 self.row -= 1 fillMatrix(self) except IndexError: pass