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

win-destroyer-ts

v0.0.1

Published

A modern recreation of the timeless Desktop Destroyer game developed by Ing. Miroslav Nemecek, written in TypeScript.

Downloads

58

Readme

domain-destroyer

A modern recreation of the timeless Desktop Destroyer game developed by Miroslav Němeček, written in TypeScript for the web.

Controls

| key | function | | ------- | ------------------- | | mouse | fire weapon | | 1 key | hammer | | 2 key | machine gun | | 3 key | stamp | | c key | clear screen | | - key | previous weapon | | = key | next weapon | | ; key | volume down | | ' key | volume up |

npm i domain-destroyer

or

clone the repository and compile the TypeScript yourself with

npm run build
  • Import the Destroyer constructor
import Destroyer from "domain-destroyer";
  • Import the included CSS file
import "domain-destroyer/dist/css/destroyer.min.css";

The Destroyer constructor takes two arguments:

  • parent: HTMLDivElement - the element to act as the bounding container for the game contents

  • options: object - optional parameters for controlling different aspects of the game upon instantiation

    • defaultVolume: number (0 - 1) - the initial volume

    • onDamage: (pageHealth) => {} - a callback function that will be called when a weapon "inflicts damage" to the page

    • pageHealth: number - the total amount of "health" the page has (this is decremented every time a weapon fires)

    • particleLimit: number - the maximum number of particles allowed to exist at one time (only effects the animation phase of rendering, not how many particles are persisted on screen)

    • volumeChangeDelta: number (0 - 1) - how much the volume is incremented / decremented when calling volumeUp() or volumeDown()

    • zIndexStart: number - the z-index at which game elements should begin layering

Once instantiated, you will have access to the following noteworthy properties and methods:

| property | description | | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | | clear() | clears all currently rendered particles | | currentWeaponID | the numeric ID for the current weapon in use | | fire() | triggers the weapon to fire a single shot | | inject() | injects the visible contents of the game into the parent element | | isFiring | boolean relating to the current state of the weapon | | mousePos | tracks the x / y coordinates of the mouse within the viewport | | particleLimit | the number of particle animators allowed to exist at one time (for animation performance only, does not limit how many particles are persisted on the screen) | | setVolume() | explicitly sets a certain volume level (from 0 to 1) | | setWeapon() | explicitly sets the weapon by its numeric ID | | updateCSS() | updates the CSS variables pertaining to the current weapon | | volume | the volume level (from 0 to 1) | | volumeDown() | lowers the volume by .1 until min volume is reached | | volumeUp() | raises the volume by .1 until max volume is reached | | weaponDown() | sets the current weapon to the previous in the list | | weaponUp() | sets the current weapon to the next in the list |

  1. Save your desired parent container to a variable
const myParent = document.querySelector("#myParent");
  1. Create an instance of the Destroyer object, passing it the parent and options arguments

  2. Inject the Destroyer game components into your selected parent container using the inject() method

const options = { particleLimit: 20, zIndexStart: 5 };

const myDestroyer = new Destroyer(myParent, options);

myDestroyer.inject();

Example

Below is an example of how to use domain-destroyer in a React component.

import React, { useEffect, useState } from "react";
import Destroyer from "domain-destroyer";
import "domain-destroyer/dist/css/destroyer.min.css";

const App = () => {
  let myParent;
  const [destroyer, setDestroyer] = useState(null);

  const options = {
    defaultVolume: 0.5,
    particleLimit: 20,
    zIndexStart: 5,
    onDamage: (pageHealth) => console.log(pageHealth),
    pageHealth: 200,
    volumeChangeDelta: 0.5,
  };

  useEffect(() => {
    myParent && setDestroyer(new Destroyer(myParent, options));
  }, [myParent]);

  useEffect(() => {
    destroyer && destroyer.inject();
  }, [destroyer]);

  return <div className="myParent" ref={(el) => (myParent = el)} />;
};

export default App;