def end_game(winner=False): scene = new_scene() message = 'You Win' if winner else 'Game Over' text = ls.Pix.from_text(message, color=ls.RED, bgcolor=ls.BLUE) for dx in range(-8, text.width): scene.blit(text, -dx, 1) ls.show(scene) ls.tick(1 / 12)
dx = 1 if screen.pixel(x + dx, y + dy) not in {WALL, ROCK}: x += dx y += dy elif screen.pixel(x + dx, y + dy) == ROCK and dy == 0: if screen.pixel(x + dx + dx, y + dy + dy) == VOID: screen.pixel(x + dx + dx, y + dy + dy, ROCK) screen.pixel(x + dx, y + dy, VOID) x += dx y += dy count = 0 for a in range(8): for b in range(7, -1, -1): if (screen.pixel(a, b) == ROCK and screen.pixel(a, b + 1) == VOID and (a, b + 1) != (x, y)): screen.pixel(a, b, VOID) screen.pixel(a, b + 1, ROCK) if (a, b + 2) == (x, y): dead = True if screen.pixel(a, b) in {GEM1, GEM2}: screen.pixel(a, b, GEM1 if blink else GEM2) count += 1 if count == 0: break screen.pixel(x, y, 3 if blink else HERO) blink = not blink ls.show(screen) ls.tick(1 / 6)
return red(intensity)+green(intensity)+blue(intensity) ls.init() screen = ls.Pix() while True: ################################################################################ # First Phase text = ls.Pix.from_text("Hello world!", color=ls.RED, bgcolor=ls.BLUE) screen.box(color=ls.BLUE, x=0, y=0, width=8, height=8) start = time.monotonic() while time.monotonic() - start < 5: for dx in range(-8, text.width): screen.blit(text, -dx, 1) ls.show(screen) ls.tick(1/12) ################################################################################ # Second Phase # Try orange for undrawn pixels # screen.box(color=52, x=0, y=0, width=8, height=8) for x in range(4): screen.pixel(x, 0, color=red(x)) screen.pixel(x+4, 0, color=red(3-x)) screen.pixel(x, 1, color=green(x)) screen.pixel(x+4, 1, color=green(3-x)) screen.pixel(x, 2, color=blue(x))
def show(p): for i in range(len(p.buffer)): c = p.buffer[i] screen2.buffer[i] = c ^ (c >> 1) ls.show(screen2)
def show_scene(data): scene = new_scene() scene = show_blocks(scene, data['blocks']) scene = show_player(scene, data['player']) scene = show_ball(scene, data['ball']) ls.show(scene)