Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Untitled_20.py
from scene import *
from math import floor
class SceneTimers(Scene):
def setup(self):
t1=LabelNode()
t2=LabelNode()
t3=LabelNode()
t1.anchor_point=(0,0)
t2.anchor_point=(0,0)
t3.anchor_point=(0,0)
t1.position=(20,50)
t2.position=(20,80)
t3.position=(20,110)
self.add_child(t1)
self.add_child(t2)
self.add_child(t3)
t1.score=0
t2.score=0
t3.score=0
self.t1=t1
self.t2=t2
self.t3=t3
t1.text='0'
t2.text='0'
t3.text='0'
t1.a=Action.sequence(Action.wait(2), Action.call(self.update_label1))
t1.run_action(t1.a)
self.t3.last_update=0
def update_label1(self):
self.t1.score+=1
self.t1.text='Action sequence {}'.format(self.t1.score)
self.t1.run_action(self.t1.a)
def update(self):
self.t2.score+=(self.dt/2)
self.t2.text='Fractional score {}'.format(floor(self.t2.score))
if self.t >= self.t3.last_update+2:
self.t3.last_update=self.t
self.t3.score+=1
self.t3.text='Check time {}'.format(self.t3.score)
s=SceneTimers()
run(s,show_fps=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.