Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
sokoban-engine
Advanced tools
Readme
Create and manage Sokoban games with ease.
🔓 Fully Customisable | The size of the Sokoban grid, number of boxes, and entity appearances is up to you.
🎮 Randomly Generated Levels | Generate a random game with a random size and number of boxes. (Custom levels coming soon!)
🏗️ Easy to Set Up and Use | All the logic that goes into making Sokoban is handled for you.
⏱️ Synchronous | All functions are synchronous, so you can use them in your game loop.
Please Note: Custom levels are not currently supported. Want to request a feature? Open an Issue, or Fork and Submit a Pull Request on our GitHub Repository!
To install the package, run the following command in your terminal:
npm i sokoban-engine --save
Setting up the package for use is as simple as creating a new Sokoban class and setting the width and height of the game grid.
There are also a few other options you can set, such as the number of boxes on the level, and the appearance of each entity.
const SokobanEngine = require("sokoban-engine");
const sokoban = new SokobanEngine(10, 10, { // Setting up a 10x10 grid
boxes: 2, // Number of boxes to generate on the level
entityAppearance: { // Customise what each entity on the level looks like
player: "🤪",
box: "📦",
boxOnGoal: "✅",
goal: "📥",
wall: "🚧",
floor: "⬛"
}
});
Here's a quick example of how to use the package to create your own Sokoban game to run in the terminal.
const SokobanEngine = require("sokoban-engine");
const sokoban = new SokobanEngine(10, 10);
while (!sokoban.hasWon) { // Keep running the game until all boxes are on the goals
// Displaying the level
console.clear();
console.log(`Sokoban`);
console.log(`Moves: ${sokoban.moves.toLocaleString()}`);
sokoban.level.forEach(row => console.log(row.join("")));
console.log("(w,a,s,d) to move, (r) to restart the level, (q) to quit");
let movement = // Get the user's input somehow
switch (movement) {
case "w":
sokoban.moveUp(); // Move up
break;
case "a":
sokoban.moveLeft(); // Move left
break;
case "s":
sokoban.moveDown(); // Move down
break;
case "d":
sokoban.moveRight(); // Move right
break;
case 'r':
sokoban.reset(); // Restart the level
break;
case "q":
process.exit(); // Quit the game
}
}
// Displaying the level
console.clear();
console.log(`Sokoban`);
console.log(`Moves: ${sokoban.moves.toLocaleString()}`);
sokoban.level.forEach(row => console.log(row.join("")));
console.log("You win!");
👋 Need Help? Join Our Discord Server!
👾 Found a Bug or want to Request a Feature? Open an Issue, or Fork and Submit a Pull Request on our GitHub Repository!
FAQs
Create and manage Sokoban games. Levels and entities are fully customisable.
The npm package sokoban-engine receives a total of 4 weekly downloads. As such, sokoban-engine popularity was classified as not popular.
We found that sokoban-engine 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.