lazy BSTRD buddy addition

This commit is contained in:
Jill 2023-06-04 15:52:16 +03:00
parent 75a7535e4d
commit b9187ebcfb
Signed by: oat
GPG Key ID: 33489AA58A955108
15 changed files with 157 additions and 11 deletions

BIN
assets/buddies/bstrd.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.0 KiB

101
assets/fonts/Newspaper.fnt Normal file
View File

@ -0,0 +1,101 @@
info font="Newspaper Cutout White On Black" size=32 bold=0 italic=0 charset="" unicode=0 stretchH=100 smooth=1 aa=1 padding=2,2,2,2 spacing=2,2
common lineHeight=46 base=34 scaleW=512 scaleH=256 pages=1 packed=0
page id=0 file="Newspaper.png"
chars count=97
char id=80 x=2 y=2 width=25 height=48 xoffset=-2 yoffset=0 xadvance=19 page=0 chnl=0 letter="P"
char id=123 x=29 y=2 width=15 height=46 xoffset=-3 yoffset=0 xadvance=13 page=0 chnl=0 letter="{"
char id=73 x=46 y=2 width=20 height=45 xoffset=-1 yoffset=0 xadvance=15 page=0 chnl=0 letter="I"
char id=77 x=68 y=2 width=25 height=45 xoffset=-2 yoffset=0 xadvance=22 page=0 chnl=0 letter="M"
char id=82 x=95 y=2 width=22 height=45 xoffset=-1 yoffset=0 xadvance=18 page=0 chnl=0 letter="R"
char id=90 x=119 y=2 width=20 height=45 xoffset=-2 yoffset=0 xadvance=17 page=0 chnl=0 letter="Z"
char id=72 x=141 y=2 width=21 height=45 xoffset=-2 yoffset=0 xadvance=18 page=0 chnl=0 letter="H"
char id=79 x=164 y=2 width=21 height=45 xoffset=-1 yoffset=0 xadvance=18 page=0 chnl=0 letter="O"
char id=89 x=187 y=2 width=19 height=44 xoffset=-2 yoffset=0 xadvance=16 page=0 chnl=0 letter="Y"
char id=125 x=208 y=2 width=13 height=44 xoffset=-2 yoffset=0 xadvance=11 page=0 chnl=0 letter="}"
char id=87 x=223 y=2 width=30 height=44 xoffset=-1 yoffset=0 xadvance=26 page=0 chnl=0 letter="W"
char id=78 x=255 y=2 width=21 height=44 xoffset=-1 yoffset=0 xadvance=19 page=0 chnl=0 letter="N"
char id=70 x=278 y=2 width=18 height=44 xoffset=-1 yoffset=0 xadvance=17 page=0 chnl=0 letter="F"
char id=83 x=298 y=2 width=25 height=44 xoffset=-3 yoffset=0 xadvance=21 page=0 chnl=0 letter="S"
char id=81 x=325 y=2 width=21 height=44 xoffset=-2 yoffset=0 xadvance=16 page=0 chnl=0 letter="Q"
char id=86 x=348 y=2 width=23 height=44 xoffset=-2 yoffset=0 xadvance=20 page=0 chnl=0 letter="V"
char id=76 x=373 y=2 width=17 height=44 xoffset=-1 yoffset=0 xadvance=15 page=0 chnl=0 letter="L"
char id=67 x=392 y=2 width=22 height=43 xoffset=-2 yoffset=0 xadvance=19 page=0 chnl=0 letter="C"
char id=71 x=416 y=2 width=21 height=43 xoffset=-2 yoffset=0 xadvance=18 page=0 chnl=0 letter="G"
char id=106 x=439 y=2 width=12 height=43 xoffset=-2 yoffset=0 xadvance=10 page=0 chnl=0 letter="j"
char id=33 x=453 y=2 width=13 height=43 xoffset=0 yoffset=0 xadvance=13 page=0 chnl=0 letter="!"
char id=74 x=468 y=2 width=15 height=43 xoffset=-1 yoffset=0 xadvance=13 page=0 chnl=0 letter="J"
char id=65 x=485 y=2 width=21 height=43 xoffset=-2 yoffset=0 xadvance=19 page=0 chnl=0 letter="A"
char id=66 x=2 y=52 width=23 height=43 xoffset=-2 yoffset=0 xadvance=19 page=0 chnl=0 letter="B"
char id=84 x=27 y=52 width=20 height=43 xoffset=-2 yoffset=0 xadvance=16 page=0 chnl=0 letter="T"
char id=69 x=49 y=52 width=20 height=43 xoffset=-2 yoffset=0 xadvance=17 page=0 chnl=0 letter="E"
char id=75 x=71 y=52 width=24 height=43 xoffset=-2 yoffset=0 xadvance=19 page=0 chnl=0 letter="K"
char id=98 x=97 y=52 width=17 height=43 xoffset=-2 yoffset=0 xadvance=15 page=0 chnl=0 letter="b"
char id=68 x=116 y=52 width=22 height=43 xoffset=-1 yoffset=0 xadvance=19 page=0 chnl=0 letter="D"
char id=88 x=140 y=52 width=23 height=43 xoffset=-2 yoffset=0 xadvance=19 page=0 chnl=0 letter="X"
char id=124 x=165 y=52 width=13 height=42 xoffset=-1 yoffset=0 xadvance=11 page=0 chnl=0 letter="|"
char id=105 x=180 y=52 width=11 height=42 xoffset=-2 yoffset=0 xadvance=9 page=0 chnl=0 letter="i"
char id=47 x=193 y=52 width=26 height=42 xoffset=0 yoffset=0 xadvance=27 page=0 chnl=0 letter="/"
char id=100 x=221 y=52 width=18 height=42 xoffset=-2 yoffset=0 xadvance=15 page=0 chnl=0 letter="d"
char id=40 x=241 y=52 width=12 height=42 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=0 letter="("
char id=104 x=255 y=52 width=18 height=42 xoffset=-2 yoffset=0 xadvance=14 page=0 chnl=0 letter="h"
char id=85 x=275 y=52 width=25 height=42 xoffset=-1 yoffset=0 xadvance=21 page=0 chnl=0 letter="U"
char id=37 x=302 y=52 width=21 height=42 xoffset=0 yoffset=0 xadvance=22 page=0 chnl=0 letter="%"
char id=103 x=325 y=52 width=16 height=42 xoffset=-2 yoffset=0 xadvance=14 page=0 chnl=0 letter="g"
char id=102 x=343 y=52 width=14 height=42 xoffset=-2 yoffset=0 xadvance=12 page=0 chnl=0 letter="f"
char id=41 x=359 y=52 width=12 height=42 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=0 letter=")"
char id=107 x=373 y=52 width=17 height=41 xoffset=-2 yoffset=0 xadvance=14 page=0 chnl=0 letter="k"
char id=108 x=392 y=52 width=12 height=41 xoffset=-2 yoffset=0 xadvance=9 page=0 chnl=0 letter="l"
char id=63 x=406 y=52 width=17 height=41 xoffset=0 yoffset=1 xadvance=18 page=0 chnl=0 letter="?"
char id=64 x=425 y=52 width=22 height=40 xoffset=0 yoffset=0 xadvance=23 page=0 chnl=0 letter="@"
char id=116 x=449 y=52 width=15 height=40 xoffset=-2 yoffset=0 xadvance=12 page=0 chnl=0 letter="t"
char id=113 x=466 y=52 width=20 height=40 xoffset=-1 yoffset=0 xadvance=16 page=0 chnl=0 letter="q"
char id=112 x=488 y=52 width=19 height=39 xoffset=-3 yoffset=0 xadvance=15 page=0 chnl=0 letter="p"
char id=121 x=2 y=97 width=16 height=38 xoffset=-2 yoffset=2 xadvance=12 page=0 chnl=0 letter="y"
char id=51 x=20 y=97 width=15 height=38 xoffset=-1 yoffset=2 xadvance=13 page=0 chnl=0 letter="3"
char id=36 x=37 y=97 width=18 height=38 xoffset=0 yoffset=0 xadvance=17 page=0 chnl=0 letter="$"
char id=52 x=57 y=97 width=17 height=38 xoffset=-2 yoffset=0 xadvance=14 page=0 chnl=0 letter="4"
char id=53 x=76 y=97 width=17 height=38 xoffset=-1 yoffset=1 xadvance=14 page=0 chnl=0 letter="5"
char id=114 x=95 y=97 width=13 height=37 xoffset=-2 yoffset=1 xadvance=10 page=0 chnl=0 letter="r"
char id=115 x=110 y=97 width=17 height=37 xoffset=-3 yoffset=1 xadvance=14 page=0 chnl=0 letter="s"
char id=48 x=129 y=97 width=17 height=37 xoffset=-2 yoffset=3 xadvance=13 page=0 chnl=0 letter="0"
char id=49 x=148 y=97 width=15 height=37 xoffset=-1 yoffset=2 xadvance=13 page=0 chnl=0 letter="1"
char id=92 x=165 y=97 width=13 height=37 xoffset=0 yoffset=1 xadvance=12 page=0 chnl=0 letter="\"
char id=54 x=180 y=97 width=17 height=37 xoffset=-2 yoffset=1 xadvance=14 page=0 chnl=0 letter="6"
char id=50 x=199 y=97 width=15 height=37 xoffset=-1 yoffset=3 xadvance=14 page=0 chnl=0 letter="2"
char id=56 x=216 y=97 width=15 height=37 xoffset=-1 yoffset=2 xadvance=14 page=0 chnl=0 letter="8"
char id=57 x=233 y=97 width=15 height=37 xoffset=-1 yoffset=4 xadvance=13 page=0 chnl=0 letter="9"
char id=55 x=250 y=97 width=14 height=37 xoffset=-1 yoffset=2 xadvance=12 page=0 chnl=0 letter="7"
char id=93 x=266 y=97 width=14 height=36 xoffset=0 yoffset=3 xadvance=14 page=0 chnl=0 letter="]"
char id=120 x=282 y=97 width=19 height=36 xoffset=-1 yoffset=1 xadvance=15 page=0 chnl=0 letter="x"
char id=35 x=303 y=97 width=19 height=36 xoffset=1 yoffset=6 xadvance=20 page=0 chnl=0 letter="#"
char id=117 x=324 y=97 width=17 height=36 xoffset=-1 yoffset=2 xadvance=14 page=0 chnl=0 letter="u"
char id=111 x=343 y=97 width=17 height=35 xoffset=-3 yoffset=5 xadvance=13 page=0 chnl=0 letter="o"
char id=109 x=362 y=97 width=22 height=35 xoffset=-2 yoffset=3 xadvance=19 page=0 chnl=0 letter="m"
char id=110 x=386 y=97 width=17 height=35 xoffset=-2 yoffset=3 xadvance=15 page=0 chnl=0 letter="n"
char id=118 x=405 y=97 width=17 height=35 xoffset=-2 yoffset=3 xadvance=14 page=0 chnl=0 letter="v"
char id=119 x=424 y=97 width=21 height=35 xoffset=-2 yoffset=3 xadvance=19 page=0 chnl=0 letter="w"
char id=97 x=447 y=97 width=16 height=35 xoffset=-2 yoffset=3 xadvance=13 page=0 chnl=0 letter="a"
char id=91 x=465 y=97 width=12 height=35 xoffset=0 yoffset=4 xadvance=12 page=0 chnl=0 letter="["
char id=101 x=479 y=97 width=15 height=35 xoffset=-1 yoffset=2 xadvance=13 page=0 chnl=0 letter="e"
char id=38 x=2 y=137 width=22 height=35 xoffset=0 yoffset=2 xadvance=19 page=0 chnl=0 letter="&"
char id=122 x=26 y=137 width=14 height=35 xoffset=-2 yoffset=2 xadvance=11 page=0 chnl=0 letter="z"
char id=99 x=42 y=137 width=17 height=34 xoffset=-2 yoffset=2 xadvance=14 page=0 chnl=0 letter="c"
char id=59 x=61 y=137 width=11 height=33 xoffset=0 yoffset=2 xadvance=11 page=0 chnl=0 letter=";"
char id=58 x=74 y=137 width=14 height=30 xoffset=0 yoffset=4 xadvance=13 page=0 chnl=0 letter=":"
char id=61 x=90 y=137 width=17 height=25 xoffset=-1 yoffset=10 xadvance=15 page=0 chnl=0 letter="="
char id=43 x=109 y=137 width=17 height=25 xoffset=0 yoffset=9 xadvance=18 page=0 chnl=0 letter="+"
char id=45 x=128 y=137 width=14 height=24 xoffset=0 yoffset=7 xadvance=15 page=0 chnl=0 letter="-"
char id=62 x=144 y=137 width=17 height=21 xoffset=0 yoffset=12 xadvance=17 page=0 chnl=0 letter=">"
char id=60 x=163 y=137 width=16 height=21 xoffset=0 yoffset=12 xadvance=16 page=0 chnl=0 letter="<"
char id=94 x=181 y=137 width=14 height=20 xoffset=0 yoffset=0 xadvance=14 page=0 chnl=0 letter="^"
char id=39 x=197 y=137 width=11 height=18 xoffset=0 yoffset=0 xadvance=12 page=0 chnl=0 letter="'"
char id=46 x=210 y=137 width=10 height=16 xoffset=0 yoffset=26 xadvance=10 page=0 chnl=0 letter="."
char id=44 x=222 y=137 width=11 height=15 xoffset=0 yoffset=27 xadvance=11 page=0 chnl=0 letter=","
char id=34 x=235 y=137 width=14 height=14 xoffset=1 yoffset=0 xadvance=15 page=0 chnl=0 letter="""
char id=126 x=251 y=137 width=15 height=13 xoffset=0 yoffset=14 xadvance=15 page=0 chnl=0 letter="~"
char id=42 x=268 y=137 width=13 height=12 xoffset=0 yoffset=0 xadvance=13 page=0 chnl=0 letter="*"
char id=96 x=283 y=137 width=11 height=11 xoffset=-2 yoffset=0 xadvance=8 page=0 chnl=0 letter="`"
char id=95 x=296 y=137 width=16 height=11 xoffset=0 yoffset=29 xadvance=17 page=0 chnl=0 letter="_"
char id=32 x=314 y=137 width=0 height=0 xoffset=0 yoffset=34 xadvance=11 page=0 chnl=0 letter=" "
char id=127 x=316 y=137 width=0 height=0 xoffset=0 yoffset=34 xadvance=22 page=0 chnl=0 letter=""
kernings count=0

BIN
assets/fonts/Newspaper.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 37 KiB

BIN
assets/sfx/talk_bstrd1.ogg Normal file

Binary file not shown.

BIN
assets/sfx/talk_bstrd2.ogg Normal file

Binary file not shown.

BIN
assets/sfx/talk_bstrd3.ogg Normal file

Binary file not shown.

BIN
assets/sfx/talk_bstrd4.ogg Normal file

Binary file not shown.

BIN
assets/sfx/talk_bstrd5.ogg Normal file

Binary file not shown.

BIN
assets/sfx/talk_bstrd6.ogg Normal file

Binary file not shown.

BIN
assets/sfx/talk_bstrd7.ogg Normal file

Binary file not shown.

BIN
assets/sfx/talk_bstrd8.ogg Normal file

Binary file not shown.

View File

@ -22,6 +22,9 @@ module Funfriend
# Implements the logic for the talk SFX, similar to corru.observer's `talk: () => ...` # Implements the logic for the talk SFX, similar to corru.observer's `talk: () => ...`
abstract def talk_sound abstract def talk_sound
# Returns a base filepath for the font their chatter must use
abstract def font
end end
class FunfriendBuddy < Buddy class FunfriendBuddy < Buddy
@ -67,6 +70,10 @@ module Funfriend
def talk_sound def talk_sound
SoundMan.play_sound("assets/sfx/talk#{(1..8).sample}.ogg") SoundMan.play_sound("assets/sfx/talk#{(1..8).sample}.ogg")
end end
def font
"assets/fonts/SpaceMono"
end
end end
class CatfriendBuddy < FunfriendBuddy class CatfriendBuddy < FunfriendBuddy
@ -108,12 +115,53 @@ module Funfriend
def talk_sound def talk_sound
SoundMan.play_sound("assets/sfx/talk_god#{(1..8).sample}.ogg") SoundMan.play_sound("assets/sfx/talk_god#{(1..8).sample}.ogg")
end end
def font
"assets/fonts/SpaceMono"
end
end
class BstrdBuddy < Buddy
def name : String
"BSTRD"
end
def dialog(type) : Array(Array(String))
case type
when .chatter?
[
[">:)"]
]
else
[] of Array(String)
end
end
def textures : TextureMan::TextureBasket
TextureMan::TextureBasket.new(
[ TextureMan.load_texture("assets/buddies/bstrd.png") ],
10
)
end
def bg_texture : Texture?
nil
end
def talk_sound
SoundMan.play_sound("assets/sfx/talk_bstrd#{(1..8).sample}.ogg")
end
def font
"assets/fonts/Newspaper"
end
end end
BUDDIES = { BUDDIES = {
"funfriend" => FunfriendBuddy, "funfriend" => FunfriendBuddy,
"catfriend" => CatfriendBuddy, "catfriend" => CatfriendBuddy,
"god" => GodBuddy, "god" => GodBuddy,
"bstrd" => BstrdBuddy,
} }
def self.make_buddy(name : String) : Buddy def self.make_buddy(name : String) : Buddy

View File

@ -193,7 +193,7 @@ class Funfriend::BuddyContext < Funfriend::WindowContext
end end
end end
Funfriend.add_context(ChatterContext.new(text, Vec2.new( Funfriend.add_context(ChatterContext.new(text, buddy.font, Vec2.new(
window.position[:x] + window_size.x / 2, window.position[:x] + window_size.x / 2,
window.position[:y] - 20 window.position[:y] - 20
), parent: self)) ), parent: self))

View File

@ -10,8 +10,8 @@ class Funfriend::ChatterContext < Funfriend::WindowContext
PADDING = 10 PADDING = 10
def initialize(text : String, position : Vec2, duration : Float64 = DEFAULT_DURATION, parent : WindowContext? = nil) def initialize(text : String, font : String, position : Vec2, duration : Float64 = DEFAULT_DURATION, parent : WindowContext? = nil)
sheet = FontMan.parse_bm(File.read "assets/fonts/SpaceMono.fnt") sheet = FontMan.parse_bm(File.read "#{font}.fnt")
position_data = FontMan.position_text(text, sheet) position_data = FontMan.position_text(text, sheet)
@ -27,7 +27,7 @@ class Funfriend::ChatterContext < Funfriend::WindowContext
window.make_context_current window.make_context_current
@timer = duration @timer = duration
@renderer = TextRenderer.new(text, sheet, window_size.x_i, window_size.y_i) @renderer = TextRenderer.new(text, font, sheet, window_size.x_i, window_size.y_i)
window.position = (position - window_size / 2).xy_i window.position = (position - window_size / 2).xy_i

View File

@ -1,5 +1,7 @@
class Funfriend::TextRenderer class Funfriend::TextRenderer
getter text : String getter text : String
# TODO: merge into one?
getter font : String
getter sheet : FontMan::BMSheet getter sheet : FontMan::BMSheet
getter width : Int32 getter width : Int32
getter height : Int32 getter height : Int32
@ -9,19 +11,14 @@ class Funfriend::TextRenderer
getter vertex_buffer : Buffer getter vertex_buffer : Buffer
getter font_texture : Texture getter font_texture : Texture
def initialize(text : String, sheet : FontMan::BMSheet, width : Int32, height : Int32) def initialize(@text : String, @font : String, @sheet : FontMan::BMSheet, @width : Int32, @height : Int32)
@text = text
@sheet = sheet
@width = width
@height = height
@shader_program = init_shaders @shader_program = init_shaders
@vertex_array, @vertex_buffer = init_buffers @vertex_array, @vertex_buffer = init_buffers
@font_texture = init_textures @font_texture = init_textures
end end
def init_textures def init_textures
TextureMan.load_texture("assets/fonts/SpaceMono.png", { TextureMan.load_texture("#{font}.png", {
Texture::ParameterName::TextureWrapS => Texture::ParameterValue::ClampToBorder, Texture::ParameterName::TextureWrapS => Texture::ParameterValue::ClampToBorder,
Texture::ParameterName::TextureWrapT => Texture::ParameterValue::ClampToBorder, Texture::ParameterName::TextureWrapT => Texture::ParameterValue::ClampToBorder,
Texture::ParameterName::TextureMinFilter => Texture::ParameterValue::Linear, Texture::ParameterName::TextureMinFilter => Texture::ParameterValue::Linear,