Skip to content

Commit

Permalink
fixing old examples
Browse files Browse the repository at this point in the history
  • Loading branch information
cptx032 committed Jun 17, 2019
1 parent 5dade09 commit f54a7c4
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 28 deletions.
2 changes: 1 addition & 1 deletion examples/flappixel.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class MainScene(CalciumScene):
def __init__(self, window):
super(MainScene, self).__init__('mainscene', window)
self.pixel = CalciumSprite(8, 16, animations={'d': [[0,0,1]]})
self.pixel = CalciumSprite(8, 16, animations={'d': [[0, 0, 1]]})
self.sprites.append(self.pixel)

self.rec = CalciumSprite(
Expand Down
30 changes: 15 additions & 15 deletions examples/pong.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,27 +32,27 @@ def update(self):
self.vely *= -1


class PongApp(CalciumTerminal):
def __init__(self, *args, **kwargs):
class PongScene(core.CalciumScene):
def __init__(self, window):
super(PongScene, self).__init__('mainscene', window)
self.ball = PongBall(0, 0, {'normal': [[0, 0, 1]]}, velx=3, vely=2)
CalciumTerminal.__init__(self, *args, **kwargs)
self.set_fg_color(0xec,0xf0, 0xf1)
self.set_bg_color(0x2e, 0xcc, 0x71)
self.screen.clear()
self.bind(
CalciumTerminal.ARROW_RIGHT_KEY, self.__change_bg_color, '+')
self.bind('q', self.quit, '+')
CalciumTerminal.ARROW_RIGHT_KEY,
self.__change_bg_color,
'+'
)
self.sprites.append(self.ball)

def __change_bg_color(self):
self.set_bg_color(255, 0, 0)
self.window.set_bg_color(255, 0, 0)

def run(self):
self.ball.update()
self.screen.clear()
self.screen.plot(self.ball)
self.go_to_0_0()
self.draw()

if __name__ == '__main__':
PongApp(
SCREEN_WIDTH, SCREEN_HEIGHT).mainloop()
app = CalciumTerminal(fps=60, terminal_size=True)
app.set_fg_color(0xec, 0xf0, 0xf1)
app.set_bg_color(0x2e, 0xcc, 0x71)
app.scenes['mainscene'] = PongScene(app)
app.actual_scene_name = 'mainscene'
app.mainloop()
23 changes: 11 additions & 12 deletions examples/windfarm.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,34 +8,33 @@

gif_path = os.path.join(os.path.dirname(sys.argv[0]), 'eolic.gif')

class WindFarmApp(terminal.CalciumTerminal):
def __init__(self, *args, **kwargs):
super(WindFarmApp, self).__init__(*args, **kwargs)

class WindFarmScene(core.CalciumScene):
def __init__(self, window):
super(WindFarmScene, self).__init__('mainscene', window)
self.scene = core.CalciumSprite(
0, 0,
dict(normal=image.ImageSprite.get_frames_from_gif(gif_path)))
self.line = core.CalciumSprite(0, 0, {
'normal': [draw.line(0, 0, 80, 48, color=0)]
})
self.bind('q', self.quit, '+')

# self.set_bg_color(0xC9, 0xB9, 0x82)
# self.set_fg_color(0x24, 0x24, 0x24)
self.counter = 0.0
self.sprites.append(self.scene)
self.sprites.append(self.line)

def run(self):
self.counter += 1
if self.counter >= 3:
self.scene.next_frame()
self.counter = 0
self.screen.clear()
self.screen.plot(self.scene)
self.screen.plot(self.line)
self.go_to_0_0()
self.draw()


if __name__ == '__main__':
app = WindFarmApp(terminal_size=True)
app = terminal.CalciumTerminal(terminal_size=True)
# app.set_bg_color(0xC9, 0xB9, 0x82)
# app.set_fg_color(0x24, 0x24, 0x24)
app.scenes['mainscene'] = WindFarmScene(app)
app.actual_scene_name = 'mainscene'
app.mainloop()
print(app.last_fps)

0 comments on commit f54a7c4

Please sign in to comment.