def creatwall(): a=780 while True: h=1000 d=-1000 for i in data.wa: if iskey(K_UP): i.y -= 4 #time.sleep(0.01) if iskey(K_DOWN): i.y += 4 #time.sleep(0.01) try: if i.y > 800 or i.y < -600: data.wa.remove(i) except: print('無法刪除') if i.y <h: h = i.y if i.y+600 >d: d = i.y+600 if h>0: data.wa.append(wall.wall(a, h-600)) if d<800: data.wa.append(wall.wall(a,d)) time.sleep(0.01)
def main(): ############################## # M VARIABLES # ############################## # Color colors = global_Module.colors # Gets the colors from the globals game_loop = True # Used to stop the game when you want it over menu_dict = {'Start' : (INT_WIDTH / 2, (INT_HEIGHT / 6) * 3), 'Multi-player' : (INT_WIDTH / 2, (INT_HEIGHT / 6) * 4), 'Quit' : (INT_WIDTH / 2 , (INT_HEIGHT / 6) * 5)} ############################## # M INIT # ############################## pygame.init() # inits fps_clock = pygame.time.Clock() # sets the framerate clock win_screen_obj = pygame.display.set_mode(INT_SIZE) # sets the display pygame.display.set_caption('Racing Game') # sets the caption for the display userKeyboard = keyboard_mouse_Class.Keyboard() # All keyboard and mouse are handled by this main_menu = menu_Class.Menu(win_screen_obj, fps_clock, menu_dict, "ULTIMATE RACING BUTLER SIMULATOR 2015") player_sprite_group = pygame.sprite.Group() player_car = car_Class.Car() player_sprite_group.add(player_car) wall_sprite_group = pygame.sprite.Group() ############################## # M MENU CLASS # ############################## #main_menu.main() ############################## # M MAIN LOOP # ############################## while game_loop: # Game loop # Fetch info keys = userKeyboard.update() # Fetches keyboard and mouse inputs if keys['K']: rand_wall = wall.wall() wall_sprite_group.add(rand_wall) keys['K'] = False # Updates win_screen_obj.fill(colors['white']) # sets the screen color to white player_sprite_group.draw(win_screen_obj) player_sprite_group.update(keys, win_screen_obj) wall_sprite_group.draw(win_screen_obj) fps_clock.tick(FPS) # This sets the block at the fps pygame.display.update() # This updates the screen
def user_act(map, treasures, foods, user, mob, nb_mob, stdscr, win): c = stdscr.getch() end = 0 if c == ord('s') and user.y < 24: mod,mob = wall.wall(map, user.y + 1, user.x, mob, nb_mob, user, treasures, foods) if mod == 1: user.y = user.y + 1 elif mod == 2: fight.fight_user(mob, user, win, stdscr) if c == ord('w') and user.y > 0: mod,mob = wall.wall(map, user.y - 1, user.x, mob, nb_mob, user, treasures, foods) if mod == 1: user.y = user.y - 1 elif mod == 2: fight.fight_user(mob, user, win, stdscr) if c == ord('d') and user.x < 79: mod,mob = wall.wall(map, user.y, user.x + 1, mob, nb_mob, user, treasures, foods) if mod == 1: user.x = user.x + 1 elif mod == 2: fight.fight_user(mob, user, win, stdscr) if c == ord('a') and user.x > 0: mod,mob = wall.wall(map, user.y, user.x - 1, mob, nb_mob, user, treasures, foods) if mod == 1: user.x = user.x - 1 elif mod == 2: fight.fight_user(mob, user, win, stdscr) if c == ord('e'): user.hp = user.hp_max user.ration = user.ration - 1 if c == ord('z'): if (map[user.y - 1][user.x] == level.door_lvl_symbol): end = 1 if (map[user.y - 1][user.x] == pickups.treasure_symbol): user.gold = user.gold+10 if (map[user.y - 1][user.x] == pickups.food_symbol): user.hp = user.hp_max if c == ord('q'): end = 2 if c == ord('p'): end = 1 return (end)
def get_postform(self, msg="post", from_page="/", username=None): wall1 = wall.wall(username) wall1.body = \ """<form method="post" action="/post"> <input type="hidden" name="from_page" value="%(from_page)s" /> %(msg)s<br /> Post: <input type="text" name="message" /> <br /> <input type="submit" value="Post" /> """ %locals() wall1.pull(username) return wall1.return_html()
def add_walls(self, n, widthGrid, heightGrid): """ Add walls in grid. n: number of rooms horizontally widthGrid: width of the grid heightGrid: height of the grid """ widthRooms = floor(widthGrid / n) heightRooms = floor(heightGrid / n) heightHall = heightGrid - 2 * heightRooms # Add horizontal walls for i in range(n - 1): for y in range(heightRooms): brick = wall(self.num_agents, self) self.grid.place_agent(brick, ((i + 1) * widthRooms, y)) self.grid.place_agent(brick, ((i + 1) * widthRooms, y + heightRooms + heightHall)) doorWidth = 2 # Add vertical walls for x in range(widthGrid): if (x % widthRooms) < (widthRooms - doorWidth): brick = wall(self.num_agents, self) self.grid.place_agent(brick, (x, heightRooms)) self.grid.place_agent(brick, (x, heightRooms + heightHall - 1))
def setMaze(): global themap, timeout, delay themap = mazegenerator.Generate(winwidth / 48, winheight / 48) # remove exactly 10 walls timeout = (30 - level) * 50 delay = (30 - level) * 1000 for _ in range(30 - level): xx, yy = random.randint(1, len(themap[0]) - 2), random.randint( 1, len(themap) - 2) while (themap[yy][xx] == 0): xx, yy = random.randint(1, len(themap[0]) - 2), random.randint( 1, len(themap) - 2) themap[yy][xx] = 0 for y in range(len(themap)): for x in range(len(themap[y])): if themap[y][x] == 1: all_sprites_list.add(wall.wall(x, y))
def update(self): worldx = self.world.viewport[0] worldy = self.world.viewport[1] #saving/loading if ord("s") in self.world.keyspress: self.save() if ord("l") in self.world.keyspress: self.load() #scaling if self.world.mouse_scroll_up: #print(self.world.keyspress) if not ord("x") in self.world.keyspressed: self.ysize = min(5, self.ysize + 1) if not ord("y") in self.world.keyspressed: self.xsize = min(5, self.xsize + 1) #self.size=min(5,self.size+1) if self.world.mouse_scroll_down: if not ord("x") in self.world.keyspressed: self.ysize = max(1, self.ysize - 1) if not ord("y") in self.world.keyspressed: self.xsize = max(1, self.xsize - 1) if self.world.mouse_left: xx = roundup(self.world.mouse_x - 16 - worldx) yy = roundup(self.world.mouse_y - 16 - worldy) for xt in range(-self.xsize + 1, self.xsize): x = int( (xx + xt * 16) / 16 ) #clamp(int((xx+xt*16)/16),0,int(self.world.size[0]/16)) if 0 < x < int(self.world.size[0] / 16): for yt in range(-self.ysize + 1, self.ysize): y = int( (yy + yt * 16) / 16 ) #clamp(int((yy+yt*16)/16),0,int(self.world.size[1]/16)) if 0 < y < int(self.world.size[1] / 16): if self.world.walls[x][y] == None: self.world.walls[x][y] = wall( self.world, x * 16, y * 16, 16, 16) if self.world.mouse_right: xx = roundup(self.world.mouse_x - 16 - worldx) yy = roundup(self.world.mouse_y - 16 - worldy) x = int(xx / 16) y = int(yy / 16) for xt in range(-self.xsize + 1, self.xsize): x = int( (xx + xt * 16) / 16 ) #clamp(int((xx+xt*16)/16),0,int(self.world.size[0]/16)) if 0 < x < int(self.world.size[0] / 16): for yt in range(-self.ysize + 1, self.ysize): y = int( (yy + yt * 16) / 16 ) #clamp(int((yy+yt*16)/16),0,int(self.world.size[1]/16)) if 0 < y < int(self.world.size[1] / 16): if not self.world.walls[x][y] == None: del self.world.walls[x][y] self.world.walls[x].insert(y, None) '''
def update(self, bman_obj, enemy_obj, brick_obj, bomb_obj): #initializing all to empty strings self.layout[0:38][0:76] = ' ' #insert walls wall_obj = w.wall() wall_obj.insert_into(self.layout) #insert bomberman if alive if (bman_obj.lives_left >= 0): pos_tofill = p.true_pos(bman_obj.pos) #Fill 8 bytes with the bomberman for i in range(8): x = int(pos_tofill[i][0]) y = int(pos_tofill[i][1]) self.layout[x][y] = bman_obj.ch #insert enemy if alive if (enemy_obj.alive == 1): pos_tofill = p.true_pos(enemy_obj.pos) #Fill 8 bytes with the enemy for i in range(8): x = int(pos_tofill[i][0]) y = int(pos_tofill[i][1]) self.layout[x][y] = enemy_obj.ch #insert bricks all_bricks = brick_obj.pos #Array with positions of all bricks for j in all_bricks: pos_tofill = p.true_pos(j) #Fill 8 bytes with one brick for i in range(8): x = int(pos_tofill[i][0]) y = int(pos_tofill[i][1]) self.layout[x][y] = brick_obj.ch #insert bombs all_bombs = bomb_obj.pos_and_timer #Array with positions of all bombs for j in all_bombs: xc = j[0] yc = j[1] pos_tofill = p.true_pos([xc, yc]) #Fill 8 bytes with one bomb for i in (0, 4): x = int(pos_tofill[i][0]) y = int(pos_tofill[i][1]) self.layout[x][y] = '[' for i in (3, 7): x = int(pos_tofill[i][0]) y = int(pos_tofill[i][1]) self.layout[x][y] = ']' for i in (1, 2, 5, 6): x = int(pos_tofill[i][0]) y = int(pos_tofill[i][1]) self.layout[x][y] = int(j[2] / 3) #timer of this bomb #insert explosion pos_expl = bomb_obj.current_explosion if pos_expl: pos = [0, 0] pos[0] = pos_expl[0][0] pos[1] = pos_expl[0][1] pos_tocheck = [0, 0] #PUT EXPLOSION AT BOMB CURRENT POSITION pos_tocheck[0] = pos[0] pos_tocheck[1] = pos[1] pos_tofill = p.true_pos(pos_tocheck) #Fill 8 bytes with one explosion for i in range(8): x = int(pos_tofill[i][0]) y = int(pos_tofill[i][1]) self.layout[x][y] = '^' #CHECKING IF EXPLOSION CAN GO RIGHT pos_tocheck[0] = pos[0] pos_tocheck[1] = pos[1] for j in range(1, 3): pos_tocheck[0] = pos[0] + j if (cm.check_move(pos_tocheck, self.layout) == '#'): break else: pos_tofill = p.true_pos(pos_tocheck) #Fill 8 bytes with one explosion for i in range(8): x = int(pos_tofill[i][0]) y = int(pos_tofill[i][1]) self.layout[x][y] = '^' #Destroy bricks at this spot if any if (brick_obj.destroy(pos_tocheck) == 1): bman_obj.score += 20 #returns 1 if a brick was destroyed #CHECKING IF EXPLOSION CAN GO LEFT pos_tocheck[0] = pos[0] pos_tocheck[1] = pos[1] for j in range(1, 3): pos_tocheck[0] = pos[0] - j if (cm.check_move(pos_tocheck, self.layout) == '#'): break else: pos_tofill = p.true_pos(pos_tocheck) #Fill 8 bytes with one explosion for i in range(8): x = int(pos_tofill[i][0]) y = int(pos_tofill[i][1]) self.layout[x][y] = '^' #Destroy bricks at this spot if any if (brick_obj.destroy(pos_tocheck) == 1): bman_obj.score += 20 #returns 1 if a brick was destroyed #CHECKING IF AN EXPLOSION CAN GO UP pos_tocheck[0] = pos[0] pos_tocheck[1] = pos[1] for j in range(1, 3): pos_tocheck[1] = pos[1] + j if (cm.check_move(pos_tocheck, self.layout) == '#'): break else: pos_tofill = p.true_pos(pos_tocheck) #Fill 8 bytes with one explosion for i in range(8): x = int(pos_tofill[i][0]) y = int(pos_tofill[i][1]) self.layout[x][y] = '^' #Destroy bricks at this spot if any if (brick_obj.destroy(pos_tocheck) == 1): bman_obj.score += 20 #returns 1 if a brick was destroyed #CHECKING IF AN EXPLOSION CAN GO DOWN pos_tocheck[0] = pos[0] pos_tocheck[1] = pos[1] for j in range(1, 3): pos_tocheck[1] = pos[1] - j if (cm.check_move(pos_tocheck, self.layout) == '#'): break else: pos_tofill = p.true_pos(pos_tocheck) #Fill 8 bytes with one explosion for i in range(8): x = int(pos_tofill[i][0]) y = int(pos_tofill[i][1]) self.layout[x][y] = '^' #Destroy bricks at this spot if any if (brick_obj.destroy(pos_tocheck) == 1): bman_obj.score += 20
if event.key == SDLK_SPACE: pl.step = 2 def draw(self): self.dis.clip_draw(0, (self.kind + 1) * 21, 21, 21, self.pivx, self.pivy) #초기화 구역 global step global X, Y open_canvas() pl = player() ui = Uishowcase.UI() ##### wl = wall() wp = WeapoN() d = Disk() running = True #게임 루프 구간 while running: X, Y = pl.x, pl.y handle_events() clear_canvas() if d.blast == True and d.blasttime == 1: if pl.x > d.x - 100 and pl.x < wl.x + 100: if pl.y > d.y - 100 and pl.y < d.y + 100: pl.x += 2 * (d.x - pl.x)
def paintEvent(self, event): painter = QPainter(self) colors = [Qt.red, Qt.blue, Qt.green, Qt.yellow, Qt.magenta, Qt.gray] painter.setPen(QPen(colors[1], 2)) # print(self.lines) allLines = [] allWalls = [] for b in self.lines: walls = [] for x in range(6): walls.append(wall(colors[x])) counter = 0 for l in b: viewedLine = [] for p in l: # tutaj sa rzutowane punkty x = (self.lens / p[1]) * p[0] + self.screen_size[0] / 2 y = self.screen_size[1] / 2 - (self.lens / p[1]) * p[2] viewedPoint = (x, y) # if(p[1] > self.lens): // to jest usuwanie krawedzie po za ekranem viewedLine.append(viewedPoint) # if(len(viewedLine) > 1): to jest usuwanie krawedzie po za ekranem objL = line(viewedLine, l) if counter in [0, 1, 2, 3]: objL.attachWall(walls[0]) walls[0].attachLine(objL) if counter in [1, 4, 9, 6]: objL.attachWall(walls[1]) walls[1].attachLine(objL) if counter in [9, 8, 11, 10]: objL.attachWall(walls[2]) walls[2].attachLine(objL) if counter in [3, 7, 11, 5]: objL.attachWall(walls[3]) walls[3].attachLine(objL) if counter in [6, 2, 10, 7]: objL.attachWall(walls[4]) walls[4].attachLine(objL) if counter in [0, 4, 8, 5]: objL.attachWall(walls[5]) walls[5].attachLine(objL) allLines.append(objL) # stare rysowanie painter.drawPolyline( QPolygon([ QPoint(int(viewedLine[0][0]), int(viewedLine[0][1])), QPoint(int(viewedLine[1][0]), int(viewedLine[1][1])) ])) counter += 1 for w in walls: w.createEquation() allWalls.append(w) print(allWalls) print(allLines)
if event.key == SDLK_SPACE: pl.step = 2 def draw(self): self.dis.clip_draw(0, (self.kind + 1) * 21, 21, 21, self.pivx, self.pivy) #초기화 구역 global step global X, Y open_canvas() pl = player() ui = Uishowcase.UI() ##### wl = wall() wl2 = wall() wp = WeapoN() d = Disk() en = Pc() wl2.x = 200 running = True #게임 루프 구간 while running: X, Y = pl.x, pl.y handle_events() clear_canvas() if d.blast == True and d.blasttime == 1: if pl.x > d.x - 100 and pl.x < wl.x + 100:
def main(): #######################INICIALIZACION DE VARIABLES########################## ####### VARIABLES QUE DEFINEN LA PANTALLA DEL JUEGO FPS = 60 WIDTH = 800 HEIGHT = 600 filas = 13 # Numero de filas en las que se dividira el viewport columnas = 17 # Numero de columnas en los que se dividira el viewpoert # Matriz que guardara el estado del juego mEstadoJuego = [None] * filas for i in range(filas): mEstadoJuego[i] = [0] * columnas # Inicializacion de pygame y de opengl init(WIDTH, HEIGHT, "Super Bomberman Deluxe") # Se crea el reloj del juego clock = pygame.time.Clock() # Musica y sonidos pygame.mixer.music.load("Res/bgm.mp3") bombExp = pygame.mixer.Sound("Res/BOM_11_S.wav") bomSet = pygame.mixer.Sound("Res/BOM_SET.wav") goalSound = pygame.mixer.Sound("Res/GOAL.wav") itemGet = pygame.mixer.Sound("Res/ITEM_GET.wav") shiso = pygame.mixer.Sound("Res/SHISO.wav") pygame.mixer.music.play(-1,0) ####### VARIABLES QUE DEFINEN LOS ELEMENTOS EN PANTALLA vistaPrincipal = vista.vista() p1 = character.character(mPos(1, 1, WIDTH, HEIGHT, filas, columnas)) vistaPrincipal.personaje = p1 # Muros indestructibles for i in range(filas): vistaPrincipal.listaMuros.append(wall.wall(mPos(i, columnas - 1, WIDTH, HEIGHT, filas, columnas))) vistaPrincipal.listaMuros.append(wall.wall(mPos(i, 0, WIDTH, HEIGHT, filas, columnas))) mEstadoJuego[i][0] = -1 mEstadoJuego[i][columnas - 1] = -1 for i in range(columnas): vistaPrincipal.listaMuros.append(wall.wall(mPos(0, i, WIDTH, HEIGHT, filas, columnas))) vistaPrincipal.listaMuros.append(wall.wall(mPos(filas - 1, i, WIDTH, HEIGHT, filas, columnas))) mEstadoJuego[0][i] = -1 mEstadoJuego[filas - 1][i] = -1 for i in range(filas): for j in range(columnas): if i % 2 == 0 and j % 2 == 0: vistaPrincipal.listaMuros.append(wall.wall(mPos(i, j, WIDTH, HEIGHT, filas, columnas))) mEstadoJuego[i][j] = -1 # Escalamos los muros de forma correcta para la pantalla for i in vistaPrincipal.listaMuros: i.escalarCorrecto(WIDTH, HEIGHT, filas, columnas) # Muros destructibles # recorremos la matriz completa for q15 in range(filas): for p15 in range(columnas): # Donde exista un espacio libre if mEstadoJuego[q15][p15] == 0: azar = random.randint(0, 100) # Pared se generara azarosamente if not (q15 == 1 and p15 == 1) and not (q15 == 1 and p15 == 2) and not ( q15 == 2 and p15 == 1): # Fuera de las zonas principales if azar > 50: vistaPrincipal.listaDestructibles.append( destructibleWall.destructibleWall(mPos(q15, p15, WIDTH, HEIGHT, filas, columnas))) vistaPrincipal.listaDestructibles[-1].escalarCorrecto(WIDTH, HEIGHT, filas, columnas) mEstadoJuego[q15][p15] = 1 # recorremos la matriz completa for q16 in range(filas): for p16 in range(columnas): # Detras de una pared if mEstadoJuego[q16][p16] == 1: azar2 = random.randint(0, 100) # Pared se generara azarosamente if 0 < azar2 < 10: vistaPrincipal.listaPowerUp1.append( PowerUP1.powerUP1(mPos(q16, p16, WIDTH, HEIGHT, filas, columnas))) if 10 < azar2 < 20: vistaPrincipal.listaPowerUp2.append( PowerUP2.powerUP2(mPos(q16, p16, WIDTH, HEIGHT, filas, columnas))) if 20 < azar2 < 30: vistaPrincipal.listaPowerUp3.append( PowerUP3.powerUP3(mPos(q16, p16, WIDTH, HEIGHT, filas, columnas))) # Anadimos algunos enemigos a la escena (en particular 4) nEnemigos = 0 while True: px = random.randint(0, filas - 1) py = random.randint(0, columnas - 1) if not (px == 1 and py == 1) and not (px == 1 and py == 2) and not (px == 2 and py == 1): if nEnemigos == 0 or nEnemigos == 1: if mEstadoJuego[px][py] == 0: vistaPrincipal.listaEnemigos.append(enemy.enemy(mPos(px, py, WIDTH, HEIGHT, filas, columnas))) nEnemigos += 1 elif nEnemigos == 2 or nEnemigos == 3: if mEstadoJuego[px][py] == 0: vistaPrincipal.listaEnemigos.append(enemy2.enemy2(mPos(px, py, WIDTH, HEIGHT, filas, columnas))) nEnemigos += 1 if nEnemigos == 4: break # Annadimos la salida en una posicion aleatoria while True: px = random.randint(0, filas - 1) py = random.randint(0, columnas - 1) if mEstadoJuego[px][py] == 1: salida = Salida.Salida(mPos(px, py, WIDTH, HEIGHT, filas, columnas)) vistaPrincipal.salida = salida break ###### VARIABLES QUE SIRVEN PARA LA LOGICA DEL JUEGO maxBombas = 3 alcance = 1 keyToExplode = False #######################COMIENZO DEL BUCLE########################## run = True while run: clock.tick(FPS) #######################ANALISIS DE EVENTOS########################## for event in pygame.event.get(): if event.type == QUIT: exit() if event.type == KEYDOWN: # colocar bomba if event.key == K_a: (i, j) = p1.indices(filas, columnas, WIDTH, HEIGHT) if mEstadoJuego[i][j] == 0 and len(vistaPrincipal.listaBombas) < maxBombas: bomb = bomba.bomba(mPos(i, j, WIDTH, HEIGHT, filas, columnas)) bomb.setTiempoInicial(time.get_ticks()) bomb.alcance = alcance vistaPrincipal.listaBombas.append(bomb) mEstadoJuego[i][j] = 2 bomSet.play() # explotar las bombas if event.key == K_s and keyToExplode: if len(vistaPrincipal.listaBombas) > 0: bombExp.play() bomb = vistaPrincipal.listaBombas[0] bomb.explotar(mEstadoJuego, filas, columnas, WIDTH, HEIGHT, vistaPrincipal) ######################LOGICA DEL JUEGO################################ keys = pygame.key.get_pressed() if keys[K_LEFT]: if p1.checkLista(Vector(-1, 0) * p1.velocidad, vistaPrincipal.listaMuros + vistaPrincipal.listaDestructibles): if checkBombAtravesable(Vector(-1, 0), p1, vistaPrincipal.listaBombas): p1.mover(Vector(-1, 0) * p1.velocidad) if keys[K_UP]: if p1.checkLista(Vector(0, 1) * p1.velocidad, vistaPrincipal.listaMuros + vistaPrincipal.listaDestructibles): if checkBombAtravesable(Vector(0, 1), p1, vistaPrincipal.listaBombas): p1.mover(Vector(0, 1) * p1.velocidad) if keys[K_RIGHT]: if p1.checkLista(Vector(1, 0) * p1.velocidad, vistaPrincipal.listaMuros + vistaPrincipal.listaDestructibles): if checkBombAtravesable(Vector(1, 0), p1, vistaPrincipal.listaBombas): p1.mover(Vector(1, 0) * p1.velocidad) if keys[K_DOWN]: if p1.checkLista(Vector(0, -1) * p1.velocidad, vistaPrincipal.listaMuros + vistaPrincipal.listaDestructibles): if checkBombAtravesable(Vector(0, -1), p1, vistaPrincipal.listaBombas): p1.mover(Vector(0, -1) * p1.velocidad) # Cambiamos estado de las bombas si dejamos de tocarlas for bomb in vistaPrincipal.listaBombas: if not (bomb.rect.colliderect(p1.rect)): bomb.atravesable = False # explocion de una bomba for bomb in vistaPrincipal.listaBombas: if time.get_ticks() - bomb.tiempoInicial > 3000: bombExp.play() bomb.explotar(mEstadoJuego, filas, columnas, WIDTH, HEIGHT, vistaPrincipal) # Quitar la explocion de la bomba for bomb in vistaPrincipal.listaExplociones: if time.get_ticks() - bomb.tiempoExplotada > 1300: # Quitamos elementos de la vista y de las listas vistaPrincipal.listaExplociones.pop(0) # Verificar si esta chocando con una explocion for bombExploted in vistaPrincipal.listaExplociones: for rec in bombExploted.rectList: if rec.collidepoint(p1.rect.center): # Aqui hay que quitar el juego print "Has perdido" run = False # Verificar los power ups for pup in vistaPrincipal.listaPowerUp1: if p1.rect.colliderect(pup.rect): itemGet.play() p1.aumentarVelocidad(1) vistaPrincipal.listaPowerUp1.pop(vistaPrincipal.listaPowerUp1.index(pup)) for pup in vistaPrincipal.listaPowerUp2: if p1.rect.colliderect(pup.rect): itemGet.play() alcance += 1 vistaPrincipal.listaPowerUp2.pop(vistaPrincipal.listaPowerUp2.index(pup)) for pup in vistaPrincipal.listaPowerUp3: if p1.rect.colliderect(pup.rect): itemGet.play() keyToExplode = True vistaPrincipal.listaPowerUp3.pop(vistaPrincipal.listaPowerUp3.index(pup)) # Movimiento de los enemigos for enem in vistaPrincipal.listaEnemigos: chocaFuego = False for i in vistaPrincipal.listaExplociones: enem.mover(enem.direccion * enem.velocidad) for rect in i.rectList: if enem.rect.colliderect(rect): chocaFuego = True enem.mover(enem.direccion * enem.velocidad * -1) if not (enem.checkLista(enem.direccion * enem.velocidad, vistaPrincipal.listaDestructibles + vistaPrincipal.listaMuros)) or not ( checkBombAtravesable(enem.direccion, enem, vistaPrincipal.listaBombas)): enem.rotar() elif chocaFuego: enem.rotar() else: enem.mover(enem.direccion * enem.velocidad) # Matar enemigos si chocan con fuego for enem in vistaPrincipal.listaEnemigos: for bombExploted in vistaPrincipal.listaExplociones: for rec in bombExploted.rectList: if rec.collidepoint(enem.rect.center): shiso.play() vistaPrincipal.listaEnemigos.pop(vistaPrincipal.listaEnemigos.index(enem)) # Cerrar el juego si choca con enemigo for enem in vistaPrincipal.listaEnemigos: if enem.rect.colliderect(p1.rect): # Aqui hay que quitar el juego print "Has perdido" run = False # Ganar si llega hasta la salida if p1.rect.colliderect(salida.rect): goalSound.play() print "Has ganado" run = False #######################DIBUJO DE LAS VISTAS########################## vistaPrincipal.dibujar() # Actualizamos la pantalla pygame.display.flip()
"""
def add_wall(self, x, y): self.walls.append(wall.wall(None, x, y))
#x = wall.wall(20,30) def main(): wd = turtle.Screen() wd.tracer(0,0) walls = [] <<<<<<< HEAD A = (0,190) B = (150,190) C = (150, -140) D = (-160, -140) E = (-160, 180) F = (130, 180) G = (130, -120) H = (-140, -1 walls.append(wall.wall((A, B)) walls.append(wall.wall(B, (150, -140))) walls.append(wall.wall((150, -140), (-160, -140))) walls.append(wall.wall((-160, -140), (-160, 180))) walls.append(wall.wall((-160, 180), (130, 180))) walls.append(wall.wall((130, 180), (130, 120))) walls.append(wall.wall((130, 120), (-140, -120))) walls.append(wall.wall((-140, -120), (-140, 160))) walls.append(wall.wall((-140, 160), (120, 160))) walls.append(wall.wall((120, 160), (120, -110))) walls.append(wall.wall((120, -110), (-120, -110))) walls.append(wall.wall((-120, -110), (-130, 120))) walls.append(wall.wall((-130, 120), (0, 110))) walls.append(wall.wall((0, 110), (110, 130))) ======= walls.append(wall.wall((300, 400), (-300, 400)))
def add_wall(self): self.walls.append(wall(self, 20))