diff --git a/assets/funfriend/catfriend_00.png b/assets/buddies/catfriend_00.png similarity index 100% rename from assets/funfriend/catfriend_00.png rename to assets/buddies/catfriend_00.png diff --git a/assets/funfriend/catfriend_01.png b/assets/buddies/catfriend_01.png similarity index 100% rename from assets/funfriend/catfriend_01.png rename to assets/buddies/catfriend_01.png diff --git a/assets/funfriend/catfriend_02.png b/assets/buddies/catfriend_02.png similarity index 100% rename from assets/funfriend/catfriend_02.png rename to assets/buddies/catfriend_02.png diff --git a/assets/funfriend/catfriend_03.png b/assets/buddies/catfriend_03.png similarity index 100% rename from assets/funfriend/catfriend_03.png rename to assets/buddies/catfriend_03.png diff --git a/assets/funfriend/catfriend_04.png b/assets/buddies/catfriend_04.png similarity index 100% rename from assets/funfriend/catfriend_04.png rename to assets/buddies/catfriend_04.png diff --git a/assets/funfriend/catfriend_05.png b/assets/buddies/catfriend_05.png similarity index 100% rename from assets/funfriend/catfriend_05.png rename to assets/buddies/catfriend_05.png diff --git a/assets/funfriend/catfriend_06.png b/assets/buddies/catfriend_06.png similarity index 100% rename from assets/funfriend/catfriend_06.png rename to assets/buddies/catfriend_06.png diff --git a/assets/funfriend/catfriend_07.png b/assets/buddies/catfriend_07.png similarity index 100% rename from assets/funfriend/catfriend_07.png rename to assets/buddies/catfriend_07.png diff --git a/assets/funfriend/catfriend_08.png b/assets/buddies/catfriend_08.png similarity index 100% rename from assets/funfriend/catfriend_08.png rename to assets/buddies/catfriend_08.png diff --git a/assets/funfriend/catfriend_09.png b/assets/buddies/catfriend_09.png similarity index 100% rename from assets/funfriend/catfriend_09.png rename to assets/buddies/catfriend_09.png diff --git a/assets/funfriend/catfriend_10.png b/assets/buddies/catfriend_10.png similarity index 100% rename from assets/funfriend/catfriend_10.png rename to assets/buddies/catfriend_10.png diff --git a/assets/funfriend/catfriend_11.png b/assets/buddies/catfriend_11.png similarity index 100% rename from assets/funfriend/catfriend_11.png rename to assets/buddies/catfriend_11.png diff --git a/assets/funfriend/catfriend_12.png b/assets/buddies/catfriend_12.png similarity index 100% rename from assets/funfriend/catfriend_12.png rename to assets/buddies/catfriend_12.png diff --git a/assets/funfriend/catfriend_13.png b/assets/buddies/catfriend_13.png similarity index 100% rename from assets/funfriend/catfriend_13.png rename to assets/buddies/catfriend_13.png diff --git a/assets/funfriend/catfriend_14.png b/assets/buddies/catfriend_14.png similarity index 100% rename from assets/funfriend/catfriend_14.png rename to assets/buddies/catfriend_14.png diff --git a/assets/funfriend/catfriend_15.png b/assets/buddies/catfriend_15.png similarity index 100% rename from assets/funfriend/catfriend_15.png rename to assets/buddies/catfriend_15.png diff --git a/assets/funfriend/catfriend_16.png b/assets/buddies/catfriend_16.png similarity index 100% rename from assets/funfriend/catfriend_16.png rename to assets/buddies/catfriend_16.png diff --git a/assets/funfriend/catfriend_17.png b/assets/buddies/catfriend_17.png similarity index 100% rename from assets/funfriend/catfriend_17.png rename to assets/buddies/catfriend_17.png diff --git a/assets/funfriend/catfriend_18.png b/assets/buddies/catfriend_18.png similarity index 100% rename from assets/funfriend/catfriend_18.png rename to assets/buddies/catfriend_18.png diff --git a/assets/funfriend/catfriend_19.png b/assets/buddies/catfriend_19.png similarity index 100% rename from assets/funfriend/catfriend_19.png rename to assets/buddies/catfriend_19.png diff --git a/assets/funfriend/catfriend_20.png b/assets/buddies/catfriend_20.png similarity index 100% rename from assets/funfriend/catfriend_20.png rename to assets/buddies/catfriend_20.png diff --git a/assets/funfriend/catfriend_21.png b/assets/buddies/catfriend_21.png similarity index 100% rename from assets/funfriend/catfriend_21.png rename to assets/buddies/catfriend_21.png diff --git a/assets/funfriend/catfriend_22.png b/assets/buddies/catfriend_22.png similarity index 100% rename from assets/funfriend/catfriend_22.png rename to assets/buddies/catfriend_22.png diff --git a/assets/funfriend/catfriend_23.png b/assets/buddies/catfriend_23.png similarity index 100% rename from assets/funfriend/catfriend_23.png rename to assets/buddies/catfriend_23.png diff --git a/assets/funfriend/catfriend_24.png b/assets/buddies/catfriend_24.png similarity index 100% rename from assets/funfriend/catfriend_24.png rename to assets/buddies/catfriend_24.png diff --git a/assets/funfriend/catfriend_25.png b/assets/buddies/catfriend_25.png similarity index 100% rename from assets/funfriend/catfriend_25.png rename to assets/buddies/catfriend_25.png diff --git a/assets/funfriend/catfriend_26.png b/assets/buddies/catfriend_26.png similarity index 100% rename from assets/funfriend/catfriend_26.png rename to assets/buddies/catfriend_26.png diff --git a/assets/funfriend/catfriend_27.png b/assets/buddies/catfriend_27.png similarity index 100% rename from assets/funfriend/catfriend_27.png rename to assets/buddies/catfriend_27.png diff --git a/assets/funfriend/catfriend_28.png b/assets/buddies/catfriend_28.png similarity index 100% rename from assets/funfriend/catfriend_28.png rename to assets/buddies/catfriend_28.png diff --git a/assets/funfriend/catfriend_29.png b/assets/buddies/catfriend_29.png similarity index 100% rename from assets/funfriend/catfriend_29.png rename to assets/buddies/catfriend_29.png diff --git a/assets/funfriend/catfriend_30.png b/assets/buddies/catfriend_30.png similarity index 100% rename from assets/funfriend/catfriend_30.png rename to assets/buddies/catfriend_30.png diff --git a/assets/funfriend/catfriend_31.png b/assets/buddies/catfriend_31.png similarity index 100% rename from assets/funfriend/catfriend_31.png rename to assets/buddies/catfriend_31.png diff --git a/assets/funfriend/catfriend_32.png b/assets/buddies/catfriend_32.png similarity index 100% rename from assets/funfriend/catfriend_32.png rename to assets/buddies/catfriend_32.png diff --git a/assets/funfriend/catfriend_33.png b/assets/buddies/catfriend_33.png similarity index 100% rename from assets/funfriend/catfriend_33.png rename to assets/buddies/catfriend_33.png diff --git a/assets/funfriend/catfriend_34.png b/assets/buddies/catfriend_34.png similarity index 100% rename from assets/funfriend/catfriend_34.png rename to assets/buddies/catfriend_34.png diff --git a/assets/funfriend/catfriend_35.png b/assets/buddies/catfriend_35.png similarity index 100% rename from assets/funfriend/catfriend_35.png rename to assets/buddies/catfriend_35.png diff --git a/assets/funfriend/catfriend_36.png b/assets/buddies/catfriend_36.png similarity index 100% rename from assets/funfriend/catfriend_36.png rename to assets/buddies/catfriend_36.png diff --git a/assets/funfriend/catfriend_37.png b/assets/buddies/catfriend_37.png similarity index 100% rename from assets/funfriend/catfriend_37.png rename to assets/buddies/catfriend_37.png diff --git a/assets/funfriend/catfriend_38.png b/assets/buddies/catfriend_38.png similarity index 100% rename from assets/funfriend/catfriend_38.png rename to assets/buddies/catfriend_38.png diff --git a/assets/funfriend/catfriend_39.png b/assets/buddies/catfriend_39.png similarity index 100% rename from assets/funfriend/catfriend_39.png rename to assets/buddies/catfriend_39.png diff --git a/assets/funfriend/funfriend_00.png b/assets/buddies/funfriend_00.png similarity index 100% rename from assets/funfriend/funfriend_00.png rename to assets/buddies/funfriend_00.png diff --git a/assets/funfriend/funfriend_01.png b/assets/buddies/funfriend_01.png similarity index 100% rename from assets/funfriend/funfriend_01.png rename to assets/buddies/funfriend_01.png diff --git a/assets/funfriend/funfriend_02.png b/assets/buddies/funfriend_02.png similarity index 100% rename from assets/funfriend/funfriend_02.png rename to assets/buddies/funfriend_02.png diff --git a/assets/funfriend/funfriend_03.png b/assets/buddies/funfriend_03.png similarity index 100% rename from assets/funfriend/funfriend_03.png rename to assets/buddies/funfriend_03.png diff --git a/assets/funfriend/funfriend_04.png b/assets/buddies/funfriend_04.png similarity index 100% rename from assets/funfriend/funfriend_04.png rename to assets/buddies/funfriend_04.png diff --git a/assets/funfriend/funfriend_05.png b/assets/buddies/funfriend_05.png similarity index 100% rename from assets/funfriend/funfriend_05.png rename to assets/buddies/funfriend_05.png diff --git a/assets/funfriend/funfriend_06.png b/assets/buddies/funfriend_06.png similarity index 100% rename from assets/funfriend/funfriend_06.png rename to assets/buddies/funfriend_06.png diff --git a/assets/funfriend/funfriend_07.png b/assets/buddies/funfriend_07.png similarity index 100% rename from assets/funfriend/funfriend_07.png rename to assets/buddies/funfriend_07.png diff --git a/assets/funfriend/funfriend_08.png b/assets/buddies/funfriend_08.png similarity index 100% rename from assets/funfriend/funfriend_08.png rename to assets/buddies/funfriend_08.png diff --git a/assets/funfriend/funfriend_09.png b/assets/buddies/funfriend_09.png similarity index 100% rename from assets/funfriend/funfriend_09.png rename to assets/buddies/funfriend_09.png diff --git a/assets/funfriend/funfriend_10.png b/assets/buddies/funfriend_10.png similarity index 100% rename from assets/funfriend/funfriend_10.png rename to assets/buddies/funfriend_10.png diff --git a/assets/funfriend/funfriend_11.png b/assets/buddies/funfriend_11.png similarity index 100% rename from assets/funfriend/funfriend_11.png rename to assets/buddies/funfriend_11.png diff --git a/assets/funfriend/funfriend_12.png b/assets/buddies/funfriend_12.png similarity index 100% rename from assets/funfriend/funfriend_12.png rename to assets/buddies/funfriend_12.png diff --git a/assets/funfriend/funfriend_13.png b/assets/buddies/funfriend_13.png similarity index 100% rename from assets/funfriend/funfriend_13.png rename to assets/buddies/funfriend_13.png diff --git a/assets/funfriend/funfriend_14.png b/assets/buddies/funfriend_14.png similarity index 100% rename from assets/funfriend/funfriend_14.png rename to assets/buddies/funfriend_14.png diff --git a/assets/funfriend/funfriend_15.png b/assets/buddies/funfriend_15.png similarity index 100% rename from assets/funfriend/funfriend_15.png rename to assets/buddies/funfriend_15.png diff --git a/assets/funfriend/funfriend_16.png b/assets/buddies/funfriend_16.png similarity index 100% rename from assets/funfriend/funfriend_16.png rename to assets/buddies/funfriend_16.png diff --git a/assets/funfriend/funfriend_17.png b/assets/buddies/funfriend_17.png similarity index 100% rename from assets/funfriend/funfriend_17.png rename to assets/buddies/funfriend_17.png diff --git a/assets/funfriend/funfriend_18.png b/assets/buddies/funfriend_18.png similarity index 100% rename from assets/funfriend/funfriend_18.png rename to assets/buddies/funfriend_18.png diff --git a/assets/funfriend/funfriend_19.png b/assets/buddies/funfriend_19.png similarity index 100% rename from assets/funfriend/funfriend_19.png rename to assets/buddies/funfriend_19.png diff --git a/assets/funfriend/funfriend_20.png b/assets/buddies/funfriend_20.png similarity index 100% rename from assets/funfriend/funfriend_20.png rename to assets/buddies/funfriend_20.png diff --git a/assets/funfriend/funfriend_21.png b/assets/buddies/funfriend_21.png similarity index 100% rename from assets/funfriend/funfriend_21.png rename to assets/buddies/funfriend_21.png diff --git a/assets/funfriend/funfriend_22.png b/assets/buddies/funfriend_22.png similarity index 100% rename from assets/funfriend/funfriend_22.png rename to assets/buddies/funfriend_22.png diff --git a/assets/funfriend/funfriend_23.png b/assets/buddies/funfriend_23.png similarity index 100% rename from assets/funfriend/funfriend_23.png rename to assets/buddies/funfriend_23.png diff --git a/assets/funfriend/funfriend_24.png b/assets/buddies/funfriend_24.png similarity index 100% rename from assets/funfriend/funfriend_24.png rename to assets/buddies/funfriend_24.png diff --git a/assets/funfriend/funfriend_25.png b/assets/buddies/funfriend_25.png similarity index 100% rename from assets/funfriend/funfriend_25.png rename to assets/buddies/funfriend_25.png diff --git a/assets/funfriend/funfriend_26.png b/assets/buddies/funfriend_26.png similarity index 100% rename from assets/funfriend/funfriend_26.png rename to assets/buddies/funfriend_26.png diff --git a/assets/funfriend/funfriend_27.png b/assets/buddies/funfriend_27.png similarity index 100% rename from assets/funfriend/funfriend_27.png rename to assets/buddies/funfriend_27.png diff --git a/assets/funfriend/funfriend_28.png b/assets/buddies/funfriend_28.png similarity index 100% rename from assets/funfriend/funfriend_28.png rename to assets/buddies/funfriend_28.png diff --git a/assets/funfriend/funfriend_29.png b/assets/buddies/funfriend_29.png similarity index 100% rename from assets/funfriend/funfriend_29.png rename to assets/buddies/funfriend_29.png diff --git a/assets/funfriend/funfriend_30.png b/assets/buddies/funfriend_30.png similarity index 100% rename from assets/funfriend/funfriend_30.png rename to assets/buddies/funfriend_30.png diff --git a/assets/funfriend/funfriend_31.png b/assets/buddies/funfriend_31.png similarity index 100% rename from assets/funfriend/funfriend_31.png rename to assets/buddies/funfriend_31.png diff --git a/assets/funfriend/funfriend_32.png b/assets/buddies/funfriend_32.png similarity index 100% rename from assets/funfriend/funfriend_32.png rename to assets/buddies/funfriend_32.png diff --git a/assets/funfriend/funfriend_33.png b/assets/buddies/funfriend_33.png similarity index 100% rename from assets/funfriend/funfriend_33.png rename to assets/buddies/funfriend_33.png diff --git a/assets/funfriend/funfriend_34.png b/assets/buddies/funfriend_34.png similarity index 100% rename from assets/funfriend/funfriend_34.png rename to assets/buddies/funfriend_34.png diff --git a/assets/funfriend/funfriend_35.png b/assets/buddies/funfriend_35.png similarity index 100% rename from assets/funfriend/funfriend_35.png rename to assets/buddies/funfriend_35.png diff --git a/assets/funfriend/funfriend_36.png b/assets/buddies/funfriend_36.png similarity index 100% rename from assets/funfriend/funfriend_36.png rename to assets/buddies/funfriend_36.png diff --git a/assets/funfriend/funfriend_37.png b/assets/buddies/funfriend_37.png similarity index 100% rename from assets/funfriend/funfriend_37.png rename to assets/buddies/funfriend_37.png diff --git a/assets/funfriend/funfriend_38.png b/assets/buddies/funfriend_38.png similarity index 100% rename from assets/funfriend/funfriend_38.png rename to assets/buddies/funfriend_38.png diff --git a/assets/funfriend/funfriend_39.png b/assets/buddies/funfriend_39.png similarity index 100% rename from assets/funfriend/funfriend_39.png rename to assets/buddies/funfriend_39.png diff --git a/assets/buddies/god_00.png b/assets/buddies/god_00.png new file mode 100644 index 0000000..2f6af48 Binary files /dev/null and b/assets/buddies/god_00.png differ diff --git a/assets/buddies/god_01.png b/assets/buddies/god_01.png new file mode 100644 index 0000000..3ba358a Binary files /dev/null and b/assets/buddies/god_01.png differ diff --git a/assets/buddies/god_02.png b/assets/buddies/god_02.png new file mode 100644 index 0000000..1e1114b Binary files /dev/null and b/assets/buddies/god_02.png differ diff --git a/assets/buddies/god_03.png b/assets/buddies/god_03.png new file mode 100644 index 0000000..77dc44d Binary files /dev/null and b/assets/buddies/god_03.png differ diff --git a/assets/buddies/god_04.png b/assets/buddies/god_04.png new file mode 100644 index 0000000..e92f59a Binary files /dev/null and b/assets/buddies/god_04.png differ diff --git a/assets/buddies/god_05.png b/assets/buddies/god_05.png new file mode 100644 index 0000000..0d3219e Binary files /dev/null and b/assets/buddies/god_05.png differ diff --git a/assets/buddies/god_06.png b/assets/buddies/god_06.png new file mode 100644 index 0000000..26806f5 Binary files /dev/null and b/assets/buddies/god_06.png differ diff --git a/assets/buddies/god_07.png b/assets/buddies/god_07.png new file mode 100644 index 0000000..8222c7d Binary files /dev/null and b/assets/buddies/god_07.png differ diff --git a/assets/buddies/god_08.png b/assets/buddies/god_08.png new file mode 100644 index 0000000..1184bcf Binary files /dev/null and b/assets/buddies/god_08.png differ diff --git a/assets/buddies/god_09.png b/assets/buddies/god_09.png new file mode 100644 index 0000000..d5cd84f Binary files /dev/null and b/assets/buddies/god_09.png differ diff --git a/assets/sfx/talk_god1.ogg b/assets/sfx/talk_god1.ogg new file mode 100644 index 0000000..123b8cb Binary files /dev/null and b/assets/sfx/talk_god1.ogg differ diff --git a/assets/sfx/talk_god2.ogg b/assets/sfx/talk_god2.ogg new file mode 100644 index 0000000..e2e28f4 Binary files /dev/null and b/assets/sfx/talk_god2.ogg differ diff --git a/assets/sfx/talk_god3.ogg b/assets/sfx/talk_god3.ogg new file mode 100644 index 0000000..bd37082 Binary files /dev/null and b/assets/sfx/talk_god3.ogg differ diff --git a/assets/sfx/talk_god4.ogg b/assets/sfx/talk_god4.ogg new file mode 100644 index 0000000..52bd102 Binary files /dev/null and b/assets/sfx/talk_god4.ogg differ diff --git a/assets/sfx/talk_god5.ogg b/assets/sfx/talk_god5.ogg new file mode 100644 index 0000000..480a41a Binary files /dev/null and b/assets/sfx/talk_god5.ogg differ diff --git a/assets/sfx/talk_god6.ogg b/assets/sfx/talk_god6.ogg new file mode 100644 index 0000000..4fc6345 Binary files /dev/null and b/assets/sfx/talk_god6.ogg differ diff --git a/assets/sfx/talk_god7.ogg b/assets/sfx/talk_god7.ogg new file mode 100644 index 0000000..083a900 Binary files /dev/null and b/assets/sfx/talk_god7.ogg differ diff --git a/assets/sfx/talk_god8.ogg b/assets/sfx/talk_god8.ogg new file mode 100644 index 0000000..1b7ad02 Binary files /dev/null and b/assets/sfx/talk_god8.ogg differ diff --git a/src/buddies.cr b/src/buddies.cr new file mode 100644 index 0000000..a7b05be --- /dev/null +++ b/src/buddies.cr @@ -0,0 +1,102 @@ +module Funfriend + enum DialogType + # Upon boot-up; random chatter + Chatter + # Upon being moved + Moved + # Upon being touched, but not moved + Touched + end + + abstract class Buddy + # Used in window titles + abstract def name : String + + # Given a specific `DialogType`, returns a list of possible dialogue choices + abstract def dialog(type : DialogType) : Array(Array(String)) + + # Returns the textures this buddy uses + abstract def textures : TextureMan::TextureBasket + + # Implements the logic for the talk SFX, similar to corru.observer's `talk: () => ...` + abstract def talk_sound + end + + class FunfriendBuddy < Buddy + def name : String + "FUNFRIEND" + end + + def dialog(type) : Array(Array(String)) + case type + when .chatter? + [ + ["HELLO AGAIN"], + ["HI INTERLOPER"], + ["HELLO!", "IS THE AUTH LAYER STILL DISSOCIATED?", "I MISS THEM"], + ["INTERLOPER!", "WELCOME", "BUT ALSO PLEASE DO NOT BOTHER ME", "VERY BUSY"] + ] + when .moved? + [ + ["OK I'LL BE HERE"] + ] + when .touched? + [ + ["HI INTERLOPER!"], + ["HELLO!"], + ["HI!"] + ] + else + [] of Array(String) + end + end + + def textures : TextureMan::TextureBasket + TextureMan::TextureBasket.new( + (0..39).map { |i| TextureMan.load_texture("assets/buddies/funfriend_#{i.to_s.rjust(2, '0')}.png") }, + 10 + ) + end + + def talk_sound + SoundMan.play_sound("assets/sfx/talk#{(1..8).sample}.ogg") + end + end + + class CatfriendBuddy < FunfriendBuddy + def textures : TextureMan::TextureBasket + TextureMan::TextureBasket.new( + (0..39).map { |i| TextureMan.load_texture("assets/buddies/catfriend_#{i.to_s.rjust(2, '0')}.png") }, + 10 + ) + end + end + + class GodBuddy < Buddy + def name : String + "GOD" + end + + def dialog(type) : Array(Array(String)) + case type + when .chatter? + [ + ["hello!"] + ] + else + [] of Array(String) + end + end + + def textures : TextureMan::TextureBasket + TextureMan::TextureBasket.new( + (0..9).map { |i| TextureMan.load_texture("assets/buddies/god_#{i.to_s.rjust(2, '0')}.png") }, + 10 + ) + end + + def talk_sound + SoundMan.play_sound("assets/sfx/talk_god#{(1..8).sample}.ogg") + end + end +end diff --git a/src/funfriend_context.cr b/src/buddy_context.cr similarity index 85% rename from src/funfriend_context.cr rename to src/buddy_context.cr index e2bd828..e2acb6f 100644 --- a/src/funfriend_context.cr +++ b/src/buddy_context.cr @@ -1,27 +1,12 @@ -class Funfriend::FunfriendContext < Funfriend::WindowContext +class Funfriend::BuddyContext < Funfriend::WindowContext CHATTER_TIMER = 3.0 - CHATTER_ARRAY = [ - ["HELLO AGAIN"], - ["HI INTERLOPER"], - ["HELLO!", "IS THE AUTH LAYER STILL DISSOCIATED?", "I MISS THEM"], - ["INTERLOPER!", "WELCOME", "BUT ALSO PLEASE DO NOT BOTHER ME", "VERY BUSY"] - ] + getter buddy : Buddy - STAY_ARRAY = [ - "OK I'LL BE HERE" - ] - - TOUCH_ARRAY = [ - "HI INTERLOPER!", - "HELLO!", - "HI!" - ] - - getter renderer : FunfriendRenderer + getter renderer : BuddyRenderer property chatter_timer : Float64 = 1.0 property chatter_index : Int32 = 0 - property chatter_array : Array(String)? = CHATTER_ARRAY.sample + property chatter_array : Array(String)? property held : Bool = false property held_at : Vec2 = Vec2.zero @@ -40,24 +25,21 @@ class Funfriend::FunfriendContext < Funfriend::WindowContext WANDER_TIMER = 4.0 property wander_timer : Float64 = WANDER_TIMER - def initialize + def initialize(@buddy : Buddy) super( - title: "??_FUNFRIEND_??", + title: "??_#{buddy.name}_??", width: window_size.x_i, height: window_size.y_i, transparent: true ) # just for initialization, let OpenGL know this is the current context window.make_context_current - @renderer = FunfriendRenderer.new + @renderer = BuddyRenderer.new(buddy) window.on_mouse_button do |event| - if event.action.press? && event.mouse_button.two? - renderer.catmoding = !renderer.catmoding - end if event.mouse_button.one? if event.action.press? - SoundMan.play_sound("assets/sfx/talk#{(1..8).sample}.ogg") + buddy.talk_sound @easing_dur = 0.0 @held = true @held_at = Vec2.new({ @@ -91,6 +73,8 @@ class Funfriend::FunfriendContext < Funfriend::WindowContext } window.position = random_pos @static_pos = Vec2.new(random_pos) + + @chatter_array = buddy.dialog(DialogType::Chatter).sample end def window_size @@ -189,10 +173,10 @@ class Funfriend::FunfriendContext < Funfriend::WindowContext if !speaking if stable_pos_dist > 50 # moved quite a bit from initial point - say STAY_ARRAY.sample + say buddy.dialog(DialogType::Moved) else # just touched - say TOUCH_ARRAY.sample + say buddy.dialog(DialogType::Touched) end end end @@ -214,7 +198,19 @@ class Funfriend::FunfriendContext < Funfriend::WindowContext window.position[:y] - 20 ), parent: self)) - SoundMan.play_sound("assets/sfx/talk#{(1..8).sample}.ogg") + buddy.talk_sound + end + + def say(text : Array(String)) + @chatter_array = text + @chatter_timer = 0.0 + @chatter_index = 0 + end + + def say(text : Array(Array(String))) + if text.size > 0 + say text.sample + end end def speaking diff --git a/src/funfriend_renderer.cr b/src/buddy_renderer.cr similarity index 79% rename from src/funfriend_renderer.cr rename to src/buddy_renderer.cr index 42d0ad2..9089248 100644 --- a/src/funfriend_renderer.cr +++ b/src/buddy_renderer.cr @@ -1,19 +1,15 @@ -class Funfriend::FunfriendRenderer - FPS = 10.0 +class Funfriend::BuddyRenderer + getter buddy : Buddy getter shader_program : Program getter vertex_array : VertexArray getter vertex_buffer : Buffer - getter textures : Hash(String, TextureMan::TextureBasket) - - property catmoding : Bool - - def initialize - @catmoding = false + getter textures : TextureMan::TextureBasket + def initialize(@buddy : Buddy) @shader_program = init_shaders @vertex_array, @vertex_buffer = init_buffers - @textures = init_textures + @textures = buddy.textures end def funfriend_size @@ -21,19 +17,6 @@ class Funfriend::FunfriendRenderer {width: funfriend_size, height: funfriend_size} end - def init_textures - return { - "normal" => TextureMan::TextureBasket.new( - (0..39).map { |i| TextureMan.load_texture("assets/funfriend/funfriend_#{i.to_s.rjust(2, '0')}.png") }, - FPS - ), - "cat" => TextureMan::TextureBasket.new( - (0..39).map { |i| TextureMan.load_texture("assets/funfriend/catfriend_#{i.to_s.rjust(2, '0')}.png") }, - FPS - ) - } - end - def init_buffers vertices = { # ------ positions ------- texture coordinates @@ -90,9 +73,8 @@ class Funfriend::FunfriendRenderer LibGL.clear_color(0.0, 0.0, 0.0, 0.0) LibGL.clear(Buffer::Bit::Color) - textures.each_value &.update(dt) - texture_basket = textures[catmoding ? "cat" : "normal"] - frame = texture_basket.texture + textures.update(dt) + frame = textures.texture width, height = frame[:width], frame[:height] diff --git a/src/fontman.cr b/src/fontman.cr index d2ef786..a6e3ea5 100644 --- a/src/fontman.cr +++ b/src/fontman.cr @@ -96,7 +96,7 @@ module Funfriend::FontMan bm_char = sheet[:chars].find! { |c| c[:letter] == char } positions << { x: x + bm_char[:xoffset], - y: sheet[:common][:base] - bm_char[:height], + y: sheet[:common][:base] - bm_char[:height] - bm_char[:yoffset] + (sheet[:common][:line_height] - sheet[:common][:base]), char: bm_char, } x = x + bm_char[:xadvance] diff --git a/src/funfriend.cr b/src/funfriend.cr index 120e9e9..2863849 100644 --- a/src/funfriend.cr +++ b/src/funfriend.cr @@ -12,9 +12,10 @@ require "./configman.cr" require "./textureman.cr" require "./fontman.cr" require "./soundman.cr" +require "./buddies.cr" require "./window_context.cr" -require "./funfriend_context.cr" -require "./funfriend_renderer.cr" +require "./buddy_context.cr" +require "./buddy_renderer.cr" require "./chatter_context.cr" require "./text_renderer.cr" @@ -34,7 +35,7 @@ module Funfriend end def self.init_contexts - add_context(FunfriendContext.new) + add_context(BuddyContext.new(FunfriendBuddy.new)) @@main_context = @@contexts[0] at_exit { contexts.each &.destroy } end