def initStartMenuFlyByShip(data): startX = 5*data.width/4 startY = 3*data.height/8 top = objects.AlphaBulkhead(startX, startY - 40) bot = objects.AlphaBulkhead(startX, startY + 40) right = objects.AlphaBulkhead(startX + 40, startY) left = objects.AlphaBulkhead(startX - 40, startY) command = objects.CommandModule(startX, startY) laserGun1 = objects.LaserGun(startX - 80, startY, 90, 10) laserGun2 = objects.LaserGun(startX + 80, startY, 270, 10) laserGun3 = objects.LaserGun(startX, startY - 80, 0, 10) layout = [ [None, None, None, None, None, None, None], [None, None, None, laserGun3, None, None, None], [None, None, None, top, None, None, None], [None, laserGun1, left, command, right, laserGun2, None], [None, None, None, bot, None, None, None], [None, None, None, None, None, None, None] ] connection = [ [None, None, None, None, None, None, None], [None, None, None, "DOWN", None, None, None], [None, None, None, "DOWN", None, None, None], [None, "RIGHT", "RIGHT", 'CM', "LEFT", "LEFT", None], [None, None, None, "UP", None, None, None], [None, None, None, None, None, None, None] ] data.flyByShip = ships.PlayerShip(command.x, command.y, layout, connection) data.flyByShip.forwardAccelerate = True data.flyByShip.isShooting = True data.flyByShip.speed = -data.flyByShip.maxSpeed data.flyByShip.angle = -90 data.flyByShip.rotateHelper(data, 0)
def initPlayerShip(data): height = objects.AlphaBulkhead.height command = objects.CommandModule(data.width/2, data.height/2) top = objects.AlphaBulkhead(data.width/2, data.height/2 - height) botBulkhead = objects.AlphaBulkhead(data.width/2, data.height/2 + height) right = objects.AlphaBulkhead(data.width/2 + 40, data.height/2) left = objects.AlphaBulkhead(data.width/2 - 40, data.height/2) rocketLauncher1 = objects.RocketLauncher(data.width/2, data.height/2 - 2*height, 90, 20) laserGun1 = objects.LaserGun(data.width/2 - 40, data.height/2 - height, 90, 10) laserGun2 = objects.LaserGun(data.width/2 + 40, data.height/2 - height, 90, 10) laserGun3 = objects.LaserGun(data.width/2, data.height/2 + height, 270, 60) layout = [ [None, None, None, None, None], [None, None, rocketLauncher1, None, None], [None, laserGun1, top, laserGun2, None], [None, left, command, right, None], [None, None, laserGun3, None, None], [None, None, None, None, None] ] connections = [ [None, None, None, None, None], [None, None, "DOWN", None, None], [None, "DOWN", "DOWN", "DOWN", None], [None, "RIGHT", 'CM', "LEFT", None], [None, None, "UP", None, None], [None, None, None, None, None] ] data.player = ships.PlayerShip(command.x, command.y, layout, connections)
def spawnAlpha2(data): enemyX = random.randint(0 - int(data.scrollX), data.width - int(data.scrollX)) enemyY = random.randint(0 - int(data.scrollY), data.height - int(data.scrollY)) height = objects.AlphaBulkhead.height width = objects.AlphaBulkhead.width commandModule = objects.CommandModule(enemyX, enemyY, 10) left = objects.AlphaBulkhead(enemyX - width, enemyY) right = objects.AlphaBulkhead(enemyX + width, enemyY) laserGun = objects.LaserGun(enemyX, enemyY - height, 90, 5) layout = [[None, None, None, None, None], [None, None, laserGun, None, None], [None, left, commandModule, right, None], [None, None, None, None, None], [None, None, None, None, None]] connections = [[None, None, None, None, None], [None, None, 'DOWN', None, None], [None, 'RIGHT', 'CM', 'LEFT', None], [None, None, None, None, None], [None, None, None, None, None]] newEnemy = ships.EnemyShip(enemyX, enemyY, layout, connections, 0) return newEnemy
def loadPlayerLayout(data): fileObject = open('Saves.txt', 'rb') layout, connections = pickle.load(fileObject) startX = data.width/2 startY = data.height/2 for enemy in data.enemiesGroup: if 0 < enemy.commandModuleX < data.width and \ 0 < enemy.commandModuleY < data.height: data.enemiesGroup.remove(enemy) commandRow, commandCol = getCommandRowCol(layout) for row in range(len(layout)): for col in range(len(layout[row])): item = layout[row][col] rowDiff = row - commandRow colDiff = col - commandCol changeX, changeY = colDiff*40, rowDiff*40 itemX = startX + changeX itemY = startY + changeY if connections[row][col] == 'DOWN': angle = 90 elif connections[row][col] == 'UP': angle = 270 elif connections[row][col] == 'LEFT': angle = 0 elif connections[row][col] == 'RIGHT': angle = 180 if item == 'CM': layout[row][col] = objects.CommandModule(startX, startY) if item == 'LG': layout[row][col] = objects.LaserGun(itemX, itemY, angle, 10) if item == 'RL': layout[row][col] = objects.RocketLauncher(itemX, itemY, angle, 20) if item == 'A': layout[row][col] = objects.AlphaBulkhead(itemX, itemY) if item == 'B': layout[row][col] = objects.BravoBulkhead(itemX, itemY) if item == 'C': layout[row][col] = objects.CharlieBulkhead(itemX, itemY) if item == 'D': layout[row][col] = objects.CharlieBulkhead(itemX, itemY) data.player = ships.PlayerShip(startX, startY, layout, connections) data.scrollX = 0 data.scrollY = 0