
Security News
Nx npm Packages Compromised in Supply Chain Attack Weaponizing AI CLI Tools
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
A 2D sandbox game, using Gosu and REnet.
Built on top of Gosu, an engine for making 2-D games. Gosu provides the means to handle the graphics, sound, and keyboard/mouse events. It doesn't provide any sort of client/server network architecture for multiplayer games, nor a system for tracking objects in game-space. This gem aims to fill that gap.
Originally I tried using Chipmunk as the physics engine, but its outcomes were too unpredictable for the client to anticipate the server. It was also hard to constrain in the ways I wanted. So I elected to build something integer-based.
In the short term, I'm throwing anything into this gem that interests me. There are reusable elements (GameSpace, Entity, ServerPort), and game-specific elements (particular Entity subclasses with custom behaviors). Longer term, I could see splitting it into two gems. This gem, game_2d, would retain the reusable platform classes. The other classes would move into a new gem specific to the game I'm developing, as a sort of reference implementation.
This will eventually become a separate game mode, accessible only to certain authorized players.
The physics is (intentionally) pretty simple. Unsupported blocks fall, accelerating downward at a rate of 1/10 pixel per tick per tick. Blocks assume one of the following forms depending on how many hit points they possess:
Brick and Cement blocks are considered supported from the sides only if the entities present there are at exactly the same height. Steel blocks are less picky; they only fall if nothing is touching them.
When building a block, the longer you hold the S or DownArrow key, the more HP will be awarded to the block. Hitting a block with a pellet reduces its HP, until it degrades to a lower form. Dirt blocks with 1 HP will be entirely destroyed when hit.
Whether a block is supported depends exclusively on its immediate surroundings. That means two blocks can support each other, and hang suspended. For example, a dirt block sitting on a steel block will support each other. A horizontal row of brick, capped at either end with cement, will also be free-standing.
There are also Titanium entities. They take up space and can be used for support, but they are not truly blocks. They never fall, and are indestructible. These are intended for use in designing levels with specific shapes. They can only be created, destroyed, or moved by using the level-editing features.
The GameSpace is bounded by invisible, indestructible Wall entities. These are like Titanium, except that they are off-screen, and cannot be altered even with the level-editing features.
A player object is called a Gecko, because of how it moves. A Gecko is considered to be supported if its "feet" are touching a block. Unsupported Geckos will turn feet-downward and fall, until they land on something. Supported Geckos may slide left or right, and will follow any edges they reach -- going up and down walls, or hanging under ceilings. The "flip" maneuver swaps head and feet; this becomes useful if the Gecko's head is exactly touching another block. At all other times, a flip leads to a fall (which can be useful too).
When building a block, the player and the new block occupy the same space. This is allowed until the player moves off of the block. After that, the block is considered opaque as usual. While the block is still "inside" the player, the Rise Up maneuver may be used. This moves the player headward (which may not be "up"--it depends which way the player is turned) to sit "on top" of the block. It's possible to use this maneuver to construct a horizontal row of bricks, carefully.
A base is a spawn point for players, and is also an object that can be moved. When a game server is started with a new level name, a single starter base will be created in the center (and then promptly fall to the bottom). New bases can be created using the level-editing features, as many as desired, and placed wherever it makes sense for players to enter the level. Bases are indestructible (currently).
Like Geckos, Bases can perch on walls or ceilings, as long as their "feet" are pointed the right way. Unlike Geckos, when a Base gets thrown sideways or upwards, it will turn its "feet" in the direction it's going. So it will tend to stick to the first thing it hits.
Bases are physical objects, and most other objects (like blocks) can't move through them; but they're transparent to players. Players who join the game will start out at a randomly selected unoccupied base, in the same orientation as the base.
When a Gecko is destroyed, the player turns into a Ghost. This means you're dead. A Ghost can't touch anything or affect anything, and isn't affected by anything, even gravity. Ghosts can only float around, and look at things.
One other thing a Ghost can do is turn back into a Gecko, i.e. respawn. The player gets some choice as to which base to respawn at, if more than one exist and are unoccupied. The Ghost will move quickly to the unoccupied base nearest to the click position (even if that's really far away). If the player's not choosy, they may click anywhere. If all bases are occupied, nothing happens; the Ghost player must wait for those other Geckos to get out of the way.
This is also the solution for allowing new players to enter the game when all bases are occupied: The new player is created as a Ghost.
Pellets are fired from the player's center, and are affected by gravity. They damage whatever they hit first, and disappear. Pellets won't hit the player who fired them. Blocks, slime, and players can take damage and be destroyed.
Teleporters never fall, and they are "transparent" to most entities; they act as if part of the background. Their only action is to transfer their contents (anything close enough to intersect with their center) to their single destination-point. This transfer affects location but not velocity. Transfer doesn't happen if there is something blocking the exit point.
They're black. Really black. Against the starry background, they're impossible to see... except that they occlude the stars.
Mostly, holes are detectable just like real black holes: by virtue of the effect they have on everything around them. Normal gravity makes loose objects fall downward, but in the vicinity of a hole, gravity sucks all objects toward the hole. If the falling object gets too close to the hole, it will begin taking damage. Blocks will rapidly be destroyed as they approach. Pellets can't take damage in this way, but their path will bend around the hole. Pellets can even be captured in orbit around the hole, though they always escape eventually.
Install it with:
$ gem install game_2d
This needs streamlining.
Start a server in one window:
$ game_2d_server.rb -w 50 -h 50 --level example
And a client in another window:
$ game_2d_client.rb --name Bender --hostname 127.0.0.1
The client can use the menu to select "Save", telling the server to save a copy of the level. Subsequent runs of the server can leave off the dimensions:
$ game_2d_server.rb --level example
Run these commands with --help to see more options.
git checkout -b my-new-feature
)git commit -am 'Add some feature'
)git push origin my-new-feature
)FAQs
Unknown package
We found that game_2d demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.
Security News
CISA’s 2025 draft SBOM guidance adds new fields like hashes, licenses, and tool metadata to make software inventories more actionable.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.