def spawnBravo2(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)) width = objects.BravoBulkhead.width height = objects.BravoBulkhead.height commandModule = objects.CommandModule(enemyX, enemyY, 25) right = objects.BravoBulkhead(enemyX + width, enemyY) top = objects.BravoBulkhead(enemyX, enemyY - height) left = objects.BravoBulkhead(enemyX - width, enemyY) bot = objects.BravoBulkhead(enemyX, enemyY + height) laserGun = objects.LaserGun(enemyX, enemyY - 2 * height, 90, 5) layout = [[None, None, laserGun, None, None], [None, None, top, None, None], [None, left, commandModule, right, None], [None, None, bot, None, None, None], [None, None, None, None, None]] connections = [[None, None, 'DOWN', None, None], [None, None, 'DOWN', None, None], [None, 'RIGHT', 'CM', 'LEFT', None], [None, None, 'UP', None, None], [None, None, None, None, None]] newEnemy = ships.EnemyShip(enemyX, enemyY, layout, connections, 1, -3) return newEnemy
def spawnCharlie3(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)) width = objects.CharlieBulkhead.width height = objects.CharlieBulkhead.height commandModule = objects.CommandModule(enemyX, enemyY, 50) right = objects.CharlieBulkhead(enemyX + width, enemyY) top = objects.CharlieBulkhead(enemyX, enemyY - height) left = objects.CharlieBulkhead(enemyX - width, enemyY) bot = objects.CharlieBulkhead(enemyX, enemyY + height) rocketLauncher1 = objects.RocketLauncher(enemyX, enemyY - height, 90, 15) rocketLauncher2 = objects.RocketLauncher(enemyX, enemyY + 2 * height, 270, 15) laserGun1 = objects.LaserGun(enemyX, enemyY - height, 90, 5, 20) laserGun2 = objects.LaserGun(enemyX - width, enemyY - height, 90, 5, 20) laserGun3 = objects.LaserGun(enemyX + width, enemyY - height, 90, 5, 20) layout = [[None, None, None, None, None], [None, laserGun2, rocketLauncher1, laserGun3, None], [None, left, commandModule, right, None], [None, None, bot, None, None], [None, None, rocketLauncher2, None, None], [None, None, None, None, None]] connections = [[None, None, None, None, None], [None, 'DOWN', 'DOWN', 'DOWN', None], [None, 'RIGHT', 'CM', 'LEFT', None], [None, None, 'UP', None, None], [None, None, 'UP', None, None], [None, None, None, None, None]] newEnemy = ships.EnemyShip(enemyX, enemyY, layout, connections, 2, -4) return newEnemy
def spawnCharlie2(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)) width = objects.CharlieBulkhead.width height = objects.CharlieBulkhead.height commandModule = objects.CommandModule(enemyX, enemyY, 50) top = objects.CharlieBulkhead(enemyX, enemyY - height) bot = objects.CharlieBulkhead(enemyX, enemyY + height) laserGun1 = objects.LaserGun(enemyX, enemyY - height, 90, 5, 20) laserGun2 = objects.LaserGun(enemyX - width, enemyY, 180, 10, 20) laserGun3 = objects.LaserGun(enemyX + width, enemyY, 0, 10, 20) layout = [[None, None, None, None, None], [None, None, laserGun1, None, None], [None, laserGun2, commandModule, laserGun3, None], [None, None, bot, 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, 'UP', None, None], [None, None, None, None, None]] newEnemy = ships.EnemyShip(enemyX, enemyY, layout, connections, 2, -4) return newEnemy
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 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 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
def spawnDeltaEnemy(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)) width = objects.DeltaBulkhead.width height = objects.DeltaBulkhead.height command = objects.CommandModule(enemyX, enemyY, 150) right = objects.DeltaBulkhead(enemyX + width, enemyY) top = objects.DeltaBulkhead(enemyX, enemyY - height) topLeft = objects.DeltaBulkhead(enemyX - width, enemyY - height) topRight = objects.DeltaBulkhead(enemyX + width, enemyY - height) left = objects.DeltaBulkhead(enemyX - width, enemyY) bot = objects.DeltaBulkhead(enemyX, enemyY + height) rocket1 = objects.RocketLauncher(enemyX - width, enemyY - 2 * height, 90, 35, 50, 15) rocket2 = objects.RocketLauncher(enemyX + width, enemyY - 2 * height, 90, 35, 50, 15) rocket3 = objects.RocketLauncher(enemyX, enemyY + 2 * height, 270, 35, 50, 20) laser1 = objects.LaserGun(enemyX, enemyY - height, 90, 25, 50) laser2 = objects.LaserGun(enemyX - width, enemyY + height, 270, 25, 50) laser3 = objects.LaserGun(enemyX + width, enemyY + height, 270, 25, 50) laser4 = objects.LaserGun(enemyX - 2 * width, enemyY - height, 180, 25, 50) laser5 = objects.LaserGun(enemyX + 2 * width, enemyY - height, 0, 25, 50) layout = [[None, None, None, None, None, None, None], [None, None, rocket1, laser1, rocket2, None, None], [None, laser4, topLeft, top, topRight, laser5, None], [None, None, left, command, right, None, None], [None, None, laser2, bot, laser3, None, None], [None, None, None, rocket3, None, None, None], [None, None, None, None, None, None, None]] connections = [[None, None, None, None, None, None, None], [None, None, 'DOWN', 'DOWN', 'DOWN', None, None], [None, 'RIGHT', 'DOWN', 'DOWN', 'DOWN', 'LEFT', None], [None, None, 'RIGHT', 'CM', 'LEFT', None, None], [None, None, 'UP', 'UP', 'UP', None, None], [None, None, None, 'UP', None, None, None], [None, None, None, None, None, None, None]] newEnemy = ships.EnemyShip(enemyX, enemyY, layout, connections, 2, -5) return newEnemy
def spawnAlpha1(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) bot = objects.AlphaBulkhead(enemyX, enemyY + height) laserGun = objects.LaserGun(enemyX, enemyY - height, 90, 5) layout = [[None, None, None], [None, laserGun, None], [None, commandModule, None], [None, bot, None], [None, None, None]] connections = [[None, None, None], [None, 'DOWN', None], [None, 'CM', None], [None, 'UP', None], [None, None, None]] newEnemy = ships.EnemyShip(enemyX, enemyY, layout, connections, 0) return newEnemy