{"id":13292193,"url":"https://github.com/J-Puls/domain-destroyer","last_synced_at":"2025-03-10T06:34:14.201Z","repository":{"id":57214858,"uuid":"293857545","full_name":"J-Puls/domain-destroyer","owner":"J-Puls","description":"A modern spin-off of the timeless Desktop Destroyer game developed by Miroslav Němeček","archived":false,"fork":false,"pushed_at":"2020-12-29T19:24:05.000Z","size":459,"stargazers_count":7,"open_issues_count":1,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-09T15:47:30.417Z","etag":null,"topics":["90s","browser-game","desktop-destroyer","game","html-game","ing","mini-game","miroslav-nemecek","react","reactjs","retro","typescript","vintage"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/J-Puls.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-08T15:51:17.000Z","updated_at":"2023-12-26T00:13:00.000Z","dependencies_parsed_at":"2022-08-29T04:00:57.793Z","dependency_job_id":null,"html_url":"https://github.com/J-Puls/domain-destroyer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/J-Puls%2Fdomain-destroyer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/J-Puls%2Fdomain-destroyer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/J-Puls%2Fdomain-destroyer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/J-Puls%2Fdomain-destroyer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/J-Puls","download_url":"https://codeload.github.com/J-Puls/domain-destroyer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242805773,"owners_count":20187996,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["90s","browser-game","desktop-destroyer","game","html-game","ing","mini-game","miroslav-nemecek","react","reactjs","retro","typescript","vintage"],"created_at":"2024-07-29T17:07:28.971Z","updated_at":"2025-03-10T06:34:13.661Z","avatar_url":"https://github.com/J-Puls.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# domain-destroyer\n\nA modern recreation of the timeless Desktop Destroyer game developed by Miroslav Němeček, written in TypeScript for the web.\n\n## Controls\n\n| key     | function            |\n| ------- | ------------------- |\n| `mouse` | **fire weapon**     |\n| `1 key` | **hammer**          |\n| `2 key` | **machine gun**     |\n| `3 key` | **stamp**           |\n| `c key` | **clear screen**    |\n| `- key` | **previous weapon** |\n| `= key` | **next weapon**     |\n| `; key` | **volume down**     |\n| `' key` | **volume up**       |\n\n\u003chr/\u003e\n## Installation\n\n```bash\nnpm i domain-destroyer\n```\n\nor\n\n[clone the repository](https://github.com/J-Puls/domain-destroyer.git) and compile the TypeScript yourself with\n\n```bash\nnpm run build\n```\n\n\u003chr/\u003e\n## Setup\n\n- Import the `Destroyer` constructor\n\n```javascript\nimport Destroyer from \"domain-destroyer\";\n```\n\n- Import the included CSS file\n\n```javascript\nimport \"domain-destroyer/dist/css/destroyer.min.css\";\n```\n\n\u003chr/\u003e\n## API\n\nThe **`Destroyer`** constructor takes two arguments:\n\n- **`parent`**: `HTMLDivElement` - the element to act as the bounding container for the game contents\n\n- **`options`**: `object` - optional parameters for controlling different aspects of the game upon instantiation\n\n  - **`defaultVolume`**: `number (0 - 1)` - the initial volume\n\n  - **`onDamage`**: `(pageHealth) =\u003e {}` - a callback function that will be called when a weapon _\"inflicts damage\"_ to the page\n\n  - **`pageHealth`**: `number` - the total amount of _\"health\"_ the page has (this is decremented every time a weapon fires)\n\n  - **`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)\n\n  - **`volumeChangeDelta`**: `number (0 - 1)` - how much the volume is incremented / decremented when calling `volumeUp()` or `volumeDown()`\n\n  - **`zIndexStart`**: `number` - the z-index at which game elements should begin layering\n\nOnce instantiated, you will have access to the following noteworthy properties and methods:\n\n| property              | description                                                                                                                                                   |\n| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| **`clear()`**         | clears all currently rendered particles                                                                                                                       |\n| **`currentWeaponID`** | the numeric ID for the current weapon in use                                                                                                                  |\n| **`fire()`**          | triggers the weapon to fire a single shot                                                                                                                     |\n| **`inject()`**        | injects the visible contents of the game into the parent element                                                                                              |\n| **`isFiring`**        | boolean relating to the current state of the weapon                                                                                                           |\n| **`mousePos`**        | tracks the x / y coordinates of the mouse within the viewport                                                                                                 |\n| **`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) |\n| **`setVolume()`**     | explicitly sets a certain volume level (from 0 to 1)                                                                                                          |\n| **`setWeapon()`**     | explicitly sets the weapon by its numeric ID                                                                                                                  |\n| **`updateCSS()`**     | updates the CSS variables pertaining to the current weapon                                                                                                    |\n| **`volume`**          | the volume level (from 0 to 1)                                                                                                                                |\n| **`volumeDown()`**    | lowers the volume by .1 until min volume is reached                                                                                                           |\n| **`volumeUp()`**      | raises the volume by .1 until max volume is reached                                                                                                           |\n| **`weaponDown()`**    | sets the current weapon to the previous in the list                                                                                                           |\n| **`weaponUp()`**      | sets the current weapon to the next in the list                                                                                                               |\n\n\u003chr/\u003e\n## Usage\n\n1. Save your desired parent container to a variable\n\n```javascript\nconst myParent = document.querySelector(\"#myParent\");\n```\n\n2. Create an instance of the `Destroyer` object, passing it the `parent` and `options` arguments\n\n3. Inject the `Destroyer` game components into your selected parent container using the `inject()` method\n\n```javascript\nconst options = { particleLimit: 20, zIndexStart: 5 };\n\nconst myDestroyer = new Destroyer(myParent, options);\n\nmyDestroyer.inject();\n```\n\n### Example\n\nBelow is an example of how to use domain-destroyer in a **`React`** component.\n\n```javascript\nimport React, { useEffect, useState } from \"react\";\nimport Destroyer from \"domain-destroyer\";\nimport \"domain-destroyer/dist/css/destroyer.min.css\";\n\nconst App = () =\u003e {\n  let myParent;\n  const [destroyer, setDestroyer] = useState(null);\n\n  const options = {\n    defaultVolume: 0.5,\n    particleLimit: 20,\n    zIndexStart: 5,\n    onDamage: (pageHealth) =\u003e console.log(pageHealth),\n    pageHealth: 200,\n    volumeChangeDelta: 0.5,\n  };\n\n  useEffect(() =\u003e {\n    myParent \u0026\u0026 setDestroyer(new Destroyer(myParent, options));\n  }, [myParent]);\n\n  useEffect(() =\u003e {\n    destroyer \u0026\u0026 destroyer.inject();\n  }, [destroyer]);\n\n  return \u003cdiv className=\"myParent\" ref={(el) =\u003e (myParent = el)} /\u003e;\n};\n\nexport default App;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJ-Puls%2Fdomain-destroyer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FJ-Puls%2Fdomain-destroyer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FJ-Puls%2Fdomain-destroyer/lists"}