Category Archives: Programming

Building and publishing a Godot websocket server on Dokku

The title is quite specific, but I would have loved to have this article around when I moved my game Sumur from its old hosting at IBM Code Engine and to my own Dokku server. Also, I remember having had some issues packaging the game in a docker to begin with, so here is a short explanation of how that can be done. I am sure there are other ways.

Godot websocket server in a Docker

Lets start with the Dockerfile:

FROM ubuntu:22.04

WORKDIR /app
COPY . .
RUN mkdir logs

EXPOSE 8080
CMD ["./game"]

As you can see, this is not all that impressive. We expose port 8080 (the server code is configured to listen on that port of course) and run the game. But what is this “game” that is being run?

Good question. It is not the executeable that Godot will give you as a result if building for Linux. Its rather the server version of Godot itself (when writing this, its the file found here: https://downloads.tuxfamily.org/godotengine/3.5/Godot_v3.5-stable_linux_server.64.zip) renamed as game.

In the same directory is the game archive, named game.pck (Godot will automatically load the pck file with the same name as the executeable).

Thats basically all there is to it.

Here is the relevant part of my Makefile for reference (the server code is in directory “server”):

build/game.pck: $(shell find server -type f)
        $(godot) --path "server" --export "Linux/X11" ./game.pck --no-window
        mv server/game.pck build

build/game:  
        - mkdir build
        cd build;wget https://downloads.tuxfamily.org/godotengine/3.5/Godot_v3.5-stable_linux_server.64.zip;unzip *.zip;rm *.zip
        mv build/Godot*.64 build/game 

linuxserver: build/game build/game.pck
        cp -R server/data build
        cp server/*.so build
        cd build;docker build -f ../Dockerfile -t sumur_server .
        docker tag sumur_server myrepo/sumur_server:latest

Deploying, running and re-deploying on Dokku

As I explained in Goodbye Heroku (for now) I have set up a Dokku server where I run all my server stuff (its quite amazing how much stuff one can run on one cheap cloud server) and mostly this has been simple. Running Django or Rails applications using Heroku buildpacks is a well documented and simple process. A docker container with godot server running websockets turned out to be less documented..

To start, set up a normal dokku application and hostname, letsencrypt and all that. Basically:

dokku apps:create sumurserver
dokku domains:add sumurserver sumurserver.yourdomain.com
dokku letsencrypt:enable sumurserver

Then you need to add the ports. My dokku defaulted to redirect http and https to port 5000 in the docker. To fix that:

dokku proxy:ports-clear sumurserver
dokku proxy:ports-add sumurserver http:80:8080
dokku proxy:ports-add sumurserver https:443:8080
dokku proxy:ports-add sumurserver wss:443:8080

Since websockets is supported by nginx, this “just works” without any more configuration. Now we’re all set to deploy the docker.

The simplest way is to deploy once and be done with it:

dokku git:from-image sumurserver myrepo/sumur_server:latest

This will work just fine, but I never got it to update the image when I rebuilt it and published a new container to my repository. How to fix that is described in the dokku documentation at https://dokku.com/docs~v0.25.7/deployment/methods/git/#initializing-an-app-repository-from-a-docker-image using the images sha hash instead of its lable. In my case:

dokku git:from-image sumurserver myrepo/sumur_server@sha256:9d187c3025d03c033dcc71e3a284fee53be88cc4c0356a19242758bc80cab673

Again, put into a Makefile:

publish-linuxserver:
        docker push sumurserver myrepo/sumur_server:latest
        TAG=$$(docker inspect --format='{{index .RepoDigests 0}}' sumurserver myrepo/sumur_server:latest) &&  ssh my.dokku.server.com dokku git:from-image sumurserver $$TAG

Advanced search in Todour 2.06 (preliminary)

Advanced searching has been implemented and is being tested for the 2.06 release of Todour.

The search will be able to handle multiple search words including negative ones, like below where all lines with “test2” and “test1” but not test4 will be matched.

skarmklipp-2016-09-30-23-43-48

The negative matching is especially convenient when wanting to exclude a project or context. I use it for excluding the “@work” context when I am not working for example but you can of course find many other uses for it.

Stay tuned for the 2.06 release coming quite soon…

Context locking in Todour

The 2.05 version of Todour will have a context lock feature. That means that when the context is “locked”, it’s automatically added to any new line. So for instance if your’re working on a +project1, you can search for it, press the lock and then just add all the todos you want. All will have +project1 added to them so they keep the context you’re in.

skarmavbild-2016-09-28-kl-21-44-46

 

Sorting issue in 2.04

There is an error in 2,04 that will cause the list to not sort properly in some cases. There are two possible workarounds if this happens to you.

Either

Activate alphabetic sorting

2-04-workaround1

Just toggling the sorting to on is enough, then the program will go into a correct sorting mode. This of course only makes using the alphabetic sorting possible. If you need the more “natural”  sorting then use the following workaround.

Make sure the “Inactive” field contains something relevant2-04-workaround2

By adding data to the “inactive” field in preferences the application doesn’t get into it’s error state and all works as it’s supposed to This way both the alphabetic sorting and the normal sorting will work properly.

 

An update will be released as soon as possible.

Adding analytics

For quite a few years I’ve had Todour available for anyone to download. It’s software I make for my own use and I’m happy to share it but I can’t help wondering how many people are actually using it, and on what platforms.  How many people care if I make an update?

I have had no tracking of downloads on my page, but that wouldn’t really have mattered anyway as it says nothing about who uses the software and also the software is available for download in other places.

To get a better view of this I have, from version 2.01, added google analytics into the application, hoping that it doesn’t offend anyone. The analytics can be easily turned off of course and it only gathers very basic data.

Currently I will be collecting:

  • Application starts, Operating system (Windows or Mac) and what version of Todour is being started
  • How often the update checker in the about menu has been run

I hope this will give me more insights into how many people actually use the software to understand if there is interest in keeping developing it (it’s does most of the things I need for now).

[wp_ad_camp_2]

Automatic music video

Much to my surprise, I have come to realise that YouTube is used by many for music listening. That’s too bad, as I don’t know much about making videos.

For a few songs, i used iMovie to cut together some footage and text. See for example From the bottle below

But making these was a bit tedious, especially when it’s the music and not the video that interests me.

So, after some surfing, I ended up with this little script using ffmpeg

ffmpeg -i "The Stage (v1.01).mp3" -i ../cover.jpg -filter_complex "nullsrc=size=1280x768 [base]; [1:v] setpts=PTS-STARTPTS ,scale=768x768 [cover]; [0:a] showwaves=s=512x768:mode=cline [sw]; [base][sw]overlay=x=768 [tmp1]; [tmp1][cover]overlay=x=0 [out]" -map "[out]" -map a:0 -c:v libx264 -shortest -crf 18 -c:a copy "The Stage (v1.01).mkv"

That yields the following video

and

ffmpeg -i "Beneath the snow (v1.01).mp3" -i ../cover.jpg -filter_complex "nullsrc=size=1280x768 [base]; [1:v] setpts=PTS-STARTPTS ,scale=768x768 [cover]; [0:a]showspectrum=mode=combined:slide=scroll:color=intensity:scale=cbrt:s=512x768[sw]; [base][sw]overlay=x=768 [tmp1]; [tmp1][cover]overlay=x=0 [out]" -map "[out]" -map a:0 -c:v libx264 -shortest -crf 18 -c:a copy "Beneath the snow (v1.01).mkv"

that generated this one

There are more possibilities for using ffmpeg and generating music visualisation, but I found these two to be the simplest to use. This is perfect for us nerdy musicians that want to be able to script all boring stuff out of our lives 🙂

(note that the script does not transcode the music, it leaves it as is = good thing)

Fallur: Making of 2.0

feature

Now, the game Fallur was released a bit early, just to be out in time for christmas (and the reason for that being that I had invested 30 minutes into making christmas graphics for the game). Now it’s time to make the game good enough to be playable for the rest of the year.

screenshotGraphics

The graphics in the 1.0 version of the game where all photography based, and the game ran in 360×540 resolution with 48×48 sprites. This is a quite nice resolution to work in when using that kind of graphics, but if the graphics is to be hand-drawn it puts quite a lot of pressure on the artist.

Screenshot_2014-12-29-12-36-15For the 2.0 version I decided to lower the resolution quite a lot (4x) to hide the fact that I can’t draw at all, and also that the added resolution really didn’t add anything at all to the game play.

For sprites I used the very nice Random Sprite Generator by Boris van Schooten (check out his site that’s full of games and useful stuff). That received me of the pain of having to do much graphics.

The rest of the graphics is just scale down of the higher resolution images used in 1.0 except for the background that I simply removed in favour of a simple gradient that makes the game more playable.

Sound

[banner]

Making music is one of my greatest passions in life. I am always playing my guitar and coming up with a new song. It’s like breathing. I have to do it. So making music for a game should be simple, shouldn’t it? Not really.

I make rock music mostly. I have once in a while made these “chip/synth”-kinds of tunes, but they are much more effort to make than a guitar based rock tune. So, I made this:

This is an early draft of music that could be added to the game, but I am not sure right now as it can’t be compressed below 2Mb of size without sounding really bad. I got it down to 1.5Mb by removing most high-frequency sounds in the song and then compressing to 80kbit. That will have to do for now..

Gameplay

The original gameplay was very simple. Hit all things that fall down (at varying speeds) but don’t hit the ghosts. Then of course the difficulty increased by increasing the number of things falling down as well as the speed.

The result was a game that was completely unplayable after level 20. It was simply to difficult. My analytics data proved the point by showing that most people failed early (or thought the game was boring and quit).

Change to the gameplay is now that there are 6 personalities with different behavioural patterns. For the first 10 levels only one, quite simple one is available. Then another, a little bit harder comes into the game and so on. The game is now playable for 60-70 levels for those who  fancy this kind of super simple game. It will be interesting to see on the analytics if anyone has the patience or interest to go that far or if people just drop the game after a few levels due to bordom.

What now

[banner]

The 2.0 version of the game is now live on google play. It has a bit more evolved gameplay than the 1.0 version and a rock soundtrack of quite low quality.

Now I will keep my eyes on my analytics to see if this appeals to anyone at all, fix issues and enhance if needed. Who knows, there might even be an iOS version of there is enough of people playing it on Android. But the goal with the game is the same as before. I do this for learning.

There will be updates. Possibly the music will be changed, the Facebook integration is very rudimentary, perhaps a google play integration would be a good thing, overlay screen showing when a new monster has been unlocked should be made, sound effects added and so on.

But now, let’s see if anyone plays the game.

 

Fallur: Why was it made?

After I made Lovur I experimented with some HTML5 frameworks for game development. I have always liked writing games but I’ve normally got stuck somewhere in sprite-handling routines and level editors but with these tools it was amazingly simple to prototype games.

Using the MellonJs HTML5 engine I prototyped two simple games in a few hours. That’s two playable games. I was intrigued by the efficiency of developing and of course I tried the games using Cordova on a recent Android phone and I got disappointed.

As nice and fast it was to develop in this environment the results on smartphone were quite bad.

I tried both games both using Cordova and also using crosswalk and CocoonJS for greater speed. I also tried re-implementing both games using Phaser (remember that I’m still writing about small prototypes of games).

To sum it up. Both games where jerky as normal Cordova builds, not reaching anywhere near 60 fps. With Crosswalk and CocoonJS they were playable, but at a high cost in file size and then just barely playable. I figured that if I would add any logic the playability would suffer. So I tried LibGDX.

I implemented both prototypes in LibGDX, this time taking a bit longer time than the HTML5 variants of course but with more control. The results where really smooth (I only tried on Android) and the development environment quite nice so I decided to continue working on the games a bit. After all, I have a few game ideas I would like to implement, but before I can do that I have to learn. Fallur is a place for me to learn.

I released it before christmas 2014, a bit ahead of time. The game isn’t ready, but it is playable (well, up to level 20, then it gets a bit too hard.. and perhaps a bit boring). I rushed it out since I had made a christmas theme for the game. The game will be re-themed later on and the game play will evolve.

As I am only doing this for my own sake and for learning I have no problem releasing an unfinished product on the world like this. Also, that is the reason the game is only available on Android. I will be updating it and that is simple and fast on Google Play. Also, as I will be evolving the game play and graphics (experimenting) I don’t have time to maintain different versions for different platforms even if the very nice LibGDX would make that possible.

Anyhow, I hope someone is enjoying the game despite it being in the state it is 🙂