import arcade import random SCREEN_W = 600 SCREEN_H = 400 class SpeakerBaby: def __init__(self, x, y): self.x = x self.y = y self.battery = 100 # full tummy self.hunger_rate = random.uniform(0.8, 1.5) self.face = "happy" # happy / hungry / sad def update(self, dt): self.battery -= self.hunger_rate * dt if self.battery > 60: self.face = "happy" elif self.battery > 20: self.face = "hungry" else: self.face = "sad" if self.battery < 0: self.battery = 0 def feed(self): if self.battery < 95: self.battery += 25 def draw(self): # Body arcade.draw_circle_filled(self.x, self.y, 35, arcade.color.LIGHT_BLUE) arcade.draw_circle_outline(self.x, self.y, 35, arcade.color.DARK_BLUE, 3) # Grille cheeks arcade.draw_rectangle_filled(self.x-15, self.y+5, 12, 16, arcade.color.GRAY) arcade.draw_rectangle_filled(self.x+15, self.y+5, 12, 16, arcade.color.GRAY) # Face if self.face == "happy": arcade.draw_circle_filled(self.x-10, self.y+10, 5, arcade.color.YELLOW) arcade.draw_circle_filled(self.x+10, self.y+10, 5, arcade.color.YELLOW) arcade.draw_arc_outline(self.x, self.y-5, 20, 15, arcade.color.RED, 0, 180, 3) elif self.face == "hungry": arcade.draw_circle_filled(self.x-10, self.y+10, 5, arcade.color.ORANGE) arcade.draw_circle_filled(self.x+10, self.y+10, 5, arcade.color.ORANGE) arcade.draw_line(self.x-5, self.y-5, self.x+5, self.y-5, arcade.color.RED, 2) else: arcade.draw_circle_filled(self.x-10, self.y+10, 5, arcade.color.RED) arcade.draw_circle_filled(self.x+10, self.y+10, 5, arcade.color.RED) arcade.draw_arc_outline(self.x, self.y-10, 20, 15, arcade.color.DARK_RED, 180, 360, 3) class FeedTheSpeakersGame(arcade.Window): def __init__(self): super().__init__(SCREEN_W, SCREEN_H, "Feed the Speaker Sprouts") arcade.set_background_color(arcade.color.PALE_GREEN) self.babies = [ SpeakerBaby(120, 200), SpeakerBaby(300, 160), SpeakerBaby(480, 220) ] self.feed_ready = True self.cooldown = 0 def on_update(self, delta_time): if self.cooldown > 0: self.cooldown -= delta_time else: self.feed_ready = True for baby in self.babies: baby.update(delta_time) def on_mouse_press(self, x, y, button, modifiers): if button == arcade.MOUSE_BUTTON_LEFT and self.feed_ready: for baby in self.babies: if ((x - baby.x)**2 + (y - baby.y)**2) <= 35**2: baby.feed() self.feed_ready = False self.cooldown = 1.2 break def on_draw(self): self.clear() arcade.draw_text("FEED THE SPEAKER SPROUTS!", SCREEN_W/2, SCREEN_H-30, arcade.color.DARK_GREEN, 20, anchor_x="center", bold=True) arcade.draw_text("Click a hungry one to give battery juice!", SCREEN_W/2, SCREEN_H-60, arcade.color.DARK_GRAY, 14, anchor_x="center") all_dead = all(b.battery <= 0 for b in self.babies) if all_dead: arcade.draw_text("ALL SPROUTS SLEEPY — TRY AGAIN!", SCREEN_W/2, SCREEN_H/2, arcade.color.BLACK, 24, anchor_x="center", bold=True) else: for baby in self.babies: baby.draw() if __name__ == "__main__": FeedTheSpeakersGame() arcade.run()