Compare commits

...

2 Commits

Author SHA1 Message Date
7fa8807c1a Added intro game state and placeholder assets. 2025-09-28 14:56:43 -04:00
0023c0a0a2 Added Fader class. 2025-09-28 12:54:17 -04:00
15 changed files with 243 additions and 57 deletions

View File

@@ -4,7 +4,20 @@ 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)
### 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)

BIN
fonts/BBrick.ttf Normal file

Binary file not shown.

BIN
fonts/Concrete.ttf Normal file

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 15 KiB

BIN
imgs/splash.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
imgs/title.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
imgs/wally.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

101
main.lua
View File

@@ -4,6 +4,7 @@
local love = require 'love'
local game_states = require 'src.states'
local Fader = require 'src.fader'
------------------------------------------------------------------------------
@@ -11,18 +12,21 @@ local game_states = require 'src.states'
------------------------------------------------------------------------------
Current_state = 1
Fade_in = 0.0
Fade_out = 1.0
Fade = Fader()
Change_state = false
Debug = false
------------------------------------------------------------------------------
-- Game methods
-- Helper methods
------------------------------------------------------------------------------
local function lerp(a, b, t)
-- Linear interpolation between two values a and b, by a t between 0.0 and 1.0
return (a * t) + (b * (1.0 - t))
local function parse_args(args)
for _, v in pairs(args) do
-- Enable debug mode.
if v == '-debug' then Debug = true end
end
end
@@ -30,8 +34,14 @@ 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
@@ -39,82 +49,89 @@ function love.update(dt)
local new_state = game_states[Current_state]:update(dt)
-- If the game state changed then trigger a fade out.
if new_state ~= Current_state and Fade_out >= 1.0 then
Fade_out = 0.0
if new_state ~= Current_state and Fade.done then
Fade:fade_out()
Change_state = true
end
-- If there is a fade in going then update it.
if Fade_in < 1.0 then
Fade_in = Fade_in + (dt / 2)
end
-- If there is a fade out going then update it.
if Fade_out < 1.0 then
Fade_out = Fade_out + (dt / 2)
end
Fade:update(dt)
-- Update the game state.
if game_states[new_state] == nil then
-- If the new state doesn't exist then wait for the fade out to end and quit.
if Fade_out >= 1.0 then
if Fade.done then
game_states[Current_state]:unload(dt)
love.event.quit()
end
else
-- If the new state exists then unload it's data and set the new state.
if Change_state and Fade_out >= 1.0 then
if Change_state and Fade.done then
game_states[Current_state]:unload(dt)
Current_state = new_state
game_states[Current_state]:load()
Change_state = false
Fade:fade_in()
end
end
end
function love.draw()
-- Reset the drawing color and clear the screen.
love.graphics.clear()
-- Render the current game state.
game_states[Current_state]:draw()
Fade:draw()
-- If there is a fade in going then render it.
if Fade_in < 1.0 then
love.graphics.setColor(0, 0, 0)
love.graphics.circle('fill', -320, love.graphics.getHeight() / 2, lerp(0, 400 * 2, Fade_in))
love.graphics.setColor()
end
-- If there is a fade out going then render it.
if Fade_out < 1.0 then
love.graphics.setColor(0, 0, 0)
love.graphics.circle('fill', -320, love.graphics.getHeight() / 2, lerp(400 * 2, 0, Fade_out))
love.graphics.setColor()
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.keypressed(key)
function love.keypressed(key, code, isrepeat)
-- Send events to the active game state if there is no fade active.
if Fade_in >= 1.0 and Fade_out >= 1.0 then
game_states[Current_state]:keypressed(key)
if Fade.done then
game_states[Current_state]:keypressed(key, code, isrepeat)
end
end
function love.mousemoved(x, y)
function love.keyreleased(key, code)
-- Send events to the active game state if there is no fade active.
if Fade_in >= 1.0 and Fade_out >= 1.0 then
game_states[Current_state]:mousemoved(x, y)
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
function love.mousepressed(x, y, btn)
-- Send events to the active game state if there is no fade active.
if Fade_in >= 1.0 and Fade_out >= 1.0 then
if Fade.done then
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

BIN
snd/ablhole.wav Normal file

Binary file not shown.

BIN
snd/ablhole2.wav Normal file

Binary file not shown.

BIN
snd/alang.wav Normal file

Binary file not shown.

BIN
snd/jachiev.wav Normal file

Binary file not shown.

97
src/fader.lua Normal file
View File

@@ -0,0 +1,97 @@
------------------------------------------------------------------------------
-- Imports
------------------------------------------------------------------------------
local love = require 'love'
local make_class = require 'src.classes'
------------------------------------------------------------------------------
-- Class definitions
------------------------------------------------------------------------------
local Fader = make_class()
------------------------------------------------------------------------------
-- Class methods
------------------------------------------------------------------------------
function Fader:_init()
self.t = 0.0
self.step = 0
self.done = true
self.reverse = false
self.callback = nil
end
function Fader:_reset()
self.t = 0
self.step = 0
self.done = false
end
function Fader:fade_in(callback)
self:_reset()
self.reverse = true
self.callback = callback
end
function Fader:fade_out(callback)
self:_reset()
self.reverse = false
self.callback = callback
end
function Fader:update(dt)
if not self.done then
self.t = self.t + dt
if self.t >= 0.009 then
self.step = self.step + 1
self.t = 0.0
end
if self.step > 175 then
self.done = true
if self.callback ~= nil then
self.callback()
self.callback = nil
end
end
end
end
function Fader:draw()
local c = 0
love.graphics.setColor(0, 0, 0)
for i = 0, 16 do
for j = 0, 10 do
if not self.reverse then
if c <= self.step then
love.graphics.rectangle('fill', 20 * i, 20 * j, 20, 20)
end
else
if c <= self.step then else
love.graphics.rectangle('fill', 20 * i, 20 * j, 20, 20)
end
end
c = c + 1
end
end
love.graphics.setColor()
end
------------------------------------------------------------------------------
-- Module return
------------------------------------------------------------------------------
return Fader

View File

@@ -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
------------------------------------------------------------------------------

View File

@@ -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