85 lines
1.7 KiB
Crystal
85 lines
1.7 KiB
Crystal
require "crystglfw"
|
|
require "lib_glfw"
|
|
require "crystgl"
|
|
require "crystimage"
|
|
|
|
require "./log.cr"
|
|
require "./ease.cr"
|
|
require "./vec2.cr"
|
|
require "./gl.cr"
|
|
require "./file_storage.cr"
|
|
require "./configman.cr"
|
|
require "./textureman.cr"
|
|
require "./fontman.cr"
|
|
require "./soundman.cr"
|
|
require "./buddies.cr"
|
|
require "./window_context.cr"
|
|
require "./buddy_context.cr"
|
|
require "./buddy_renderer.cr"
|
|
require "./chatter_context.cr"
|
|
require "./text_renderer.cr"
|
|
|
|
include CrystGLFW
|
|
include CrystGL
|
|
|
|
module Funfriend
|
|
VERSION = "0.1.0"
|
|
|
|
LOG = ::Log.for("")
|
|
|
|
@@contexts = [] of WindowContext
|
|
@@main_context : WindowContext?
|
|
|
|
def self.should_close?
|
|
@@main_context && @@main_context.not_nil!.window.should_close?
|
|
end
|
|
|
|
def self.init_contexts
|
|
ConfigMan.config["buddies"]["types"].as(String).split(",").each do |buddy_name|
|
|
add_context(BuddyContext.new(make_buddy(buddy_name)))
|
|
end
|
|
@@main_context = @@contexts[0]
|
|
at_exit { contexts.each &.destroy }
|
|
end
|
|
|
|
def self.add_context(context : WindowContext)
|
|
@@contexts << context
|
|
end
|
|
|
|
def self.contexts
|
|
@@contexts
|
|
end
|
|
|
|
def self.run
|
|
Logging.init
|
|
|
|
ConfigMan.init
|
|
SoundMan.init
|
|
|
|
CrystGLFW.run do
|
|
init_contexts
|
|
|
|
last_t = CrystGLFW.time
|
|
until should_close?
|
|
dt = CrystGLFW.time - last_t
|
|
last_t = CrystGLFW.time
|
|
|
|
@@contexts = @@contexts.select do |context|
|
|
if context.window.should_close?
|
|
context.close
|
|
at_exit { context.clean_up }
|
|
false
|
|
else
|
|
context.update(dt)
|
|
true
|
|
end
|
|
end
|
|
|
|
CrystGLFW.wait_events(1/120)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
Funfriend.run
|