Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
src/InputMonitor.cpp
include/InputMonitor.h
src/Settings.cpp
include/Settings.h)
include/Settings.h
include/displayUtils.h)
endif()
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
在游戏运行时,你可以输入以下按键:

| 按键 | 功能 |
| --- | -------------- |
| --- |----------------|
| `a` | 点击,增加点数 |
| `u` | 打开升级菜单 |
| `b` | 打开建筑商店 |
Expand Down
55 changes: 55 additions & 0 deletions README_EN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# FunnyNumber Idle Game

A small idle game you can run in the background while coding or working over SSH, giving you a little sense of achievement right from the command line.

---

## ✨ Features

* **Idle gameplay**: Points increase automatically over time
* **Active boost**: Press `a` to manually gain points
* **Upgrades & Buildings**:

* **Upgrades** – make your clicks stronger
* **Buildings** – increase automatic growth rate
* **Funny big number system**: Uses an *“INT\_MAX carry-over”* mechanic — because it’s funnier this way

---

## 🕹️ Controls

While the game is running, you can press the following keys:

| Key | Action |
| --- | ----------------------- |
| `a` | Click to gain points |
| `u` | Open upgrade menu |
| `b` | Open building shop |
| `s` | Open settings menu |
| `y` | Confirm action in menus |
| `m` | Return to main menu |

---

## 📖 Game Mechanics

* Initial click value: **1 point per click**
* Initial auto-growth: **1 point per second**
* Auto-growth increases based on the number of buildings you own
* Buying upgrades and buildings consumes points
* Each purchase generates a new, more expensive option

---

## ⚙️ Settings (WIP)

* Work in progress

---

## 🚀 Possible Future Improvements

* Save/load system
* More diverse upgrade/building trees
* Leaderboards
* Optional ASCII art UI
26 changes: 26 additions & 0 deletions include/DisplayUtils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// Created by Calcite on 2025/9/15.
//
#ifndef DISPLAYUTILS_H
#define DISPLAYUTILS_H

#pragma once
#include <string>

#define nl std::endl
#define RESET_COLOR "\033[0m"
#define RED "\033[31m"
#define GREEN "\033[32m"
#define YELLOW "\033[33m"
#define BLUE "\033[34m"
#define MAGENTA "\033[35m"
#define CYAN "\033[36m"
#define WHITE "\033[37m"

const std::string title =
"\033[31m __ __ _ ____ ____ ___ ____ ____\n"
"\033[33m ( )( ( \\(_ _)( __)/ __)( __)( _ \\\n"
"\033[32m )( / / )( ) _)( (_ \\ ) _) ) /\n"
"\033[34m (__)\\_)__) (__) (____)\\___/(____)(__\\_)\n";

#endif //DISPLAYUTILS_H
38 changes: 19 additions & 19 deletions include/Game.h
Original file line number Diff line number Diff line change
@@ -1,33 +1,32 @@
#ifndef GAME_H
#define GAME_H

#define nl std::endl
#define RESET_COLOR "\033[0m"
#define RED "\033[31m"
#define GREEN "\033[32m"
#define YELLOW "\033[33m"
#define BLUE "\033[34m"
#define MAGENTA "\033[35m"
#define CYAN "\033[36m"
#define WHITE "\033[37m"


#include <vector>
#include <string>
#include <mutex>


#ifdef _WIN64
#include <windows.h>
#else
#include <sys/ioctl.h>
#include <unistd.h>
#endif

#include "DisplayUtils.h"
#include "Buyables.h"
#include "InputMonitor.h"
#include "Settings.h"

class Settings;
class Game {
public:
const std::string title =
"\033[31m __ __ _ ____ ____ ___ ____ ____\n"
"\033[33m ( )( ( \\(_ _)( __)/ __)( __)( _ \\\n"
"\033[32m )( / / )( ) _)( (_ \\ ) _) ) /\n"
"\033[34m (__)\\_)__) (__) (____)\\___/(____)(__\\_)\n";
std::string username;
std::string statMessage;
std::atomic<bool> bIsRunning;
std::atomic<bool> bInputMode;
std::atomic<bool> bIsDisplayOnHalt;
const int FRAMERATE = 40;
const int AUTO_INCREMENT_RATE = 40;
const int CLICK_COOLDOWN = 10;
Expand All @@ -36,6 +35,7 @@ class Game {
int iClickIncrement;
int iAutoIncrement;
int iOptionIdx;
int LINE_HEIGHT = 0;
bool bIsInputThreadRunning;
void (Game::*buyConfirm)(int idx);
void (Settings::*settingConfirm)(int idx);
Expand All @@ -51,22 +51,22 @@ class Game {
Game();
~Game();
void gameRun();

void initWindow();
void setHalt(bool active);
void display();
void displayNumber();
void displayMenu();
static void displaySettings();
static void displayMainMenu();
void displayUpgrade();
void displayShop();
static void displayMainMenu();

void handleKey(int ch);
static void clear_screen();

std::vector<int> increment(int carry);
std::vector<int> increment(const std::vector<int>& carry);
std::vector<int> decrement(const std::vector<int>& cost);
bool isSufficient(const std::vector<int>& cost);
bool isSufficient(const std::vector<int>& cost) const;
void click();

void buyUpgrade(int idx);
Expand Down
5 changes: 4 additions & 1 deletion include/InputMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@ class InputMonitor {
public:
using Callback = std::function<void(int)>;

InputMonitor(): bRunning(false){}
InputMonitor(): paused(false), bRunning(false){}
~InputMonitor();
std::atomic<bool> paused;
void start(const Callback& callback);
void stop();
void pause();
void resume();

private:
std::atomic<bool> bRunning;
Expand Down
34 changes: 28 additions & 6 deletions include/Settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,38 @@

#ifndef SETTINGS_H
#define SETTINGS_H
#include "InputMonitor.h"
#include <vector>



class Game;
class Settings {
public:
Settings();
int thisSettingPage;
Game* game = nullptr;
enum settingState{menu, username, exportSave, loadSave};
Settings(Game* g);
~Settings();
void load_settings();
void save_settings();
void confirm(int idx);
void loadSettings();
void saveSettings();
void displaySettings();

void displaySettingsMainMenu();


void displaySettingsExportSave(); // $username.ids

void displaySettingsLoadSave();

void setUsername();

void confirm(int option);

struct saveData {
std::vector<int> theFunnyNumber;
int uLevel;
int bLevel;
};

};


Expand Down
Loading
Loading