コード例 #1
0
def launchWave():

    global lastSpawn, currentWave, currentLevel, gameOver, gameWon, nextLevelTS

    thisLevel = gameLevels.level[currentLevel]["structure"]

    if currentWave < len(thisLevel):

        thisWave = thisLevel[currentWave]

        for idx, enemyAtThisPosition in enumerate(thisWave):
            if enemyAtThisPosition is 1:
                enemyShips.append(
                    ships.Enemy(((windowWidth / len(thisWave)) * idx), -60,
                                pygame, surface, 1))

    elif currentLevel + 1 < len(gameLevels.level):
        currentLevel += 1
        currentWave = 0
        ship.shields = ship.maxShields
        nextLevelTS = timeTick + 5000
    else:
        gameWon = True

    lastSpawn = timeTick
    currentWave += 1
コード例 #2
0
    if mouseStates[0] is 1:

      if mousePosition[0] > 445 and mousePosition[0] < 580 and mousePosition[1] > 450 and mousePosition[1] < 510:

        gameStarted = True

    elif mouseStates[0] is 0 and mouseDown is True:
      mouseDown = False

  elif gameStarted is True and gameOver is True:
    surface.blit(startScreen, (0, 0))
    timeLasted = (gameFinishedTime - gameStartedTime) / 1000

  # Handle user and system events 
  for event in GAME_EVENTS.get():

    if event.type == pygame.KEYDOWN:

      if event.key == pygame.K_ESCAPE:
        quitGame()

  if GAME_TIME.get_ticks() - lastEnemyCreated > enemyInterval and gameStarted is True:
    enemyShips.append(ships.Enemy(random.randint(0, windowWidth), -60, pygame, surface, 1))
    lastEnemyCreated = GAME_TIME.get_ticks()

  if event.type == GAME_GLOBALS.QUIT:
    quitGame()
 
  clock.tick(60)
  pygame.display.update()