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

@suey/loader

v1.0.4

Published

many games laoder to play.

Downloads

6

Readme

安装

npm config set registry https://registry.npmjs.org

npm install @suey/loader --save

快速建立

<style>
    * { margin: 0;padding: 0; }
    body { overflow: hidden; }
    #app { width: 100vw;height: 100vh; }
</style>

<div id="app"></div>
import { loader } from '@suey/loader/planeGame';

// 默认的玩家1 wasd 上下左右 j 攻击
// 默认的玩家2 ↑↓←→ 上下左右 小键盘1 攻击

// 加载挂载的元素 id
loader('app').then(async ({ controller }) => {
  controller.start(); // 立即开始游戏

  controller.appendGameoverCbk(message => {
    console.log(message.winPlane);
  }); // 添加一个游戏结束的回调


  window.addEventListener('keydown', (e: KeyboardEvent) => {
    if (e.key.toLocaleLowerCase() === 'r') {
      controller.start(); // 当按下 r 键的时候重新开始
    }
  });

  window.addEventListener('keydown', e => {
    if (e.key.toLocaleLowerCase() === 'p') {
      controller.stop(); // 当按下 p 键的时候暂停游戏
    }
  });

  window.addEventListener('keydown', e => {
    if (e.key.toLocaleLowerCase() === 'o') {
      controller.go(); // 当按下 o 键的时候继续游戏
    }
  })
});

自定义元素

当默认的元素模型已经不能再满足你的需求的时候,你可以自定义飞机,子弹,按键等等

import { loader } from '@suey/loader';

import type { Init } from '@suey/loader';
import {
  Plane, Weapon,
  assetLoader, makeCharKey, makeArrowKey, makeDigitKey, makeNumpadKey
} from '@suey/loader';

loader('app').then(async ({ controller }) => {
  // 创建 Init 函数 用户装载玩家飞机
  const init: Init = async () => {
    const playerOne = new Plane(
      100, 100, '#f00',
      await assetLoader('http://www.baidu.com/xxxxxx/xxxx.png'), // 使用 assetLoader 加载外部资源, 作为飞机的图片
      new Weapon(await assetLoader('http://www.baidu.com/xxxxx/xxx.png'), 3, 2, 2) // 创建飞机的武器, 子弹的图片, 子弹数量,子弹攻速,子弹飞行速度
    );

    playerOne.registerEventListener( // 为飞机添加按键
      makeCharKey('w'), makeCharKey('s'),
      makeCharKey('a'), makeCharKey('d'),
      makeCharKey('j'), makeCharKey('k')
    );

    const playerTwo = new Plane(
      100, 100, '#0f0',
      await assetLoader('http://www.baidu.com/xxxxxx/xxxx.png'),
      new Weapon(await assetLoader('http://www.baidu.com/xxxxx/xxx.png'), 1, 1, 1)
    );

    playerTwo.registerEventListener(
      makeArrowKey('up'), makeArrowKey('down'),
      makeArrowKey('left'), makeArrowKey('right'),
      makeNumpadKey('1'), makeNumpadKey('2')
    );

    return [playerOne, playerTwo];
  }

  controller.start(init); // 开始游戏
});