def update(self, deltaTime): self.updateTest(deltaTime) self.tick += 1 #if self.tick % 50 == 0: tdl.setTitle('%s: %i FPS' % (self.__class__.__name__, tdl.getFPS())) tdl.flush()
(y + self.y) / height * self.zoom, self.z) bgcolor = (int(val * 255), ) * 2 + (min( 255, int(val * 2 * 255)), ) samplewin.drawChar(x, y, ' ', (255, 255, 255), bgcolor) WIDTH, HEIGHT = 80, 40 SAMPLE_WINDOW_RECT = (20, 10, 46, 20) FONT = '../fonts/X11/8x13.png' if __name__ == '__main__': tdl.setFont(FONT) console = tdl.init(WIDTH, HEIGHT, renderer='opengl') samplewin = tdl.Window(console, *SAMPLE_WINDOW_RECT) samples = [cls() for cls in [TrueColorSample, NoiseSample]] while 1: console.clear() samples[sampleIndex].runOnce() for i, sample in enumerate(samples): bgcolor = (0, 0, 0) if sampleIndex == i: bgcolor = (0, 0, 192) console.drawStr(0, -5 + i, '%s' % sample.name, (255, 255, 255), bgcolor) console.drawStr(0, -1, '%i FPS' % tdl.getFPS()) tdl.flush()
for y in range(height): val = self.noise.getPoint((x + self.x) / width * self.zoom, (y + self.y) / height * self.zoom, self.z) bgcolor = (int(val * 255),) * 2 + (min(255, int(val * 2 * 255)),) samplewin.drawChar(x, y, ' ', (255, 255, 255), bgcolor) WIDTH, HEIGHT = 80, 40 SAMPLE_WINDOW_RECT = (20, 10, 46, 20) FONT = '../fonts/X11/8x13.png' if __name__ == '__main__': tdl.setFont(FONT) console = tdl.init(WIDTH, HEIGHT, renderer='opengl') samplewin = tdl.Window(console, *SAMPLE_WINDOW_RECT) samples = [cls() for cls in [TrueColorSample, NoiseSample]] sampleIndex = 0 while 1: console.clear() samples[sampleIndex].runOnce() for i, sample in enumerate(samples): bgcolor = (0, 0, 0) if sampleIndex == i: bgcolor = (0, 0, 192) console.drawStr(0, -5 + i, '%s' % sample.name, (255, 255, 255), bgcolor) console.drawStr(0, -1, '%i FPS' % tdl.getFPS()) tdl.flush()