In this tutorial we will run Digger game in Node.js and save game screenshot to image.
Let's start with creating empty project:
In node environment you can use only emulators package, becuse
emulators-ui is made for browser integraions. For creating screenshot we will use
jimp library. So let's install them.
Next we need to download Digger js-dos bundle:
We will edit file named
digger.js. We can run it with this command
Use require to import all libraries
emulators package is made for browser, it didn't export anything. It inject itself into global object.
pathPrefix is relative to require file
Now we need to read contents of
jsdos bundle and start emulation
When dos emulation starts, we will recive Command Interface, we can use it to subscribe on frame updates and to send key/mouse events.
Now we have frame, it's in RGBA format. We only need to save it to png image:
Frame is in RGBA format, but alpha is always 0. To have normal image we should rewrite alpha channel to 255.
If you execute
node digger.js it will save digger screenshot to
Full code of