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

simtegalib

v0.1.0

Published

Lightweight game framework that manages internals while you build the interface

Downloads

1

Readme

SIMTEGA Lib

Simple Text Game Library

That's all it is. Let simtega manage your state and scenes while you manage your interface. Primarily intended for text games but maybe one day there'll be a plugin for visual games.

Basically, install simtega with

$ npm i --save simtegalib

import with

import Game from 'simtegalib';

or

const Game = require('simtegalib').default;

make an update function

const update = (type) => console.log("updating ", type);

initialize simtega

const game = new Game(update);

and kick off the game by loading the first scene

game.loadScene({
  text: "hello!",
  buttons: [
    {
      text: "button1",
      onClick: () => console.log("clicked button1")
    }
  ]
})

you are now ready to start using simtega!

Using Simtega

Loading Scenes

Scenes are the most important part of simtega. Everything it does centers around them and the state (more on that later). Scenes are interacted with in two ways: pushing them into the game with game.loadScene and getting the current scene's properties with game.currentScene.

All scenes are objects with two required properties: text and buttons. text is the description of the scene--what players see when they're in the scene. buttons is an array of button objects, an example of which can be seen above. Scene objects can also contain onEnter and onLeave methods.

Here is an example of a scenes with all properties:

{
  text: "This is a scene with onEnter & onLeave methods",
  onEnter: () => doSomething(),
  onLeave: () => doSomethingElse(),
  buttons: [
    {
      text: "button1",
      onClick: () => click1()
    },
    {
      text: "button2",
      onClick: () => click2()
    }
  ]
}

That's a scene! For most text games, this is more than enough to create a full game.

Updating the UI

When you push a new scene, you'll probably want to update your UI. To facilitate this, your update function will be called with "scene" as the first parameter. Get the parts of the scene in update with game.currentScene, i.e. game.currentScene.text.

Managing State

In simtega, state for an entire game is in one place. game.setState sets a value and game.getState gets a value. Each value in simtega's state has a path, like a path in your filesystem. There are two root "directories," var (persistent) and tmp (temporary). All subdirectories are created on the fly when you set them. For example, some valid paths include 'var/player/hp' or 'tmp/ui/textBox'.

Other things to note:

  • When you set the state, any directories or properties that do not exist are created for you.
  • If a segment is a number ('var/player/inventory/0/name'), an array will automatically be used to ease iteration.

Updating the UI

Like updating the scene, updating the state will trigger a call to your update function, but the type will be "state".

Plugins

Using Plugins

Include an array of plugins as the second parameter to the Game constructor after following the plugins' instructions.

Example:

import Game from 'simtegalib';
import Static from 'simtega-plugin-static';
import scenes from './scenes.json';
import utils from './utils';

const game = new Game(update, [new Static(scenes, utils, true)]);

Available Plugins:

  • (static plugin coming soon)