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

craftyjs

v0.9.0

Published

Crafty is a modern component and event based framework for developing games in JavaScript that targets DOM, Canvas and WebGL.

Downloads

96

Readme

Crafty JS Travis Build Status AppVeyor Build Status Sauce Test Status

Crafty is a JavaScript game library that can help you create games in a structured way…

Key Features:

  • Entities & Components - A clean and decoupled way to organize game elements. No inheritance needed!
  • Eventbinding - Event system for custom events that can be triggered whenever, whatever and bound just as easily.
  • No dom manipulation or custom drawing routines required.

Other Goodies:

  • Thriving community - Help is readily available in the forum.
  • Community modules - A growing collection of user-generated code you can use.
  • Pure JavaScript - No magic. Works in all major browsers and can be combined with your favorite js library.

Using Crafty

A simple game of pong:

Crafty.init(600, 300);
Crafty.background('rgb(127,127,127)');

//Paddles
Crafty.e("Paddle, 2D, DOM, Color, Multiway")
    .color('rgb(255,0,0)')
    .attr({ x: 20, y: 100, w: 10, h: 100 })
    .multiway(200, { W: -90, S: 90 });
Crafty.e("Paddle, 2D, DOM, Color, Multiway")
    .color('rgb(0,255,0)')
    .attr({ x: 580, y: 100, w: 10, h: 100 })
    .multiway(200, { UP_ARROW: -90, DOWN_ARROW: 90 });

//Ball
Crafty.e("2D, DOM, Color, Collision")
    .color('rgb(0,0,255)')
    .attr({ x: 300, y: 150, w: 10, h: 10,
            dX: Crafty.math.randomInt(2, 5),
            dY: Crafty.math.randomInt(2, 5) })
    .bind('UpdateFrame', function () {
        //hit floor or roof
        if (this.y <= 0 || this.y >= 290)
            this.dY *= -1;

        // hit left or right boundary
        if (this.x > 600) {
            this.x = 300;
            Crafty("LeftPoints").each(function () {
                this.text(++this.points + " Points") });
        }
        if (this.x < 10) {
            this.x = 300;
            Crafty("RightPoints").each(function () {
                this.text(++this.points + " Points") });
        }

        this.x += this.dX;
        this.y += this.dY;
    })
    .onHit('Paddle', function () {
        this.dX *= -1;
    });

//Score boards
Crafty.e("LeftPoints, DOM, 2D, Text")
    .attr({ x: 20, y: 20, w: 100, h: 20, points: 0 })
    .text("0 Points");
Crafty.e("RightPoints, DOM, 2D, Text")
    .attr({ x: 515, y: 20, w: 100, h: 20, points: 0 })
    .text("0 Points");

Left paddle is controlled by W & S, right paddle by UpArrow & DownArrow.
Check it out online and try to modify it yourself here.

Developing

If you want to fix a bug, please submit a pull request against the development branch. Some guides to help you can be found on the wiki

If you would like to make larger contributions please catch us in the forum and we will help you get started. Much appreciated :-)

Quick build instructions

The easiest way to build crafty uses gruntjs, which requires node and npm. If you have grunt, node, and npm already installed, then run npm install from Crafty's root directory. (This will pull down about 30MB of node packages.) From then on, just run grunt to build.

You can also use yarn instead of npm.

(Full instructions here.)