SLet’s give the spikes the ability to respond differently to control state, rather than the current fixed arrangement. Artisanal hand-crafted code, of course. Hello, loves. I think we can rig up a small table to give some flexibility in how the spikes respond to the control messages. For now, we’ll just allow for a different mapping between the lever’s states and the spikes cycling and state. Here’s the relevant code now: class Animated(Content): ... def control_changed(control, state_number): match state_number: case 0 | 3: self.cycling = True case 1: self.cycling = False self.set_state(1, dungeon) case 2: self.cycling = False self.set_state(0, dungeon) def set_state(self, state, dungeon): self.state = state dungeon.publish('state_number', 'view', self, self.state) Let’s begin by adding a parameter to set_state, cycling. This will break our test: def set_state(self, cycling, state, dungeon): self.cycling = cycling self.state = state dungeon.publish('state_number', 'view', self,…
No comments yet. Log in to reply on the Fediverse. Comments will appear here.