npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

piximoroxel8ai

v0.1.0-alpha.30

Published

Run PixiJS games written for MoroboxAI

Downloads

13

Readme

piximoroxel8ai

NPM version Node.js CI gitHub license Code Quality: Javascript Total Alerts

Run PixiJS games written for MoroboxAI.

Why

MoroboxAI by itself is a generic framework that can run any JavaScript code that exports a boot function.

PixiMoroxel8AI is a layer of abstraction on top of that and:

  • Uses PixiJS as a renderer
  • Loads and runs your game written in JavaScript
  • Implements all the boilerplate for being compatible with MoroboxAI
  • Provides a simple interface for controlling the graphics, audio, and inputs

To sum up, PixiMoroxel8AI takes care of all the boilerplate required for initializing and running your game in MoroboxAI, and lets you focus on coding the game logic in JavaScript.

Minimal game

The sample folder contains a sample of a minimal game for PixiMoroxel8AI:

sample/
├─ assets/
│  ├─ bunny.png
├─ game.js
├─ game.ts
├─ header.yml

As you can see, the folder contains both game.ts, and game.js.

Your game can be written with TypeScript for a more type safe coding, but it must be converted to plain JavaScript for being loadable by PixiMoroxel8AI.

The header.yml defines how the game is loaded:

  • boot must be the name of a JS module loaded in the page, that exports a boot function compatible with MoroboxAI, here PixiMoroxel8AI.
  • main is simply the relative path to your game script.
# Defines the JS module used to boot the game
boot: PixiMoroxel8AI
# Defines the main script of the game
main: game.js

Now, all that remains is index.html which is a minimalist page loading MoroboxAI + PixiMoroxel8AI and initializing the game:

<head>
    <title>PixiMoroxel8AI Sample</title>
    <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/moroboxai-player-web@latest/lib/umd/moroboxai-player-web.min.js"></script>
    <!-- Use https://cdn.jsdelivr.net/npm/piximoroxel8ai@latest/lib/umd/piximoroxel8ai.min.js in production -->
    <script type="text/javascript" src="./lib/umd/piximoroxel8ai.js"></script>
</head>

<body>
    <div id="player"></div>
</body>
<script type="text/javascript">
    (function () {
        console.log(`moroboxai-player-web v${MoroboxAIPlayer.VERSION}`);

        player = MoroboxAIPlayer.init(document.getElementById("player"), {
            // Replace with URL to your header.yml
            url: `./sample`,
            resizable: false,
            autoPlay: true,
            onReady: () => console.log("ready")
        });
    })();
</script>

<style type="text/css">
    body {
        height: 100%;
        margin: 0;
        padding: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
    }

    #player {
        background-color: black;
        background-size: cover;
        width: 512px;
        height: 512px;
    }
</style>

</html>

This is all that is required for embedding and running your game in a webpage.

Run on the web

Testing on the web requires you to run a local HTTP server to avoid CORS errors when loading local files.

For that you can install http-server:

npm install http-server -g

Open a command prompt in the piximoroxel8ai folder and run:

http-server

Now you can access the page on localhost and the port opened by http-server.

License

This content is released under the MIT License.