Skip to content

Instantly share code, notes, and snippets.

@pathunstrom
Created November 7, 2016 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pathunstrom/2f18a903ad4237d95a489907b4a1ee8d to your computer and use it in GitHub Desktop.
Save pathunstrom/2f18a903ad4237d95a489907b4a1ee8d to your computer and use it in GitHub Desktop.
def newEnemy(style):
spawn = random.randint(1, SPAWNRATE)
coin = random.randint(0, 10)
if style == "z" and spawn >= zomSpawn:
new_enemy = config.enemies["z"].copy()
new_enemy["sight"] = zomSight
elif style == "s" and spawn >= skelSpawn:
new_enemy = config.enemies["s"].copy()
new_enemy["sight"] = skelSight
else:
return
new_enemy["awake"] = coin <= awareness
new_enemy["rect"] = pygame.Rect(0, 0, new_enemy["size"], new_enemy["size"])
playerSafeZone.center = playerRect.center
if not new_enemy['rect'].colliderect(playerSafeZone):
enemies.append(new_enemy)
def newEnemy(style):
spawn = random.randint(1, SPAWNRATE)
coin = random.randint(0, 10)
if style == "z" and spawn >= zomSpawn:
newSize = ZOMSIZE
newColor = ZOMCOLOR
newSpeed = zomSpeed
newSight = zomSight
newScore = zomScore
elif style == "s" and spawn >= skelSpawn:
newSize = SKELSIZE
newColor = SKELCOLOR
newSpeed = skelSpeed
newSight = skelSight
newScore = skelScore
else:
return
if coin <= awareness:
awake = True
else:
awake = False
newMobile = {
'rect': pygame.Rect(random.randint(1, WINDOWWIDTH - newSize),
random.randint(1, WINDOWHEIGHT - newSize), newSize,
newSize),
'color': newColor,
'speed': newSpeed,
'sight': newSight,
'awake': awake,
'score': newScore
}
playerSafeZone.center = playerRect.center
if newMobile['rect'].colliderect(playerSafeZone) == False:
enemies.append(newMobile)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment