diff --git a/__init__.py b/__init__.py index c9afb52d606a2733f9cdce81595941a9f94f957d..90ff59fcb4a31ed7a161980302aef2064ed6243c 100644 --- a/__init__.py +++ b/__init__.py @@ -13,12 +13,9 @@ from st3m.ui.interactions import CapScrollController from st3m.input import InputController, InputState from ctx import Context -import bl00mbox +import media class App(Application): - channel: bl00mbox.Channel = bl00mbox.Channel() - sample: bl00mbox.sampler - def __init__(self, app_ctx: ApplicationContext) -> None: super().__init__(app_ctx) self.input = InputController() @@ -38,13 +35,17 @@ class App(Application): self._piece_name = "E" self._song_length = 0 self._song_max_length = 3000 + self._song_path = app_ctx.bundle_path + "/tetrisTheme.mp3" leds.set_auto_update(1) #random.shuffle(self._order) - self.sample = self.channel.new(bl00mbox.patches.sampler, "tetrisTheme.wav") - self.sample.signals.output = self.channel.mixer - self.sample.signals.trigger.start() - #self.sampler_preloaded = self.blm.new(bl00mbox.plugins.sampler, "/sd/apps/Tetris/tetrisTheme.wav") + def on_enter(self, vm): + super().on_enter(vm) + media.load(self._song_path) + + def on_exit(self): + super().on_exit() + media.stop() def draw(self, ctx: Context) -> None: # Paint the background black @@ -69,12 +70,8 @@ class App(Application): def think(self, ins: InputState, delta_ms: int) -> None: super().think(ins, delta_ms) - if self._song_length >= self._song_max_length: - self.sample.signals.trigger.start() - self._song_length = 0 - else: - self._song_length += 1 - #print(str(self._song_length)) + if media.get_position() == media.get_duration(): + media.load(self._song_path) if self.input.buttons.app.left.pressed and self._current_piece:# and self._thinkcounter == 0: #% self._thinkcooldown / 4 == 0: self.place_piece(0) @@ -91,9 +88,6 @@ class App(Application): elif self.input.captouch.petals[5].whole.pressed and self._current_piece: self.place_piece(0) self.drop_piece() - elif self.input.buttons.os.middle.pressed: - self.sample.signals.trigger.stop() - self._song_length = 0 if 0 <= self._thinkcounter < self._thinkcooldown: self._thinkcounter = self._thinkcounter + 1 diff --git a/flow3r.toml b/flow3r.toml index 810db17d21343ccffca17f4bd6f9c053a34cb755..335008a784831f54c4adc59cf2eaa657acd1298b 100644 --- a/flow3r.toml +++ b/flow3r.toml @@ -12,4 +12,4 @@ author = "Lichtgott" description = "Its Tetris" license = "LGPL-3.0-only" url = "https://git.flow3r.garden/Jalimamo/tetrisgame" -version = 1 +version = 2 diff --git a/tetrisTheme.mp3 b/tetrisTheme.mp3 new file mode 100644 index 0000000000000000000000000000000000000000..22371478e733d24e61f01275ecd9143be35b26ec Binary files /dev/null and b/tetrisTheme.mp3 differ diff --git a/tetrisTheme.wav b/tetrisTheme.wav deleted file mode 100644 index d7ed444328fc2cb069e15bbaae2b43555110158b..0000000000000000000000000000000000000000 Binary files a/tetrisTheme.wav and /dev/null differ