Sets collectibles for ascending.

This commit is contained in:
Markil3
2023-02-25 12:57:56 -07:00
parent 33ed9c062a
commit 6ccb425057
2 changed files with 25 additions and 17 deletions

View File

@@ -261,7 +261,7 @@ class GameLoop(Room):
self.draw_water()
thumby.display.drawText(str(self.score), thumby.display.width - (len(str(self.score)) + 2) * 5, 1, 1)
thumby.display.drawText(str(self.score), thumby.display.width - (len(str(self.score)) + 2) * 5, 1, int(self.player.y > 0))
class EndRoom(Room):

View File

@@ -131,17 +131,25 @@ def update_entities(entities, difficulty: int, current_depth: int, prev_depth: i
return set()
spawned = set()
if current_depth > 0:
max_spawned = randrange(0, difficulty + 1)
while len(spawned) < max_spawned and random() < (2 * math.pow(difficulty + 0.01, 2)) / (3 * math.pow(difficulty + 0.01, 2) + 20 * (difficulty + 0.01)) + 0.05:
if random() < 0.2:
Clazz = Collectible
if current_depth >= 0:
sprite_image = collectibleunder
else:
sprite_image = collectibleover
else:
max_spawned = randrange(0, int(5 / (0.3 * difficulty + 0.7)))
print(f"Spawning {max_spawned} entities this tick")
while len(spawned) < max_spawned:
if current_depth > 0:
if random() >= (2 * math.pow(difficulty + 0.01, 2)) / (3 * math.pow(difficulty + 0.01, 2) + 20 * (difficulty + 0.01)) + 0.05:
print(f"Cancelling obstacles after {len(spawned)} entities")
break
Clazz = Obstacle
sprite_image = OBSTACLES[randrange(0, min((difficulty + 1) * 3, len(OBSTACLES)))]
else:
if random() >= 1 / (math.pow(difficulty, 2) + 3):
print(f"Cancelling obstacles after {len(spawned)} entities")
break
Clazz = Collectible
sprite_image = collectibleover
if sprite_image.width >= thumby.display.width:
x = 0
else:
@@ -157,6 +165,6 @@ def update_entities(entities, difficulty: int, current_depth: int, prev_depth: i
error = True
break
if not error:
sprite = thumby.Sprite(sprite_image.width, sprite_image.height, sprite_image.image, 0, 0, 0, False, False)
sprite = thumby.Sprite(sprite_image.width, sprite_image.height, sprite_image.image, 0, 0, int(y < 0), False, False)
spawned.add(Clazz(x, y, sprite_image.width, sprite_image.height, sprite_image.collision or sprite_image.image, sprite))
return spawned