if event.key == K_DOWN: moveY = 5 if event.key == K_UP: moveY = -5 if event.key == K_LEFT: moveX = -5 if event.key == K_RIGHT: moveX = 5 # Key Event for fire if event.key == K_SPACE: if len(bullets) <= 8: bullets.append( Item([(Player.getObjectX() + int(Player.getObjectHeight() / 2)), Player.getObjectY()], [4, 4], [0, bulletSpeed])) elif event.type == KEYUP: if event.key == K_DOWN or event.key == K_UP: moveY = 0 if event.key == K_LEFT or event.key == K_RIGHT: moveX = 0 elif event.type == MOUSEMOTION: (x, y) = event.pos # Perform calculation for other in others: other.movObjectCoordination() if other.getObjectY() > HEIGHT: others = [ x for x in others if not (x.getObjectX() == other.getObjectX()
quit = True # Key Event for move if event.key == K_DOWN: moveY = 5 if event.key == K_UP: moveY = -5 if event.key == K_LEFT: moveX = -5 if event.key == K_RIGHT: moveX = 5 # Key Event for fire if event.key == K_SPACE: if len(bullets) <= 8: # Item( Coordination, Size, Speed, spr, player, moveArea, time_to_die) bullets.append( Item( [(Player.getObjectX() + int(Player.getObjectHeight() / 2)), Player.getObjectY()], [4,4], [0,bulletSpeed], None, False, [0,0,0,0], 50)) bullet_count += 1 elif event.type == KEYUP: if event.key == K_DOWN or event.key == K_UP: moveY = 0 if event.key == K_LEFT or event.key == K_RIGHT: moveX = 0 elif event.type == MOUSEMOTION: (x,y) = event.pos # Perform calculation window.fill( BACKGROUND_COLOR ) bullets, others, shoot_down_plus = collision_check(bullets, others) if shoot_down_plus: shoot_down_count += 1
moveY = 5 if event.key == K_UP: moveY = -5 if event.key == K_LEFT: moveX = -5 if event.key == K_RIGHT: moveX = 5 # Key Event for fire if event.key == K_SPACE: if len(bullets) <= 8: # Item( Coordination, Size, Speed, spr, player, moveArea, time_to_die) bullets.append( Item([(Player.getObjectX() + int(Player.getObjectHeight() / 2)), Player.getObjectY()], [4, 4], [0, bulletSpeed], None, False, [0, 0, 0, 0], 50)) bullet_count += 1 elif event.type == KEYUP: if event.key == K_DOWN or event.key == K_UP: moveY = 0 if event.key == K_LEFT or event.key == K_RIGHT: moveX = 0 elif event.type == MOUSEMOTION: (x, y) = event.pos # Perform calculation bullets, others, shoot_down_plus = collision_check(bullets, others) if shoot_down_plus: shoot_down_count += 1