Posted January 06, 2025 by NickTheSic
#DRM #Code
I have discovered that games you wouldn't think get stolen and posted to other sites do sometimes get stolen and posted to other sites.
This project uses emscripten and I have found and modified very simple javascript code so that the game will only run here (and where ever I decide to allow). The code is as follows:
EM_JS(bool, verify_site, (), {
if (document.location.host == 'html-classic.itch.zone' || document.location.host == 'localhost:6931'){
return true;
}
alert('This game can only be played at: https://nickthesic.itch.io');
throw 'Please Visit https://nickthesic.itch.io';
return false;
});
It checks that we are being loaded from itch.zone or localhost. html-classic.itch.zone is what seems to work and I hope that itch.io doesn't change much to break this here. While 'localhost:6931' is what the default is in emscripten and allows me to run the game locally for testing.
It is a pretty neat feature that I will most likely add to all my projects now and moving forward.
For your own projects be sure to:
1) Use a water mark. Let people know who you are
2) Link back to your site in game. Direct people back to your stuff
3) (Optionally) setup this verify. As a gamer, I hate DRM. But as small developer I very much see the appeal of locking my games to a specific site. If you have a water mark or links it may not be as bad, but you should be in charge of where the game gets uploaded