This commit is contained in:
parent
103f18d6c3
commit
4405ccfd66
2 changed files with 9 additions and 4 deletions
|
@ -34,7 +34,7 @@ animator.add(DBFAnimation, ds100="AHST", station="Holstenstraße")
|
|||
animator.add(DBFAnimation, ds100="AHS", station="Altona", count=9)
|
||||
animator.add(IcalEvents, url="https://cloud.hamburg.ccc.de/remote.php/dav/public-calendars/QJAdExziSnNJEz5g?export",
|
||||
title="CCCHH Events")
|
||||
# animator.add(SnakeAnimation)
|
||||
animator.add(SnakeAnimation)
|
||||
|
||||
@app.route("/static/<filepath>")
|
||||
def server_static(filepath):
|
||||
|
|
|
@ -13,6 +13,7 @@ class SnakeAnimation(BubaAnimation):
|
|||
self.width = 20
|
||||
self.height = 4
|
||||
self.grid = []
|
||||
self.prev_grid = []
|
||||
self.body = []
|
||||
# 0:Space
|
||||
self.charset = " "
|
||||
|
@ -35,6 +36,7 @@ class SnakeAnimation(BubaAnimation):
|
|||
|
||||
def run(self):
|
||||
self.grid = [list([0] * self.width) for i in range(self.height)]
|
||||
self.prev_grid = [list([0] * self.width) for i in range(self.height)]
|
||||
x = random.randrange(self.width)
|
||||
y = random.randrange(self.height)
|
||||
d = random.randrange(4)
|
||||
|
@ -97,6 +99,9 @@ class SnakeAnimation(BubaAnimation):
|
|||
self.grid[y][x] != 0)
|
||||
|
||||
def render(self):
|
||||
for r, row in enumerate(self.grid):
|
||||
for c, col in enumerate(row):
|
||||
self.buba.text(0, r, c*6, (c+1)*6-1, self.charset[col])
|
||||
for x in range(self.width):
|
||||
for y in range(self.height):
|
||||
if self.grid[y][x] != self.prev_grid[y][x]:
|
||||
c = x*6
|
||||
self.buba.text(0, y, c, c+5, self.charset[self.grid[y][x]])
|
||||
self.prev_grid[y][x] = self.grid[y][x]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue