Hi,
One time I had a sudden thought.
Actually how hard would it be to write a light novel like game using Elixir?
I have played a bit with CSS code and created a dialog message and then I have realized that basically I can render it as component, add more assets like background image, maybe some sounds and it should not be a problem to create a simple game that I can enhance part by part later seeing effects of my work relatively fast and that become my guilty pleasure.
Before I have realized I wrote few macros and somehow it turn into a fully working hex package.
With this package you basically do not have to worry about game logic. You have to simply input data into DSL and start using it by rendering the prepared structs in LiveView
or Scenic
app - just like you do it for other assigns.
What’s best if you use your gettext_module
as an option then you have gettext
support out of the box (including extracting messages by gettext tasks).
Below is a content of the README file. Let me know what do you think about it.
DevJoy
A package to simplify creation of Visual Novel games.
Installation
def deps do
[
{:dev_joy, "~> 1.0"}
]
end
- Create a new
phoenix
orscenic
project or just use existing one - Add
dev_joy
to your dependencies - Add English content using DSL
- Add assets to your game
- Fetch your first scene
- Draw your game following output of
current_scene_module.get_part()
orcurrent_scene_module.get_part(part_name)
- Optionally translate content using gettext (call
mix gettext.extract
).
Except drawing you only have to provide a content to the game. To “draw” your game all you need to do is to convert structs into phoenix
templates or scenic
graphs and style them respectively.
Example scenes
Main menu
defmodule MyApp.Scenes.Main do
use DevJoy.Scene
alias MyApp.Scenes.FirstStage
alias MyApp.Scenes.SecondStage
alias MyApp.Scenes.ThirdStage
part :main do
menu "Welcome in MyApp!" do
asset "/assets/main/background1.jpg", size: :stretch_to_fit, type: :backgound
asset "/assets/main/background1.mp3", loop: true, type: :background
choice "First stage", goto(FirstStage, :main)
choice "Second stage", goto(SecondStage, :main)
choice "Third stage", goto(ThirdStage, :main)
choice "Settings", goto(:settings)
choice "Credits", goto(:credits)
end
end
part :credits do
dialog :admin, "Assets: me (spend lots of time on search for free image and sounds)"
dialog :admin, "Scenario: me (generated it by AI)"
dialog :admin, "Translations: me (I'm just young kid, so nobody would notice that I have used some random free translator)"
dialog :admin, "Game fun: … (on TODO list already!)"
dialog :admin, "Aren't I the best? >^·^<"
goto()
end
part :settings do
dialog :admin, "Still working on it …"
dialog :admin, "Are you stil here ?!?!"
dialog :admin, "Oh, please! There are no achievements in this game!"
dialog :admin, "Seriously …"
dialog :admin, "Oh, right! I haven't instructed the game to navigate you back to main menu!"
goto()
end
end
Your game’s first stage
defmodule MyApp.Scenes.FirstStage do
use DevJoy.Scene
alias MyApp.Scenes.Main
alias MyApp.Scenes.SecondStage
part :main do
asset "/assets/first-stage/background1.jpg", size: :stretch_to_fit, type: :backgound
asset "/assets/first-stage/background1.mp3", loop: false, type: :foreground
dialog :admin, "Lorem ipsum …"
challenge :input_next_words, count: 3, for: "Lorem ipsum"
asset "/assets/first-stage/admin-bored.jpg", duration: "0.5s", type: :preview
question :admin, "Aren't you tired already?" do
choice "Yes! I'm done!", goto(Main, :main)
choice "Why? Isn't that just a start?", goto(SecondStage, :main)
end
end
end