From: Randy McShandy Date: Fri, 7 Nov 2025 04:47:22 +0000 (-0600) Subject: Fill out some more framework for configuration and asset management. Export script... X-Git-Url: http://git.mcshandy.xyz/gitweb.cgi?a=commitdiff_plain;h=e660bb7e40c3bced6c470ea6974a18b8ef5383d3;p=sumeriangame Fill out some more framework for configuration and asset management. Export script and track this one. --- diff --git a/main/.love-file b/main/.love-file index e69de29..e1ef230 100644 --- a/main/.love-file +++ b/main/.love-file @@ -0,0 +1,6 @@ +main.lua +conf.lua +assets.lua +assets/Intro.wav +assets/SantakkuM.ttf +assets/transition1.wav diff --git a/main/assets.lua b/main/assets.lua new file mode 100644 index 0000000..8c898e2 --- /dev/null +++ b/main/assets.lua @@ -0,0 +1,42 @@ +-- assets.lua +-- Asset storage + +-- You need a cuneiform font for this one +IntroMessage = "\n𒊩𒌆𒋼𒀯𒀭𒁶𒈨𒂗\n𒁓𒋧𒈠𒃲\n𒍣𒂵" + +local assets = {} + +AssetClass = +{ + Image = 1, + Font = 2, + AudioSource = 3, +} + +local AssetTables = {} +for k,v in pairs(AssetClass) do + table.insert(AssetTables, {}) +end + +function assets.store_font(name, path, font_size) + local new = love.graphics.newFont(path, font_size) + AssetTables[AssetClass.Font][name] = new +end + +function assets.get_font(name) + return AssetTables[AssetClass.Font][name] +end + +function assets.store_source(name, path, source_type) + AssetTables[AssetClass.AudioSource][name] = love.audio.newSource(path, source_type) +end + +function assets.get_source(name) + return AssetTables[AssetClass.AudioSource][name] +end + +assets.store_font("Cuneiform16", "assets/SantakkuM.ttf", 36) +assets.store_source("intro", "assets/Intro.wav", "static") +assets.store_source("transition1", "assets/transition1.wav", "static") + +return assets diff --git a/main/conf.lua b/main/conf.lua new file mode 100644 index 0000000..6266e39 --- /dev/null +++ b/main/conf.lua @@ -0,0 +1,22 @@ +-- conf.lua +-- All shared configuration options + +local config = {} + +-- Members of this table should conform to the config scheme described at https://www.love2d.org/wiki/Config_Files +-- and will be automatically passed to Love in the callback below +config.window = +{ + width = 800, + height = 600, + title = "title", + fullscreen = false +} + +function love.conf(t) + for k,v in pairs(config.window) do + t.window[k] = v + end +end + +return config diff --git a/main/export/game.love b/main/export/game.love new file mode 100644 index 0000000..29cb294 Binary files /dev/null and b/main/export/game.love differ diff --git a/main/love_export.sh b/main/love_export.sh new file mode 100755 index 0000000..05fd4ff --- /dev/null +++ b/main/love_export.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +if [[ -f export/game.love ]]; then + rm export/game.love +fi +cat .love-file | zip -r export/game.love -@ diff --git a/main/main.lua b/main/main.lua index 49b9e9c..e1acc53 100644 --- a/main/main.lua +++ b/main/main.lua @@ -1,4 +1,11 @@ +-- main.lua + +local conf = require('conf') +local assets = require('assets') + function love.load() + love.graphics.setFont(assets.get_font('Cuneiform16')) + love.audio.play(assets.get_source("intro")) end function love.update(delta_time) @@ -8,4 +15,5 @@ function love.keypressed(key) end function love.draw() + love.graphics.print(IntroMessage, math.floor((conf.window.width/16) * 1), math.floor((conf.window.height/16) * 1)) end