def fireAlienShips(shipRect): global alienShipList global alienBulletList fire=randint(1,100) if fire%20==0: for i in range(len(alienShipList)): aBullet=asteroidGameObject.Object(10,10,alienShipList[i].bulletImage,[alienShipList[i].centerx,alienShipList[i].centery],randint(1,360)) alienBulletList.append(aBullet)
def generateAsteroid(asteroidImageList,numbertoGenerate): # image,currPosition,angle global asteroidList for i in range(numbertoGenerate): x,y,angle=generateObjectNums() image=pickAsteroid(asteroidImageList) image=sizeAsteroid(image,[200,200]) currPosition=[x,y] aAsteroid=asteroidGameObject.Object(6,6,image,currPosition,angle) asteroidList.append(aAsteroid)
def divideAsteroid(asteroid,asteroidIndex): global asteroidList if asteroid.timesDivided==0: del asteroidList[asteroidIndex] asteroid2=asteroidGameObject.Object(randint(1,9),randint(1,9),sizeAsteroid(asteroid.image,[125,125]),[asteroid.centerx,asteroid.centery],randint(1,360)) asteroid2.timesDivided=1 asteroid1=asteroidGameObject.Object(randint(1,9),randint(1,9),sizeAsteroid(asteroid.image,[125,125]),[asteroid.centerx,asteroid.centery],randint(1,360)) asteroid1.timesDivided=1 asteroidList.append(asteroid1) asteroidList.append(asteroid2) elif asteroid.timesDivided==1: del asteroidList[asteroidIndex] asteroid2=asteroidGameObject.Object(randint(1,12),randint(1,12),sizeAsteroid(asteroid.image,[75,75]),[asteroid.centerx,asteroid.centery],randint(1,360)) asteroid2.timesDivided=2 asteroid1=asteroidGameObject.Object(randint(1,12),randint(1,12),sizeAsteroid(asteroid.image,[75,75]),[asteroid.centerx,asteroid.centery],randint(1,360)) asteroid1.timesDivided=2 asteroidList.append(asteroid1) asteroidList.append(asteroid2) elif asteroid.timesDivided==2: asteroid.timesDivided=3
def generateBullet(xspeed,yspeed,image,currPosition,angle): global bulletList aBullet=asteroidGameObject.Object(xspeed,yspeed,image,currPosition,angle) bulletList.append(aBullet)
def generateBossBullets(boss): global bossBulletList isGenerate=randint(1,100) if isGenerate%4==0: aBullet=asteroidGameObject.Object(8,8,boss.bulletImage,[boss.centerx,boss.centery],randint(1,360)) bossBulletList.append(aBullet)