def animate_relics(self): relative_pos = 0 sep = 200 base_x = SCREEN_WIDTH // 2 - (sep * (len(MainMenu.COLORS) - 1)) // 2 for color in MainMenu.COLORS: self.relics.append(self.scene.layers[0].add_sprite( color + '_relic', pos=(base_x + relative_pos, 150))) relative_pos += sep clock.schedule_interval(self.rotate, 0.01)
color="green", fontsize=60, ) # Create the game object game = Game() def toggle_spots(): if game.game_on: scene.layers[-3].visible = True else: scene.layers[-3].visible ^= 1 clock.schedule_interval(toggle_spots, 0.5) hud = scene.layers[2] score_label = hud.add_label( "SCORE: " + str(round(game.score)), font='eunomia_regular', pos=(10, 55), fontsize=40, ) time_label = hud.add_label( "TIME: " + str(round(game.time)), font='eunomia_regular', pos=(10, 95), fontsize=40, )
bullet = scene.layers[0].add_sprite('tiny_bullet', pos=ship.pos) bullet.color = (1, 0, 0, 1) bullet.vel = Vector2(600, 0).rotate_rad(ship.angle) bullet.power = 1.0 bullets.append(bullet) sounds.laser.play() def update_circ(): circ.radius += 1 poly.stroke_width += 0.01 x, y = r.pos r.pos = (x, y - 1) clock.schedule_interval(update_circ, 0.1) def rotate_star(): """Animate the rotation of the star.""" animate( star, 'bounce_end', duration=1.0, angle=star.angle + math.pi / 3, ) rotate_star() clock.schedule_interval(rotate_star, 2.0)
from wasabi2d import Scene, clock, run scene = Scene() x = scene.width / 2 labels = [ scene.layers[0].add_label("Hello", pos=(x, 200)), scene.layers[0].add_label("World", pos=(x, 300)), scene.layers[0].add_label("", pos=(x, 400)), ] def rotate(): """Rotate the text strings between the labels.""" texts = [l.text for l in labels] texts.insert(0, texts.pop()) for l, t in zip(labels, texts): l.text = t clock.schedule_interval(rotate, 0.4) run()