玩法:这让我想起了魂斗罗那第几关的boss,有点类似,不过魂斗罗那个难度肯定高点。
import os
import sys
import cfg
import random
import pygame
from modules import *
'''开始游戏'''
def startGame(screen):
clock = pygame.time.Clock()
# 加载字体
font = pygame.font.SysFont('arial', 18)
if not os.path.isfile('score'):
f = open('score', 'w')
f.write('0')
f.close()
with open('score', 'r') as f:
highest_score = int(f.read().strip())
# 敌方
enemies_group = pygame.sprite.Group()
for i in range(55):
if i < 11:
enemy = enemySprite('small', i, cfg.WHITE, cfg.WHITE)
elif i < 33:
enemy = enemySprite('medium', i, cfg.WHITE, cfg.WHITE)
else:
enemy = enemySprite('large', i, cfg.WHITE, cfg.WHITE)
enemy.rect.x = 85 + (i % 11) * 50
enemy.rect.y = 120 + (i // 11) * 45
enemies_group.add(enemy)
boomed_enemies_group = pygame.sprite.Group()
en_bullets_group = pygame.sprite.Group()
ufo = ufoSprite(color=cfg.RED)
# 我方
myaircraft = aircraftSprite(color=cfg.GREEN, bullet_color=cfg.WHITE)
my_bullets_group = pygame.sprite.Group()
# 用于控制敌方位置更新
# --移动一行
enemy_move_count = 24
enemy_move_interval = 24
enemy_move_flag = False
# --改变移动方向(改变方向的同时集体下降一次)
enemy_change_direction_count = 0
enemy_change_direction_interval = 60
enemy_need_down = False