Sunday, 7 September 2025

Care + for when your positive.

Here's a simple but complete Ruby game using the Gosu engine, inspired by anarchist principles as explained on [anarchistfaq.net](https://anarchistfaq.net). The game is a "choose your own path" simulation where you try to build a thriving anarchist utopia by making decisions that shape the community's harmony, autonomy, and solidarity. --- First, **install Gosu** if you haven’t: ```bash gem install gosu ``` --- **anarchist_utopia.rb** ```ruby require 'gosu' class Choice attr_reader :text, :effects def initialize(text, effects) @text = text @effects = effects end end class Event attr_reader :description, :choices def initialize(description, choices) @description = description @choices = choices end end EVENTS = [ Event.new( "A neighbor faces hardship. Do you:", [ Choice.new("Organize mutual aid (Solidarity +10, Autonomy -5)", {solidarity: 10, autonomy: -5}), Choice.new("Prioritize self-sufficiency (Autonomy +5, Solidarity -10)", {autonomy: 5, solidarity: -10}), ] ), Event.new( "A conflict arises in the collective. Do you:", [ Choice.new("Facilitate consensus (Harmony +10, Autonomy -5)", {harmony: 10, autonomy: -5}), Choice.new("Let members resolve it themselves (Autonomy +5, Harmony -10)", {autonomy: 5, harmony: -10}), ] ), Event.new( "An authority tries to impose rules. Do you:", [ Choice.new("Resist together (Solidarity +10, Harmony -5)", {solidarity: 10, harmony: -5}), Choice.new("Negotiate individually (Autonomy +5, Solidarity -10)", {autonomy: 5, solidarity: -10}), ] ), Event.new( "A proposal for communal garden arises. Do you:", [ Choice.new("Discuss openly (Harmony +10, Solidarity +5)", {harmony: 10, solidarity: 5}), Choice.new("Let the idea fade (Harmony -10, Solidarity -5)", {harmony: -10, solidarity: -5}), ] ), ] class UtopiaGame < Gosu::Window WIDTH, HEIGHT = 640, 480 def initialize super WIDTH, HEIGHT self.caption = "Anarchist Utopia" @font = Gosu::Font.new(24) @small_font = Gosu::Font.new(16) reset_game end def reset_game @stats = {harmony: 50, autonomy: 50, solidarity: 50} @event = EVENTS.sample @message = "" @game_over = false @choice_buttons = [] @event.choices.each_with_index do |choice, idx| @choice_buttons << [choice, 60, 260 + idx * 60, 520, 45] end end def draw Gosu.draw_rect(0, 0, WIDTH, HEIGHT, Gosu::Color::WHITE, 0) @font.draw_text("Anarchist Utopia", 20, 10, 1, 1.0, 1.0, Gosu::Color::BLACK) y = 60 @stats.each_with_index do |(k, v), i| color = [Gosu::Color::CYAN, Gosu::Color::YELLOW, Gosu::Color::GREEN][i] @font.draw_text("#{k.capitalize}: #{v}", 30 + i*200, y, 1, 1.0, 1.0, color) end if @game_over @font.draw_text(@message, 60, 200, 2, 1.0, 1.0, Gosu::Color::RED) @small_font.draw_text("Press R to restart", 220, 300, 2) else @small_font.draw_text(@event.description, 60, 140, 2, 1.0, 1.0, Gosu::Color::BLACK) @choice_buttons.each_with_index do |(choice, x, y, w, h), i| Gosu.draw_rect(x, y, w, h, Gosu::Color::GRAY, 1) @small_font.draw_text(choice.text, x+10, y+10, 2, 1.0, 1.0, Gosu::Color::BLACK) end end end def button_down(id) close if id == Gosu::KB_ESCAPE if @game_over && id == Gosu::KB_R reset_game return end if !@game_over && id == Gosu::MS_LEFT @choice_buttons.each_with_index do |(choice, x, y, w, h), i| if mouse_x.between?(x, x+w) && mouse_y.between?(y, y+h) make_choice(choice) end end end end def make_choice(choice) choice.effects.each { |k, v| @stats[k] += v } if @stats.values.any? { |v| v <= 0 } @game_over = true @message = "Your utopia collapses! Press R to try again." elsif @stats.values.all? { |v| v >= 100 } @game_over = true @message = "Utopia achieved! Mutual aid and freedom flourish!\nPress R to play again." else @event = EVENTS.sample end end end UtopiaGame.new.show ``` --- This is a launching point—you can add more events, deeper mechanics, or graphics as you wish! **Tip:** The choices and stats draw from anarchist themes: mutual aid, consensus, autonomy, solidarity, and anti-authoritarianism, all core concepts from anarchistfaq.net. Let me know if you want more advanced features or ideas!

No comments:

Post a Comment