Commit 57d541b4 authored by Delisa Mason's avatar Delisa Mason

feat: Add DSL for generating cutscenes

parents 58b8535b 31081c89
......@@ -28,6 +28,11 @@ in turn lists for the start input and pushes the
[`level`](game/states/level.lua) state. The core gameplay occurs in the level
state.
The [`scene`](game/states/scene.lua) state loads and plays cutscene files. There
is an example cutscene which plays before the first level in
[`intro.scene`](game/assets/scenes/intro.scene). Cutscene files use a DSL for
defining map, sprite, image, and audio interactions as groups of animations.
## Systems
Level logic is divided into systems which manipulate game data based on input
......
load_resources {
map_add("level01", "game/assets/maps/level01/init.lua"),
sprite_add("player", "game/assets/images/player.png", 16, 0, 16, 16),
audio_add("explosion", "game/assets/sounds/explosion.wav"),
}
all_groups {
map_draw("level01"),
camera_follow("level01", "player"),
}
group {
sprite_draw("player", 640, 120, 10, 10),
sprite_move("player", -410, 0, 4),
}
group {
sprite_draw("player", 230, 110, 10, 10),
sprite_scale("player", 1, 1, 3),
sprite_move("player", -30, 200, 3),
sprite_rotate("player", 2.1, 3),
auto_dialog(240, 10, 3, "We are gonna crash!!"),
}
group {
audio_play("explosion"),
sprite_draw("player", 200, 310, 1, 1, 2.1),
screen_shake(1, 4, 60),
wait(3)
}
group {
sprite_draw("player", 200, 310, 1, 1, 2.1),
auto_dialog(200, 200, 4, "Where are we?"),
auto_dialog(140, 430, 4, "Let's get out of here!"),
}
group {
sprite_draw("player", 200, 310, 1, 1, 2.1),
screen_fade(1, {0, 0, 0, 255}),
}
This diff is collapsed.
local Gamestate = require 'lib.gamestate'
local RenderMapSystem = require 'game.systems.render_map'
local PlayerInputSystem = require 'game.systems.player_input'
local MovementSystem = require 'game.systems.movement'
local TriggerSystem = require 'game.systems.trigger'
local MapLoader = require 'game.map_loader'
local HooksLoader = require 'game.hooks_loader'
local SceneState = require 'game.states.scene'
local state = {}
function state:enter(_, level_index)
self.level_index = level_index
local map_path = string.format("game/assets/maps/level%02d/init.lua", level_index)
self.levelstate = MapLoader(map_path)
self.hooks_loader = HooksLoader(level_index, self.levelstate.map)
self.systems = require 'game.systems'
self.systems.add(PlayerInputSystem())
self.systems.add(RenderMapSystem())
self.systems.add(MovementSystem(self.levelstate.player, self.levelstate.map))
self.systems.add(TriggerSystem(self.hooks_loader))
Gamestate.push(SceneState, "game/assets/scenes/intro.scene")
end
function state:resume(prev)
if prev.__animation == true then
local map_path = string.format("game/assets/maps/level%02d/init.lua", self.level_index)
self.levelstate = MapLoader(map_path)
self.hooks_loader = HooksLoader(self.level_index, self.levelstate.map)
self.systems = require 'game.systems'
self.systems.add(PlayerInputSystem())
self.systems.add(RenderMapSystem())
self.systems.add(MovementSystem(self.levelstate.player, self.levelstate.map))
self.systems.add(TriggerSystem(self.hooks_loader))
end
end
function state:draw()
......
local Gamestate = require 'lib.gamestate'
local SceneLoader = require 'game.scene_loader'
local state = {__animation = true}
function state:enter(_, scene_file_path)
self.scene = SceneLoader(scene_file_path)
end
function state:draw()
self.scene.draw()
end
function state:update(dt)
self.scene.update(dt)
if self.scene.done == true then
Gamestate.pop()
end
end
function state:keydown(key, code)
end
function state:keyreleased(key, code)
if self.scene.awaiting_dialog_keyreleased and key == 'space' then
self.scene.dialogkeyreleased()
end
end
return state
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment