0.0.2 â€ĸ Published 4 months ago

react-incremental-library v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

đŸ•šī¸ React Incremental Game Library

A collection of high-performance React hooks designed for incremental, clicker, and idle games. 🚀

✨ Features

  • Auto-incrementing resources
  • Achievements tracking
  • Clicker mechanics
  • Game loop management
  • Idle progression
  • Resource caps & multipliers
  • And more to come!

đŸ“Ļ Installation

[npm | bun | yarn | pnpm] add react-incremental-library

đŸ› ī¸ Usage

Each hook is designed with simplicity and flexibility in mind. Here are a few usage examples:

🔄 Game Loop (useGameLoop)

Runs a function at a fixed FPS to handle frame-based updates.

import { useGameLoop } from "react-incremental-library";

useGameLoop({
  fps: 60,
  update: () => console.log("Game loop running!"),
});

đŸ–ąī¸ Clicker (useClicker)

Manages a click-based resource.

import { useClicker } from "react-incremental-library";

const { count, handleClick } = useClicker({
  onClick: (val) => console.log("Clicked!", val)
});

đŸŽ–ī¸ Achievements (useAchievement)

Tracks when a condition is met and unlocks achievements.

import { useAchievement } from "react-incremental-library";

const { unlocked } = useAchievement({
  name: "First Click",
  condition: clicks >= 1,
  onUnlock: () => console.log("Unlocked!")
});

đŸ”ŧ Auto-Increment (useAutoIncrement)

Increases currency automatically over time.

import { useAutoIncrement } from "react-incremental-library";

const { pause, resume, isPaused } = useAutoIncrement({
  interval: 1000,
  increaseBy: 5,
  onAutoIncrement: (amount) => console.log(`Gained ${amount}!`)
});

💰 Resource Cap (useResourceCap)

Prevents resources from exceeding a maximum limit.

import { useResourceCap } from "react-incremental-library";

const { resource, addResource, removeResource } = useResourceCap({
  initialValue: 50,
  max: 100
});

💤 Idle Progress (useIdleProgress)

Rewards players for time spent away.

import { useIdleProgress } from "react-incremental-library";

const { idleGain } = useIdleProgress({ resourcePerSecond: 2 });
console.log(`You gained ${idleGain} resources while away!`);

📄 API Documentation

The following table lists the hooks available in the library. This list is designed to update automatically as new hooks and features are added. For a detailed look at each hook, please visit our examples folder.

HookDescription
useGameLoopRuns a function at a fixed FPS.
useClickerManages click-based interactions.
useAchievementUnlocks achievements when conditions are met.
useAchievementsTracks multiple achievements.
useAutoIncrementAutomates resource accumulation over time.
useResourceCapPrevents resources from exceeding max limits.
useIdleProgressRewards players for offline time.
useMultiplierApplies multipliers to resource generation.
useSaveGameSaves game state to local storage.
useLoadSaveGameLoads saved game state from local storage.
useTickCalls a function at a set interval.
useCooldownImplements cooldown mechanics for actions.
useUpgradeHandles game upgrades and purchases.

🎮 Contributing

PRs are welcome! If you have an idea for a new hook or an improvement, feel free to submit a request or open an issue. For usage examples, please refer to our examples folder.


âš–ī¸ License

MIT License Š 2025 - Tommy Danks


🚀 Start Building Your Incremental Game Today!


â¤ī¸

Reminder that you are great, you are enough, and your presence is valued. If you are struggling with your mental health, please reach out to someone you love and consult a professional. You are not alone; there is a large range of resources online for support and guidance.