Adds a second stage for ascending.
This commit is contained in:
33
Throot.py
33
Throot.py
@@ -100,6 +100,7 @@ class RoomTitle(Room):
|
||||
thumby.display.drawSprite(spr_b)
|
||||
|
||||
class GameLoop(Room):
|
||||
|
||||
def __init__(self):
|
||||
self.diving_velocity = 10
|
||||
self.diving_accel = 0
|
||||
@@ -125,13 +126,17 @@ class GameLoop(Room):
|
||||
)
|
||||
self.current_obstacle_slice = OBSTACLE_SLICES[0]
|
||||
self.player = Player()
|
||||
self.player.yspeed = 10
|
||||
self.player.speed_y = 16
|
||||
self.player.isdecend = 1
|
||||
self.score = 'score' in event and event['score'] or 0
|
||||
self.level = 'level' in event and event['level'] or 0
|
||||
|
||||
self.finish_depth = 100 + 5 * self.level ** 2
|
||||
self.finish_height = -self.finish_depth
|
||||
self.camera = Camera(self.player)
|
||||
|
||||
self.stage = DESCEND_STAGE
|
||||
|
||||
def get_obstacle_slice(self):
|
||||
return OBSTACLE_SLICES[randrange(0, len(OBSTACLE_SLICES))]
|
||||
|
||||
@@ -201,7 +206,7 @@ class GameLoop(Room):
|
||||
"""
|
||||
super().update(tpf)
|
||||
|
||||
self.player.update_phys(tpf, self.camera)
|
||||
self.player.update_phys(tpf, self.stage in (DESCEND_STAGE, ASCEND_STAGE) and self.camera or None)
|
||||
|
||||
self.camera.update_phys()
|
||||
|
||||
@@ -231,15 +236,23 @@ class GameLoop(Room):
|
||||
self.score += int(abs(self.player.ysub - self.player.prev_y) * 10)
|
||||
|
||||
# finish level
|
||||
if self.player.y > self.finish_depth + int(thumby.display.height * 1.5):
|
||||
self.score += 20
|
||||
self.level += 1
|
||||
self.start({
|
||||
'score': self.score,
|
||||
'level': self.level
|
||||
})
|
||||
if self.stage == DESCEND_STAGE:
|
||||
if self.player.y > self.finish_depth + int(thumby.display.height * 1.5):
|
||||
self.stage = ASCEND_STAGE
|
||||
self.player.ysub = 0
|
||||
self.player.prev_y = 0
|
||||
self.player.speed_y *= -1
|
||||
self.player.isdecend = 0
|
||||
elif self.stage == ASCEND_STAGE:
|
||||
if self.player.y < self.finish_height - int(thumby.display.height * 1.5):
|
||||
self.score += 20
|
||||
self.level += 1
|
||||
self.start({
|
||||
'score': self.score,
|
||||
'level': self.level
|
||||
})
|
||||
|
||||
thumby.display.fill(0)
|
||||
thumby.display.fill(int(self.player.y < 0))
|
||||
self.draw_sky()
|
||||
# Draw the entities
|
||||
for entity in self.entities:
|
||||
|
||||
10
constants.py
10
constants.py
@@ -5,3 +5,13 @@ ROOM_MAIN = 1
|
||||
ROOM_END = 2
|
||||
ROOM_NEXT = -1
|
||||
|
||||
|
||||
# The first part of the level, where we are reaching the water
|
||||
DESCEND_STAGE = 0
|
||||
# The transition to the second part of the level, where the camera travels
|
||||
# back to the surface
|
||||
WATER_STAGE = 1
|
||||
# The second part of the level, where we are growing into the sky
|
||||
ASCEND_STAGE = 2
|
||||
# The "level complete" animation
|
||||
BLOOM_STAGE = 3
|
||||
|
||||
Reference in New Issue
Block a user