Skip to main content


Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - Eggbertx

Libraries / EventEmitter for miniSphere
I'm working on a relatively simple (but hopefully useful) event system for miniSphere influenced by Node.js's EventEmitter class, so if you're familiar with that, this should be fairly simple to get used to.

Some examples:
Code: (JavaScript) [Select]
import { Thread } from 'sphere-runtime';
import { EventEmitter } from 'events';

const maxListeners = 32;
const escOnlyOnce = true;
let ei = new EventEmitter(maxListeners);

export default class Game extends Thread {
    constructor() {
        ei.addListener("escEvent", () => {
        }, escOnlyOnce);

    on_update() {
        if(kb.isPressed(Key.Escape)) ei.emit("escEvent");

The `event#addListener` function also takes an optional parameter that emits the listener when it equals true or is a function that returns true.
Code: (JavaScript) [Select]
ei.addListener("escEvent", Sphere.shutDown, escOnlyOnce, () => {
    return kb.isPressed(Key.Escape);

I'm also working on a class for handling key press/release events

GitHub repo:
Libraries / SphereIRC
I'm working on a module for an IRC client class called SphereIRC, and I may eventually start working on a server class as well.

Back in the day I wrote a very simplistic IRC bot for Sphere 1.5. Since Sphere 1.x is long dead and miniSphere has been here for a long time now, I figured I should probably resurrect it (SphereBot, not Sphere 1.x), but early on, I decided to work it into a general purpose IRC module to be integrated into your online game projects instead of a standalone bot.

Game Development / robotfindskitten, back from the dead
A long while ago, before miniSphere, and before the death and rebirth of the forums, I created a port of the game/zen simulation robotfindskitten, but my laptop died, destroying all of my old stuff. Since my original version wasn't very good anyway, I decided to recreate it, using miniSphere's API.

In this game you are robot (#). Your job is to find kitten. This task is complicated by the existence of various things which are not kitten. Robot must touch items to determine if they are kitten or not. The game ends when robotfindskitten.

Libraries / box2d-sphere
I've been working off and on on a port of box2d.js to miniSphere, which would allow a developer working with miniSphere to make more dynamic platformers. If you aren't familiar with box2d, it's a physics engine used in games like Angry Birds, LIMBO, and Happy Wheels.
The screenshot shows the stage in "Debug draw" mode, which would be the equivalent of drawing only collision objects in miniSphere. When it's more stable, I would be able to attach a Person object's position and rotation to a box2d object.
Unlike box2d.js and the original, I'm also working on a stage object to make stage building easier. So rather than writing boilerplate code for each static and dynamic body, you can just create a JSON file and save a lot of effort. For example, this is the file that sets up the stage shown in the screenshot:
Code: [Select]
"name": "Test stage",
"gravity": { "x": 0, "y": 32 },
"allowSleep": true,
"border": {
"top": 5,
"bottom": 5,
"left": 5,
"right": 5
"objects": [
"type": "rectangle",
"dynamic": false,
"position": { "x": 32, "y": 32},
"size": { "w": 50, "h": 10},
"angle": 5
"type": "circle",
"dynamic": true,
"position": { "x": 55, "y": 64},
"radius": 10,
"angle": 0

I wanted to make an animated GIF showing it in action, but OBS studio wouldn't play nicely.
This is a somewhat low-priority project compared to the other ones, but I figure you guys might be interested. I'm going to hold off on uploading the code, since it's a bit of a mess right now. As soon as it's at least a little bit more stable, I'll probably upload it to GitHub or something.
Off-Topic Discussions / Inspiration for music?
I would like to write my own music for games, but a lot of my stuff tends to be somewhat derivative (i.e. using some other song as a base). Where do you usually draw inspiration or get ideas for your music? I know people often say that nothing is truly original (or something like that), but I would like to work on being having more originality without sounding generic or boring.
Libraries / Personlib 1.1
Update: I made some improvements to Personlib. All setter functions that don't normally have a return value now return the person object for method chaining (see updated example)

I finally got around to completing my Personlib library that I mentioned a while ago. The syntax is almost identical to the Sphere 1.x, with some changes to account for miniSphere's differences. It also makes good use of miniSphere's threading capabilities, and adds some convenience functions of its own. For example:

Code: (JavaScript) [Select]
// Cellscript.mjs 
install('@/lib', files('lib/personlib.mjs'));

// main.mjs
import { Person } from "personlib";

var player = new Person("player","player.rss",false); // similar arguments to CreatePerson()
player.on_update = function() {
var adjacent = this.getAdjacentObstructions(5); // where 5 is the offset in pixels
var rand_r = Math.floor(Math.random());
var rand_g = Math.floor(Math.random());
var rand_b = Math.floor(Math.random());
var rand_a = Math.floor(Math.random());
this.setMask(new Color(rand_r, rand_g, rand_b, rand_a)); // setMask detects if the parameter is a miniSphere color object or a 1.x color object, and getMask allows you specify which one you want
if(adjacent.north.tile > -1 || adjacent.north.person != "") Sphere.abort("You are ded. RIP in pieces.");
else this.queueCommand(COMMAND_MOVE_NORTH, true);
return true;
In this example, player.on_update is optional, but if you do set on_update, on_render, etc, they need to be set immediately after the Person object is instantiated. Otherwise they won't be used.
Most of the object methods are just call the legacy function given the appropriate arguments, so if you run into issues, there's a decent chance that it's miniSphere's fault. If you suspect that isn't the case or you have some suggestions, let me know.
I'm going to be visiting family in Europe for a little while, so if you don't hear from me (updates and such) that's why. See you in ten days!
Last night I came up with an idea for a game heavily based on later versions of Bomberman, with some improvements/additions, but restricting myself to using only black and white (no colors or shades of grey) which creates a deliberate challenge of making realistic shading. I tried this a while ago with a different game, but it never really went anywhere.
In the attached screenshot, the left half shows solid black floor tiles, and the right half shows checkered tiles. Which one do you prefer? On one hand, the checkered tiles make bomb sprites stand out more than on black sprites, but on the other, the checkered tiles might cause eye strain.
If I have a person (16x16 px) in a map (16x16 px tiles) touching but not overlapping a wall, GetObstructingTile returns > -1 when it seems like it should be returning -1. Is there a better way to detect if the person would actually be able to move to the given coordinates regardless whether it's touching something or not?
In the attached picture, the person spawns at 1,1 and GetObstructingTile("personName",1*GetTileWidth(),1*GetTileHeight()) returns index 0 (the wall's tile index number)
I'm trying to get it so that I can play a loaded Sound file multiple times (for example, playing a bullet firing sound quickly), but calling seems to block it script execution until it finishes. Is there a way to play sound objects asynchronously?
Editor Development / QtSphere IDE 0.6.0
QtSphere IDE

(On Github)

QtSphere IDE is an alternative Sphere development environment, focused on being both powerful and cross-platformy, for those of us who use Linux/Mac/*BSD/Solaris (or hypothetically any OS that Qt supports) and their respective miniSphere builds but lack a proper IDE without using the 1.x editor via WINE. It used to have a source code editor with syntax highlighting and line numbering, but because of difficulty with QScintilla, I'm going to focus on miniSphere's specific formats (Spritesets, maps, etc) and leave code editing to my Visual Studio Code extension. You can still open plain text files if you want, but there are better alternatives.

A friend of mine would like to learn to program to ideally make games. Do you guys think Sphere would make a decent starting point, or would it be unrealistic?
Off-Topic Discussions / Tiled Map Editor
For anyone interested, there's a cross-platform FOSS map editor, primarily for top down games called Tiled, which can be found here. Since Radnen's IDE can't run in Linux, I haven't used this in any projects yet (though I might use it in a SHMUP I'm using as a testbed for Personlib), but playing around with it, it's pretty neat. You could create a map with it, export it as an image, and then import it into the Sphere 1.5 editor to add collision, scripts, etc. It doesn't seem to have an individual tile editor, so you have to import one, but it can create an isometric maps, use layers with transparency, create animations, select multiple tiles and use them as a stamp (as seen in the image), and other cool stuff.

Site Comments / Woo!
 Good to see the site is back up. I was kinda worried for a little while that we were going to have a repeat of last time.
I've been working on a simple library to treat Sphere Persons as javascript objects, rather than having to interface with the map engine's functions. So for example, instead of doing

Code: (javascript) [Select]

function game() {
    // ...
    player_obstructed = IsPersonObstructed("player", GetPersonX("player"), GetPersonY("player"));
    direction = GetPersonDirection("player");
    QueuePersonCommand("player", COMMAND_MOVE_SOUTH, true);

etc, which can be rather tedious after a while, you would instead do (as it is now)

Code: (javascript) [Select]

var player;
function game() {
    player = new Person ("player","player.rss",destroy_with_map);
    // ...
    player_obstructed = player.isObstructed(player.x,player.y);
    direction = player.getDirection();

And so on and so forth. This would also make it simpler to create custom update/render functions  and custom properties per-person by doing person_object.update = function() {} as desired
Instead of using GetPersonList, you would just reference the persons[] array.

Do you think this is a good way of doing things? Would the new minisphere API benefit from using this method as opposed to the old way? I'd post this in minisphere's engine update thread, but I wanted to make this thread to ask for your guys' opinions on this method in general.