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

space-defender

v1.0.0

Published

A small game, programmed in typescript. The goal of the game is to shoot down as many spaceships as possible with your spaceship and not get hit yourself.

Downloads

1

Readme

Game Context

With the Game Context you develop games faster and more effectively. It lets you create game objects that you can dynamically modify and render them on your website using Game Context.

Structure

The Game Context consists of two main modules: the Game Context and the Game Object. The Game Context has the task to contain all created Game Objects and to render them if necessary. The Game Objects describe how objects behave and must be rendered.

Game Context Module

This module contains and manages all game objects and draws them on the canvas. It also provides a function that repeats the game loop at given time intervals.

Create a GameContext

To do this, you just need to initialize the class and consider required arguments: CanvasRenderingContext, width of the canvas, height of the canvas.

Add / remove a GameObject

To add or remove one or more GameObjects, you can simply manipulate the gameObjects property.

Update all GameObjects

To do this, call the update method. You also need to specify a callable updater function. This function is executed for each specified GameObject and contains the following parameters: The current GameObject and the GameContext.

Draw all GameObjects

To achieve this, you must call the draw method. Similar to the 'update' method, a draw function can be specified here, which then receives the following parameters: The current GameObject, the GameContext and the CanvasRenderingContext (ctx). However, this does not have to be the case. If no drawing function is specified. The GameContext draws the GameObject with given coordinates and background itself.

GameObject

This module describes how objects behave and are drawn in the game.

Creating a GameObject

To create a GameObject, you need to initialize the class and observe the following configuration as an object.

Configuration

The configuration should be specified as the first argument in an object.

  • width:number - width of the object
  • height:number - height of the object
  • position:{x: number, y:number}? - position of the object - default: {x:0,y:0}
  • background:string|CanvasImageSource? - background of the object - default: 'black'.

Event system

The GameObject offers to listen for certain events. When an event is triggered, the specified functions are executed. To create an EventListener you need to execute the addEventListener method. The first argument of the method is the type of the event as string and the function that should be executed then. This function receives the following parameters: The GameObject and possibly additional parameters (depending on the event). To trigger an event you have to call the following function triggerListener with the type of the event as string.

Events

  • newposition
  • draw