Introduction
I used to play a lot of MMORPGs.
If you’ve ever looted a Magic Plate Armor in Tibia, you know how exciting that can be. But these days, I don’t have time to spend hours hunting virtual monsters.
So here’s the idea: how can you still enjoy the thrill of loot and leveling up without all the grinding? Let’s build a simple Idle RPG game where your hero goes on missions, levels up, and gathers loot - all while you focus on other things.
Goal
The goal is to build a simple backend for an Idle RPG game using Scala 3. We’ll create a REST API that allows players to manage their heroes, missions, and loot.
We’ll explore well-known libraries and common coding styles as we go. The aim is to keep this blog post series simple and easy to follow, making it accessible to anyone who wants to learn Scala through a fun project.
Code Editor
I’ll be using IntelliJ IDEA with the Scala plugin for this project. Alternatively, you can use Metals with VSCode or Vim .
Start new project
To create a new project, follow the IntelliJ IDEA with the Scala plugin guide or Building a Scala Project with IntelliJ and sbt .
Make sure to select sbt
as a build system, and Scala 3.6.x. Also, select Add sample code
to create a simple main.scala
file:
You should end up with a project structure similar to this .
Now, let’s make sure everything is working. While being in your new project in IntelliJ, open the main.scala
file, and you should see a green Play button. Click it to run the program (or even better, use the keyboard shortcut):
You can also run the program from the command line using sbt:
sbt run
You should see the following output:
Hello world!
Scalafmt
Let’s keep our code clean from the start. We’ll use Scalafmt to format our code. Here are the installation instructions. I recommend turning on the Format on save option.
You don’t need to worry about the details of the configuration for now. If you don’t have your own formatting preferences, feel free to copy the current state of the .scalafmt.conf
file from the repository
.
Summary
Now, we have everything we need to start building! In the next part, we’ll start modeling our game.