In this post, I’m not going to talk about npm (except for the initialisation part), but about how to code your module with Haxe.
First thing to do is to create our npm project.
npm init --yes
--yes because I’m lazy and I don’t want to enter the default value for each prompt.
My default package.json file looks like:
files parameter will tell npm which file/directory to import while installing the module. I only specify the dist directory, because for a production usage, the Haxe sources are not needed. But still, if you want to publish everything, just forget about the
My project looks like:
- test-node-package - dist - index.js - src - Main.hx - package.json - build.hxml
Now that we have our project setup, we can start working on our module.
Let’s say we want to do the following in another project:
In Haxe you will have to:
You will probably need to use the nodejs lib, so don’t forget to add it in your build.hxml:
I’ve changed the event handling in order to use msignal instead of passing a function down to the right component.
I’ve created an History/HistoryItem component to get a cleaner code.
To test it, just checkout the repo, install the dependancies:
And build the app.
I’m prototyping a lot for the Pico-8 console with haxe (using the hxpico8 library), so in order to help my productivity, I’ve built some tools.
The first aim was to initialize a new project quickly so you don’t lose time and you can start coding right away.
Once the project is built, the tool will take care of the compilation/deployment. Because I’m using haxe, I can’t code directly into the pico8 console and test right away. So the tool will do it for you by:
Once that’s done, you just have to reload your game in the Pico8 console, and test it.
For more information, please take a look at the github repository.
Quick post to help you start with pico-8 and haxe.
If you never heard of it:
PICO-8 is a fantasy console for making, sharing and playing tiny games and other computer programs. When you turn it on, the machine greets you with a shell for typing in Lua commands and provides simple built-in tools for creating your own cartridges.
For more info, please check the official website.
I’ve created an empty project (as a gist) which you can find below :
It took me a while but I finally did it.
I released a new version of my LD31 entry, coloring.
I had to rewrite it completely, because I used my HTML5 framework (AGE) and I wanted to deploy it on mobile. So thanks to haxe and OpenFl I did it without trashing all my old code.
So what’s new ?
For the first time, I did integrate unit tests in order to test all (or at least the most) game possibilities. For that I used munit which is really great.
For the leaderboard integration, I’ve used linden-google-play library which is a native extension for OpenFl.
Enjoy, and let me know what you think.