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

sams-web-game-engine

v0.1.13

Published

This library makes it easier to make web-based games.

Downloads

20

Readme

Sams Web Game Engine

This library makes it easier to make web-based games.

Designed for 3rd person, side scroller games that use 3D models. Powered by React Three Fiber.

This library is designed for games that use 3D assets, but 2D movement (e.g. side scrollers, tetris, galaga).

Working example: https://sams-web-game-engine-example.vercel.app/

Features:

  • Movement
  • Collisions
  • Fire projectiles
  • Menus
  • Play flow
  • Power ups
  • Enemy AI
  • Difficulty levels
  • Scale difficulty based on player skill
  • Score/high score management
  • Light weight
  • Easy to use

Future Features:

  • Use LLM for quest text generation and level design
  • AI controlled allies/teammates

Canvas

The Canvas is the entry point for your game. It holds all of the data and does most of the processing. Start with a Canvas and add other components to it.

import { Canvas } from 'sams-web-game-engine';

const gameSettings: any = {
  background: 'white',
};

return <Canvas settings={gameSettings}>...</Canvas>;

Use the settings argument to choose your game settings.

  • background - anything that can be used as a value for the background property in CSS. 'transparent' by default.
  • gravity - up, down, left, right, or none. 'none' by default.
  • travelDirection: up, down, left, right, or none. 'up' by default.

Canvas is based on Canvas from React Three Fiber, so anything that will work in that Canvas should also work in this Canvas, but there may be compatibility issues when not using components from this package.

This is the notation for positions: [x, y, z]. [0, 0, 0] is the center of the screen. The x-axis is the horizontal axis. It increases to the right. The y-axis is the vertical axis. It increases upwards. The z-axis is the axis that goes into and out of the screen. It increases out of the screen towards the camera.

Game Objects

Game Objects are general objects that you can put on the Canvas.

import { Canvas, Object } from 'sams-web-game-engine';

return (
  <Canvas>
    <Object position={[1.2, 0, 0]} />
    <Object color={'red'} />
  </Canvas>
);

Supported arguments:

  • color - color names or hex notation.
  • position - x, y, and z components of object position. [0, 0, 0] by default. This is the position of the center of the object.
  • size - x, y, and z components of object sie. [1, 1, 1] by default.
  • rotation - x-axis, y-axis, and z-axis components of object rotation in radians. [0, 0, 0] by default.
  • showCollider - Only designed for testing purposes. This option lets you see where the collider will be, even though it's usually invisible. "false" by default.
  • filePath - If you want to use a 3d model in a separate file, use this argument. It expects a path to a .gltf file. You need to also put this file in the static files directory.

Player

A player is essentially an extension of a game object. The only difference is that user inputs affect the player object.

import { Canvas, Player } from 'sams-web-game-engine';

return (
  <Canvas>
    <Player />
  </Canvas>
);

Colliders

Colliders are used to detect when two objects touch. (e.g. player touches a power-up, bullet touches enemy). Every object has a collider by default, but you can provide your own collider if you'd like.

import { Canvas, Object, Collider } from 'sams-web-game-engine';

const myCollider: Collider = {
  shape: 'box',
  boxSize: [1, 1, 1],
  offset: [0, 0, 0],
};

return (
  <Canvas>
    <Object collider={myCollider} />
  </Canvas>
);

Supported values:

  • shape - (required) point, box, cylinder, sphere. "box" by default
  • boxSize - Must be, and should only be used with box shape. x, y, and z components of collider size. "[1, 1, 1]" by default.
  • boxRotation - (future) Must be, and should only be used with box shape. x, y, and z components of collider rotation. "[0, 0, 0]" by default.
  • cylinderSize - Must be, and should only be used with cylinder shape. radius and height components of collider size. "[1, 1]" by default.
  • cylinderRotation - (future) Must be, and should only be used with cylinder shape. x, y, and z components of collider rotation. "[0, 0, 0]" by default.
  • cylinderOrientation - (future) Must be, and should only be used with cylinder shape. Orientation of the cylinder. Which axis is the height of the cylinder parallel to? x, y, or z. "x" by default.
  • sphereRadius - Must be, and should only be used with sphere shape. Radius of collider. "1" by default.
  • offset - (required) x, y, and z components of collider position offset. "[0, 0, 0]" by default.

yarn prettier

npm publish --dry-run

TODO: switch dicts to maps allow files for including 3d objects