2023-05-30 15:47:50 +02:00
|
|
|
require "crystglfw"
|
|
|
|
require "lib_glfw"
|
|
|
|
require "crystgl"
|
|
|
|
require "crystimage"
|
|
|
|
|
|
|
|
require "./log.cr"
|
2023-05-31 12:38:50 +02:00
|
|
|
require "./ease.cr"
|
2023-06-01 19:14:34 +02:00
|
|
|
require "./vec2.cr"
|
2023-05-30 15:47:50 +02:00
|
|
|
require "./gl.cr"
|
2023-06-02 11:35:26 +02:00
|
|
|
require "./file_storage.cr"
|
2023-06-01 12:41:01 +02:00
|
|
|
require "./configman.cr"
|
2023-05-30 15:47:50 +02:00
|
|
|
require "./textureman.cr"
|
|
|
|
require "./fontman.cr"
|
2023-05-31 12:14:38 +02:00
|
|
|
require "./soundman.cr"
|
2023-05-30 15:47:50 +02:00
|
|
|
require "./window_context.cr"
|
|
|
|
require "./funfriend_context.cr"
|
|
|
|
require "./funfriend_renderer.cr"
|
|
|
|
require "./chatter_context.cr"
|
|
|
|
require "./text_renderer.cr"
|
|
|
|
|
|
|
|
include CrystGLFW
|
|
|
|
include CrystGL
|
|
|
|
|
2023-05-29 14:55:38 +02:00
|
|
|
module Funfriend
|
|
|
|
VERSION = "0.1.0"
|
|
|
|
|
2023-05-30 15:47:50 +02:00
|
|
|
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
|
|
|
|
add_context(FunfriendContext.new)
|
|
|
|
@@main_context = @@contexts[0]
|
2023-05-31 12:14:38 +02:00
|
|
|
at_exit { contexts.each &.destroy }
|
2023-05-30 15:47:50 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.add_context(context : WindowContext)
|
|
|
|
@@contexts << context
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.contexts
|
|
|
|
@@contexts
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.run
|
|
|
|
Logging.init
|
|
|
|
|
2023-06-01 12:41:01 +02:00
|
|
|
ConfigMan.init
|
2023-05-31 12:14:38 +02:00
|
|
|
SoundMan.init
|
|
|
|
|
2023-05-30 15:47:50 +02:00
|
|
|
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
|
2023-05-31 12:14:38 +02:00
|
|
|
at_exit { context.clean_up }
|
2023-05-30 15:47:50 +02:00
|
|
|
false
|
|
|
|
else
|
|
|
|
context.update(dt)
|
|
|
|
true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
CrystGLFW.wait_events(1/120)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2023-05-29 14:55:38 +02:00
|
|
|
end
|
2023-05-30 15:47:50 +02:00
|
|
|
|
|
|
|
Funfriend.run
|