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

obscen

v0.0.3

Published

Simple scene manager

Downloads

8

Readme

Obscen, A simple scene manager

Overview

Obscen is intended to be an easy-to-use scene manager for the smaller projects.

There are two classes: SceneManager and Scene.

class SceneManager

Your gameloop only need to know about a scene manager, because it will handle all your scenes. Your gameloop calls update and draw on the scene manager and it will pass it down to the current scene. Obscen is agnostic against the arguments to the update and draw calls, so it doesn't matter if you pass down deltaTime or tick multiplier or renderingContext or whatever, the scene manager will just pass it on down to its scenes.

class Scene

The scenes consist of just one property and a few methods.

const myScene = Ob.Scene({
	
	// this scene's name, this is what you give to changeScene to change to this scene
	name: 'myScene',

	// this will be called when changing to this scene with changeScene('myScene', nextSceneParams)
	// the previousSceneParams is the second argument to changeScene([scene name], nextSceneParams)
	create: function (previousSceneParams) {

		// all scenes have access to a shared object
		this.sharedObject.playerScore = 1000
	},

	// this will be called when changing from this scene with changeScene('anyOtherScene')
	destroy: function () {},

	// will be called from this scene's scene managers update
	update: function () {},

	// will be called from this scene's scene managers draw
	draw: function () {},
})

Code

Written in ES5.

Only exports to CommonJS (as of now, AMD is planned).

Usage

const Ob = require('obscen') // import obscen (as Ob, because that was its intended name, which was taken)

localStorage.debug = 'obscen:*' // enable debug output

const splash = new Ob.Scene({ // create new scene - 'splash'
  name: 'splash', 
  create: function () {
    console.log('splash create', this.sharedObject)
    this.sharedObject.playerName = 'lolbert'
  },
  destroy: function () {
    console.log('splash destroy')
  },
  update: function () {
    console.log('splash update')
  },
  draw: function () {
    console.log('splash draw')
  },
})

const game = new Ob.Scene({
  name: 'game',
  create: function () {
  	// will print: 'game create, playerName: lolbert'
    console.log('game create, playerName:', this.sharedObject.playerName) 
  },
  destroy: function () {
    console.log('game destroy')
  },
  update: function () {
    console.log('game update')
  },
  draw: function () {
    console.log('game draw')
  },
})

const sceneManager = new Ob.SceneManager()

// the setScenes call will add a wrapped changeScene method to all scenes, before this .changeScene does not work
sceneManager.setScenes([
  splash,
  game,
  ])

sceneManager.changeScene('splash')

// of course update and draw will be done in your gameloop
sceneManager.update()
sceneManager.draw()
sceneManager.update()
sceneManager.draw()

splash.changeScene('game')

// of course update and draw will be done in your gameloop
sceneManager.update()
sceneManager.draw()
sceneManager.update()
sceneManager.draw()

game.changeScene('splash')

Debugging

Obscen uses debug and follows its conventions.

localStorage.debug = 'obscen:*'

Dependencies

debug

Contributing

Please feel free to put up PR's, this is very infant and hobbyish still so don't be mad if it might take a while to get a reply.

To do

  • Add tests (prolly mocha-chai)
  • Add AMD export