Sets collectibles for ascending.
This commit is contained in:
@@ -261,7 +261,7 @@ class GameLoop(Room):
|
|||||||
|
|
||||||
self.draw_water()
|
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):
|
class EndRoom(Room):
|
||||||
|
|||||||
40
sprites.py
40
sprites.py
@@ -72,7 +72,7 @@ class Entity:
|
|||||||
def render(self, tpf: float, camera: Camera) -> bool:
|
def render(self, tpf: float, camera: Camera) -> bool:
|
||||||
"""
|
"""
|
||||||
Sets the position of the sprite and draws it.
|
Sets the position of the sprite and draws it.
|
||||||
|
|
||||||
:param tpf:
|
:param tpf:
|
||||||
The number of seconds since the last tick.
|
The number of seconds since the last tick.
|
||||||
:param current_depth:
|
:param current_depth:
|
||||||
@@ -93,7 +93,7 @@ class Entity:
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
class Obstacle(Entity):
|
class Obstacle(Entity):
|
||||||
def update(self, tpf: float, player: Player, camera: Camera) -> bool:
|
def update(self, tpf: float, player: Player, camera: Camera) -> bool:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@ class Collectible(Entity):
|
|||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.score = 'score' in kwargs and kwargs['score'] or 10
|
self.score = 'score' in kwargs and kwargs['score'] or 10
|
||||||
|
|
||||||
def update(self, tpf: float, player: Player, camera: Camera) -> bool:
|
def update(self, tpf: float, player: Player, camera: Camera) -> bool:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -123,25 +123,33 @@ def update_entities(entities, difficulty: int, current_depth: int, prev_depth: i
|
|||||||
:return:
|
:return:
|
||||||
A list of entities to generate this tick.
|
A list of entities to generate this tick.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
OBSTACLE_BUFFER = 10
|
OBSTACLE_BUFFER = 10
|
||||||
|
|
||||||
if current_depth == prev_depth:
|
if current_depth == prev_depth:
|
||||||
# If we haven't moved, we don't need to spawn anything
|
# If we haven't moved, we don't need to spawn anything
|
||||||
return set()
|
return set()
|
||||||
|
|
||||||
spawned = set()
|
spawned = set()
|
||||||
max_spawned = randrange(0, difficulty + 1)
|
if current_depth > 0:
|
||||||
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:
|
max_spawned = randrange(0, difficulty + 1)
|
||||||
if random() < 0.2:
|
else:
|
||||||
Clazz = Collectible
|
max_spawned = randrange(0, int(5 / (0.3 * difficulty + 0.7)))
|
||||||
if current_depth >= 0:
|
print(f"Spawning {max_spawned} entities this tick")
|
||||||
sprite_image = collectibleunder
|
while len(spawned) < max_spawned:
|
||||||
else:
|
if current_depth > 0:
|
||||||
sprite_image = collectibleover
|
if random() >= (2 * math.pow(difficulty + 0.01, 2)) / (3 * math.pow(difficulty + 0.01, 2) + 20 * (difficulty + 0.01)) + 0.05:
|
||||||
else:
|
print(f"Cancelling obstacles after {len(spawned)} entities")
|
||||||
|
break
|
||||||
Clazz = Obstacle
|
Clazz = Obstacle
|
||||||
sprite_image = OBSTACLES[randrange(0, min((difficulty + 1) * 3, len(OBSTACLES)))]
|
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:
|
if sprite_image.width >= thumby.display.width:
|
||||||
x = 0
|
x = 0
|
||||||
else:
|
else:
|
||||||
@@ -157,6 +165,6 @@ def update_entities(entities, difficulty: int, current_depth: int, prev_depth: i
|
|||||||
error = True
|
error = True
|
||||||
break
|
break
|
||||||
if not error:
|
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))
|
spawned.add(Clazz(x, y, sprite_image.width, sprite_image.height, sprite_image.collision or sprite_image.image, sprite))
|
||||||
return spawned
|
return spawned
|
||||||
|
|||||||
Reference in New Issue
Block a user