def set_game(self): self.board = [[" " for i in range(self.N)] for j in range(self.M)] self.scr.fill(RGB_WHITE) self.generate_maze() self.draw_board() self.D = donkey(self, (self.space_h - 1, 1), "D") self.P.i, self.P.j = self.M - 2, 1 # Place player self.update_cell(self.M - 2, 1, "P") # Place donkey self.D.set_bounds(1, self.opening + 3) self.update_cell(self.space_h - 1, 4, "D") self.update_lives(3) self.update_score(self.P.score)
def main(): import os from time import sleep from random import randint plr=player() while True: fl=0 plr.checkdeath() plr.initpos() brd=board() don=donkey() b1=[ball(don)] brd.printboard(plr,don,b1) while True: plr.checkqueen() fl=plr.checkdonkey(don,fl) if fl==1: break fl=plr.checkball(b1,fl) if fl==1: break if randint(0,randint(3,6))==1: b1+=[ball(don)] plr=player.checkfall(plr,brd,don,b1) mv=getchar() if mv==' ': plr=plr.jump(brd,don,b1) else: plr=plr.getdir(mv) plr=plr.move(plr,brd,0,mv) for i in b1: i=i.move(brd) don=don.move(brd) brd.printboard(plr,don,b1) if fl==1: continue
def __donkeyLoader(self): """Loads donkies on the screen according to level""" for i in range(self._level + 1): DonkeyKong = donkey(self.donkeyx[self._level][i], \ self.donkeyy[self._level][i], self._level, i+1) self._DonkeyList.add(DonkeyKong)