phantomcastle: bg move
This commit is contained in:
parent
f0d60d50a8
commit
ee2c47dc2f
@ -36,6 +36,12 @@ class Scene(DrawableGameObject, EventHandler):
|
||||
self.background = pygame.image.load(self.assets["bg1k.png"])
|
||||
self.background = pygame.transform.scale(self.background, self.rect.size)
|
||||
|
||||
double_bg = pygame.Surface((screen_sz.x * 2, screen_sz.y))
|
||||
double_bg.blit(self.background, (0, 0))
|
||||
double_bg.blit(self.background, (screen_sz.x, 0))
|
||||
self.background = double_bg
|
||||
self.bg_shift = 0
|
||||
|
||||
self.total_levels, self.total_coins = 0, 0
|
||||
|
||||
hero_sz = Coords(*map(int, box_sz * 0.8))
|
||||
@ -75,7 +81,7 @@ class Scene(DrawableGameObject, EventHandler):
|
||||
if self.done:
|
||||
return
|
||||
self.surface.fill("white")
|
||||
self.surface.blit(self.background, self.coords)
|
||||
self.surface.blit(self.background, (-self.bg_shift, 0))
|
||||
if self.level_completed:
|
||||
self.end.draw()
|
||||
else:
|
||||
@ -124,6 +130,8 @@ class Scene(DrawableGameObject, EventHandler):
|
||||
self.handle_event(event)
|
||||
self.handle_keys(pygame.key.get_pressed())
|
||||
self.draw()
|
||||
|
||||
self.bg_shift = (self.bg_shift + 1) % self.rect.width
|
||||
pygame.display.flip()
|
||||
await asyncio.sleep(0)
|
||||
clock.tick(self.fps)
|
||||
|
Loading…
Reference in New Issue
Block a user