Browse Source

scrollers can scroll by more than 1px

Thomas Buck 1 year ago
parent
commit
0ebcdf1ba6
2 changed files with 8 additions and 4 deletions
  1. 2
    2
      draw.py
  2. 6
    2
      life.py

+ 2
- 2
draw.py View File

86
         return w
86
         return w
87
 
87
 
88
 class ScrollText:
88
 class ScrollText:
89
-    def __init__(self, g, t, i = 1, s = 100):
89
+    def __init__(self, g, t, i = 1, s = 50):
90
         self.gui = g
90
         self.gui = g
91
         self.drawer = DrawText(self.gui)
91
         self.drawer = DrawText(self.gui)
92
         self.text = t
92
         self.text = t
106
 
106
 
107
     def draw(self):
107
     def draw(self):
108
         if (time.time() - self.last) > self.speed:
108
         if (time.time() - self.last) > self.speed:
109
+            self.offset += (time.time() - self.last) / self.speed
109
             self.last = time.time()
110
             self.last = time.time()
110
-            self.offset = (self.offset + 1)
111
             if self.offset >= self.width:
111
             if self.offset >= self.width:
112
                 self.offset = -self.gui.width
112
                 self.offset = -self.gui.width
113
                 self.count += 1
113
                 self.count += 1

+ 6
- 2
life.py View File

60
                     continue
60
                     continue
61
                 if self.alive(data, x + xOff, y + yOff):
61
                 if self.alive(data, x + xOff, y + yOff):
62
                     c += 1
62
                     c += 1
63
+                    if c == 4:
64
+                        # 4 or more is not interesting for us
65
+                        break
63
         return c
66
         return c
64
 
67
 
65
     def step(self):
68
     def step(self):
113
     g = GameOfLife(t)
116
     g = GameOfLife(t)
114
 
117
 
115
     def helperRestart():
118
     def helperRestart():
116
-        c = (random.randrange(0, 256), random.randrange(0, 256), random.randrange(0, 256))
117
-        g.setColors(c, (0, 0, 0))
119
+        c1 = (random.randrange(0, 256), random.randrange(0, 256), random.randrange(0, 256))
120
+        c2 = (random.randrange(0, 128), random.randrange(0, 128), random.randrange(0, 128))
121
+        g.setColors(c1, c2)
118
 
122
 
119
     # start out with random colors
123
     # start out with random colors
120
     helperRestart()
124
     helperRestart()

Loading…
Cancel
Save