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 🙏

© 2026 – Pkg Stats / Ryan Hefner

frogjs

v1.0.0-alpha.14

Published

FrogJS - A simple framework for making games with symbols/emojis on a grid

Downloads

318

Readme

FrogJS

A minimal framework for making games with emojis and symbols on a grid.

Features

  • 🎮 Grid-based rendering
  • 🔢 Integer coordinates only (by design!)
  • 🎯 No assets needed - emojis and characters only
  • 🚀 Lightweight and fast
  • 📦 TypeScript support included
  • 🤖 AI-friendly with comprehensive guidelines

Installation

Via CDN (Recommended)

<script type="module">
  import { Game, Sprite } from 'https://cdn.jsdelivr.net/npm/frogjs/dist/frog.js';
</script>

Via npm

npm install frogjs
import { Game, Sprite } from 'frogjs';

Quick Start

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8">
  <title>My FrogJS Game</title>
  <style>body { margin: 0; padding: 0; overflow: hidden; }</style>
</head>
<body>
  <script type="module">
    import { Game, Sprite } from 'https://cdn.jsdelivr.net/npm/frogjs/dist/frog.js';
    
    // Create game
    const game = new Game({
      gridWidth: 20,
      gridHeight: 36,
      theme: 'classic',
      orientation: 'portrait',
      name: 'My Game'
    });
    
    // Create player
    const player = new Sprite({ symbol: '🐸', x: 10, y: 7 });
    game.addSprite(player);
    
    // Game loop with movement
    game.onUpdate = () => {
      if (game.isLeftKeyDown() && player.x > 0) player.x--;
      if (game.isRightKeyDown() && player.x < 19) player.x++;
      if (game.isUpKeyDown() && player.y > 0) player.y--;
      if (game.isDownKeyDown() && player.y < 35) player.y--;
    };
  </script>
</body>
</html>

⚠️ Important: Integer Coordinates Only

FrogJS uses grid-based positioning with INTEGER coordinates only.

✅ CORRECT
sprite.x = 5;
sprite.y = 10;
player.x += 1;

❌ WRONG
sprite.x = 5.5;    // No fractional coordinates!
player.x += 0.1;   // No smooth movement!

See AI_GUIDELINES.md for complete details.

API Overview

Game

const game = new Game({
  gridWidth: 20,      // Grid width in cells
  gridHeight: 36,     // Grid height in cells
  theme: 'classic',   // Color theme: 'classic', 'midnight', 'forest', 'ocean', 
                      // 'sunset', 'neon', 'retro', 'mono', 'cyberpunk', 'pastel'
  orientation: 'portrait', // 'portrait' (GameBoy) or 'landscape' (Switch)
  name: 'My Game'     // Game name shown on device (default: 'FrogJS')
});

Device Orientation

All FrogJS games are wrapped in a retro console interface with on-screen controls. Choose the orientation:

// Portrait mode - looks like a GameBoy (vertical)
const game = new Game({
  orientation: 'portrait'
});

// Landscape mode - looks like a Nintendo Switch (horizontal)
const game = new Game({
  orientation: 'landscape'
});

Sprite

const sprite = new Sprite({
  symbol: '🐸',      // Emoji or character
  x: 10,             // Grid x (INTEGER!)
  y: 7,              // Grid y (INTEGER!)
  alpha: 1.0,        // Transparency
  z: 0,              // Render order
  angle: 0,          // Rotation (degrees)
  fixed: false,      // Ignore camera scroll
  color: '#ffffff'   // Symbol color
});

Methods

game.addSprite(sprite)
game.removeSprite(sprite)
game.getSprite(x, y)
game.getAllSprites(x, y)
game.clearSprites()
game.reset()  // Clear all state (sprites, animations, timers, callbacks, camera)

// Input - Polling (check if key is currently pressed)
game.isLeftKeyDown()
game.isRightKeyDown()
game.isUpKeyDown()
game.isDownKeyDown()
game.isSpaceKeyDown()

// Input - Event-based (register callbacks for key events)
game.onLeftKeyDown(callback, once?)   // Triggered when key is pressed
game.onLeftKeyUp(callback, once?)     // Triggered when key is released
game.offLeftKeyDown(callback)         // Remove a registered callback
game.offLeftKeyUp(callback)

// Same pattern for all keys:
// onRightKeyDown/Up, offRightKeyDown/Up
// onUpKeyDown/Up, offUpKeyDown/Up
// onDownKeyDown/Up, offDownKeyDown/Up
// onSpaceKeyDown/Up, offSpaceKeyDown/Up
//
// Use `once: true` for one-time callbacks:
// game.onSpaceKeyDown(() => jump(), true)  // Only fires once

// Animations
game.fadeSprite(sprite, startAlpha, endAlpha, duration, callback)
game.rotateSprite(sprite, startAngle, endAngle, duration, callback)

// Sound (Pascal-style)
game.sound(frequency, duration)  // frequency in Hz, duration in ms
// Example: game.sound(440, 200) plays A4 for 200ms

// Timing
game.timeout(delay, callback)
game.timer(delay, callback, times)

// Camera
game.scrollX = 0
game.scrollY = 0

Resources

For AI Agents

If you're an AI agent generating FrogJS games:

  1. Read this FIRST: AI_GUIDELINES.md
  2. Quick ref: llm.txt
  3. TypeScript defs: dist/frog.d.ts

Key constraint: INTEGER COORDINATES ONLY

Examples

See the examples/ directory for complete game examples.

License

MIT

Author

Arian Fornaris

Links

  • npm: https://www.npmjs.com/package/frogjs
  • CDN: https://cdn.jsdelivr.net/npm/frogjs/
  • Repository: https://github.com/yourusername/frogjs