About
Scala DSL OpenGL LWJGL stb_truetype stb_image GLSL
This was a pretty fun project that I did in a team of two for the Programming Language Implementation course at my university. We implemented a DSL for writing visual novels in Scala, inspired by Ren'Py's script language. As a demonstration, we ported over a condensed version of The Question. I implemented the scene graph/2d rendering and some parts of the DSL.
Try it out online! Presentation slides View source code @ GitHub
Team Members
- Paul Tan
- Yip Bing You
The DSL
This is how the cut-down version of *The Question* looks like in Ren'Py script:
# Declare characters used by this game.
define s = Character(_("Sylvie"), color="#c8ffc8")
define m = Character(_("Me"), color="#c8c8ff")
# The game starts here.
label start:
scene bg uni with fade
"When we come out of the university, I spot her right away."
show sylvie green normal with dissolve
"Sylvie's got a big heart and she's always been a good friend to me."
menu:
"As soon as she catches my eye, I decide..."
"To ask her right away.":
jump rightaway
"To ask her later.":
jump later
label rightaway:
show sylvie green smile
m "Are you going home now? Wanna walk back with me?"
s "Why not?"
scene black with dissolve
"{b}Good Ending{/b}."
return
label later:
"I can't get up the nerve to ask right now. With a gulp, I decide to ask her later."
scene black with dissolve
"{b}Bad Ending{/b}."
return
And this is how it looks like in our Scala DSL:
object Game {
// Declare characters used by this game.
val s = new Character("Sylvie", color = "#abcdef")
val m = new Character("Me", color = "#c8c8ff")
// The game starts here.
def run(): Future[Unit] =
scene("bg uni") |>
"When we come out of the university, I spot her right away." |>
show("sylvie green normal") |>
"Sylvie's got a big heart and she's always been a good friend to me." |>
menu("As soon as she catches my eye, I decide...",
("To ask her right away.", rightaway),
("To ask her later.", later))
def rightaway(): Future[Unit] =
show("sylvie green smile") |>
m :< "Are you going home now? Wanna walk back with me?" |>
s :< "Why not?" |>
sceneBlack() |>
"Good Ending."
def later(): Future[Unit] =
"I can't get up the nerve to ask right now. With a gulp, I decide to ask her later." |>
sceneBlack() |>
"Bad Ending."
}
See our presentation slides for more information on how it was implemented.
Gallery
Copyright Notice
Assets used in this project are taken from the Ren'Py Project repository, which is licensed under the MIT license.