diff --git a/README.md b/README.md index 29297b3..3eecab0 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,21 @@ A dungeon crawler game made with LoveDOS for the DOSember Game Jam https://itch. ## Assets used -- [Click.wav by frosty ham](https://opengameart.org/content/click-0) +### Sprites - [B&W Ornamental Cursor by qubodup](https://opengameart.org/content/bw-ornamental-cursor-19x19) -- [Dogs of Cyberspace by congusbongus](https://modarchive.org/index.php?request=view_by_moduleid&query=207032) - [Microchip texture by ZeptoBARS](https://opengameart.org/content/microchip-texture) +- [Eris in colour by Stephen](https://openclipart.org/detail/329762/eris-in-colour) + +### Sound effects +- [Click.wav by frosty ham](https://opengameart.org/content/click-0) +- [Sci-Fi Sound Effects Library by Little Robot Sound Factory](https://opengameart.org/content/sci-fi-sound-effects-library) + +### Music + +- [Dogs of Cyberspace by congusbongus](https://modarchive.org/index.php?request=view_by_moduleid&query=207032) + +### Fonts + +- [Concrete by Frank Baranowski](https://fontlibrary.org/en/font/concrete) +- [Nemoy by BSozoo](https://fontlibrary.org/en/font/nemoy) +- [Banana Brick by artmaker](https://fontlibrary.org/en/font/banana-brick) diff --git a/fonts/BBrick.ttf b/fonts/BBrick.ttf new file mode 100644 index 0000000..e3e2562 Binary files /dev/null and b/fonts/BBrick.ttf differ diff --git a/fonts/Concrete.ttf b/fonts/Concrete.ttf new file mode 100644 index 0000000..d068098 Binary files /dev/null and b/fonts/Concrete.ttf differ diff --git a/imgs/bckg.png b/imgs/bckg.png deleted file mode 100644 index b137ed2..0000000 Binary files a/imgs/bckg.png and /dev/null differ diff --git a/imgs/splash.png b/imgs/splash.png new file mode 100644 index 0000000..0aa2a8b Binary files /dev/null and b/imgs/splash.png differ diff --git a/imgs/title.png b/imgs/title.png new file mode 100644 index 0000000..6993c1d Binary files /dev/null and b/imgs/title.png differ diff --git a/imgs/wally.png b/imgs/wally.png new file mode 100644 index 0000000..e26d8fe Binary files /dev/null and b/imgs/wally.png differ diff --git a/main.lua b/main.lua index f656644..d62936b 100644 --- a/main.lua +++ b/main.lua @@ -14,14 +14,33 @@ local Fader = require 'src.fader' Current_state = 1 Fade = Fader() Change_state = false +Debug = false + + +------------------------------------------------------------------------------ +-- Helper methods +------------------------------------------------------------------------------ + +local function parse_args(args) + for _, v in pairs(args) do + + -- Enable debug mode. + if v == '-debug' then Debug = true end + end +end ------------------------------------------------------------------------------ -- Game methods ------------------------------------------------------------------------------ -function love.load() +function love.load(args) + parse_args(args) + + -- Load the assets of the intro game state. game_states[Current_state]:load() + + -- Call a fade in after the intro assets are loaded. Fade:fade_in() end @@ -61,21 +80,43 @@ function love.draw() love.graphics.clear() game_states[Current_state]:draw() Fade:draw() -end - -function love.keypressed(key) - -- Send events to the active game state if there is no fade active. - if Fade.done then - game_states[Current_state]:keypressed(key) + if Debug then + love.graphics.print(string.format('OS: %s', love.system.getOS()), 5, 5) + love.graphics.print(string.format('Love version: %s', love.getVersion()), 5, 15) + love.graphics.print(string.format('Memory usage: %s KiB', love.system.getMemUsage()), 5, 25) end end -function love.mousemoved(x, y) +function love.keypressed(key, code, isrepeat) -- Send events to the active game state if there is no fade active. if Fade.done then - game_states[Current_state]:mousemoved(x, y) + game_states[Current_state]:keypressed(key, code, isrepeat) + end +end + + +function love.keyreleased(key, code) + -- Send events to the active game state if there is no fade active. + if Fade.done then + game_states[Current_state]:keyreleased(key, code) + end +end + + +function love.textinput(text) + -- Send events to the active game state if there is no fade active. + if Fade.done then + game_states[Current_state]:textinput(text) + end +end + + +function love.mousemoved(x, y, dx, dy) + -- Send events to the active game state if there is no fade active. + if Fade.done then + game_states[Current_state]:mousemoved(x, y, dx, dy) end end @@ -86,3 +127,11 @@ function love.mousepressed(x, y, btn) game_states[Current_state]:mousemoved(x, y, btn) end end + + +function love.mousereleased(x, y, btn) + -- Send events to the active game state if there is no fade active. + if Fade.done then + game_states[Current_state]:mousereleased(x, y, btn) + end +end diff --git a/snd/ablhole.wav b/snd/ablhole.wav new file mode 100644 index 0000000..dffd184 Binary files /dev/null and b/snd/ablhole.wav differ diff --git a/snd/ablhole2.wav b/snd/ablhole2.wav new file mode 100644 index 0000000..61926ce Binary files /dev/null and b/snd/ablhole2.wav differ diff --git a/snd/alang.wav b/snd/alang.wav new file mode 100644 index 0000000..b7cb76c Binary files /dev/null and b/snd/alang.wav differ diff --git a/snd/jachiev.wav b/snd/jachiev.wav new file mode 100644 index 0000000..35d7afd Binary files /dev/null and b/snd/jachiev.wav differ diff --git a/src/fader.lua b/src/fader.lua index aaf30af..c0679b2 100644 --- a/src/fader.lua +++ b/src/fader.lua @@ -22,6 +22,7 @@ function Fader:_init() self.step = 0 self.done = true self.reverse = false + self.callback = nil end @@ -32,15 +33,17 @@ function Fader:_reset() end -function Fader:fade_in() +function Fader:fade_in(callback) self:_reset() self.reverse = true + self.callback = callback end -function Fader:fade_out() +function Fader:fade_out(callback) self:_reset() self.reverse = false + self.callback = callback end @@ -53,7 +56,13 @@ function Fader:update(dt) self.t = 0.0 end - if self.step > 175 then self.done = true end + if self.step > 175 then + self.done = true + if self.callback ~= nil then + self.callback() + self.callback = nil + end + end end end @@ -78,10 +87,6 @@ function Fader:draw() end love.graphics.setColor() --- love.graphics.print(string.format('t: %s', self.t), 5, 35) --- love.graphics.print(string.format('step: %s', self.step), 5, 45) --- love.graphics.print(string.format('W: %s', love.graphics.getWidth()), 5, 55) --- love.graphics.print(string.format('H: %s', love.graphics.getHeight()), 5, 65) end diff --git a/src/gstate.lua b/src/gstate.lua index 6523738..6c6c155 100644 --- a/src/gstate.lua +++ b/src/gstate.lua @@ -39,11 +39,20 @@ end function GameState:unload() end -function GameState:keypressed(_) + +function GameState:keypressed(_, _ , _) end -function GameState:mousemoved(_, _) +function GameState:textinput(_) +end + + +function GameState:keyreleased(_, _) +end + + +function GameState:mousemoved(_, _, _, _) end @@ -51,6 +60,9 @@ function GameState:mousepressed(_, _, _) end +function GameState:mousereleased(_, _, _) +end + ------------------------------------------------------------------------------ -- Module return ------------------------------------------------------------------------------ diff --git a/src/intro.lua b/src/intro.lua index c039805..5db3de2 100644 --- a/src/intro.lua +++ b/src/intro.lua @@ -5,6 +5,7 @@ local love = require 'love' local make_class = require 'src.classes' local GameState = require 'src.gstate' +local Fader = require 'src.fader' ------------------------------------------------------------------------------ @@ -19,37 +20,83 @@ local Intro = make_class(GameState) ------------------------------------------------------------------------------ function Intro:_init(name, index) - -- Call super-class constructor. GameState._init(self, name, index) - - -- Attribute definitions self.skip = false + self.fade = Fader() + self.stage = 0 + self.timer = 0 end function Intro:load() - self.background = love.graphics.newImage('imgs/cpu.png') + self.splash = love.graphics.newImage('imgs/splash.png') + self.author = love.graphics.newImage('imgs/wally.png') + self.title = love.graphics.newImage('imgs/title.png') + self.splash_snd = love.audio.newSource('snd/jachiev.wav') + self.author_snd = love.audio.newSource('snd/alang.wav') + self.title_snd = love.audio.newSource('snd/ablhole.wav') self.valid = true + + self.splash_snd:play() end -function Intro:update(_) - if not self.skip then return self.index else return 0 end +function Intro:update(dt) + local total_time + + if self.stage == 0 then + total_time = 4.5 + elseif self.stage == 1 then + total_time = 3.0 + else + total_time = 8.0 + end + + if self.fade.done then + self.timer = self.timer + dt + end + + if self.timer >= total_time then + self.fade:fade_out( + function () + self.stage = self.stage + 1 + + if self.stage == 1 then + self.author_snd:play() + elseif self.stage == 2 then + self.title_snd:play() + end + + self.fade:fade_in() + end + ) + self.timer = 0.0 + end + + self.fade:update(dt) + + if not self.skip and self.stage < 3 then return self.index else return 2 end end function Intro:draw() if self.valid then - love.graphics.draw(self.background, 0, 0) - love.graphics.print(string.format('OS: %s', love.system.getOS()), 5, 5) - love.graphics.print(string.format('Love version: %s', love.getVersion()), 5, 15) - love.graphics.print(string.format('Memory usage: %s KiB', love.system.getMemUsage()), 5, 25) + if self.stage == 0 then love.graphics.draw(self.splash, 0, 0) + elseif self.stage == 1 then love.graphics.draw(self.author, 0, 0) + elseif self.stage == 2 then love.graphics.draw(self.title, 0, 0) end end + + self.fade:draw() end function Intro:unload() - self.background = nil + self.splash = nil + self.author = nil + self.title = nil + self.splash_snd = nil + self.author_snd = nil + self.title_snd = nil self.valid = false end