Git Product home page Git Product logo

termin8or's Introduction

Termin8or

GitHub License

This is a cross-platform header-only curses-like lib.

Showcases

image image image image image image

Header Files

  • ASCII_Fonts.h : API for rendering text using FIGlet fonts and allows you to style your text with different colors. Supported FIGlet fonts are:
    • Larry3D.
    • SMSlant.
    • Avatar.
  • Color.h : Contains colour definitions for the 16 colors that Termin8or (and the terminal) supports. There are also two transparency colours / modes which allows you to overlay text using the same colours that are already present in a given location in the screen buffer (see SpriteHandler.h).
  • Gradient.h : Allows you to access a vector of given objects using a normalized (0 to 1) t parameter. Useful for particle systems and things like that where it is used for color gradients.
  • Drawing.h : Features some drawing functions such as bresenham::plot_line(), drawing::draw_box(), drawing::draw_box_textured(), drawing::draw_box_outline() and drawing::filled_circle_positions().
  • GameEngine.h : A highly customizable buy easy to use game engine (or engine for any real-time terminal-based program).
  • Keyboard.h : A keyboard handling API that is easy to use. Use class StreamKeyboard to poll key presses.
  • MessageHandler.h : The MessageHandler class allows you to queue up messages of different severity levels and durations. Messages are displayed in a ui::TextBox in the middle of the screen.
  • ParticleSystem.h : This ASCII-style particle system allows you to make cool real-time VFX such as liquids and fire-smoke. See (SurgSim_Lite and Pilot_Episode for examples).
  • RC.h : A struct representing the row and column position on the screen or in a texture or bounding box to mention a few.
  • Rectangle.h : A rectangle struct that can be used for bounding boxes etc.
  • Screen.h : A collection of functions for rendering dialogs and such:
    • Low-level functions: clear_screen(), return_cursor(), restore_cursor(), gotorc().
    • draw_frame() : Draws a simple frame around your frame buffer.
    • draw_game_over(), draw_you_won() : Draws wavy banners in the FIGlet font Grafitti. Used by GameEngine if those features are enabled.

termin8or's People

Contributors

razterizer avatar

Stargazers

 avatar  avatar

Watchers

 avatar

termin8or's Issues

Still problems with frame refresh on WSL Ubuntu

Image

Here you can see that:

  1. The terminal is not properly cleared.
  2. The final row gets duplicated below it.

I don't know the reason for the second issue, so therefore it is not so easy to fix, but the first issue can be solved by adding the following code in the init() function of GameEngine:

#ifndef __APPLE__
#ifndef __WIN32
std::system("clear");
#endif
#endif

Add mouse support.

There are three separate solutions for MacOS, Linux and Windows respectively. I have working code for MacOS for starters (from ChatGPT):

#include <iostream>
#include <ApplicationServices/ApplicationServices.h>

using namespace std;

// Global cursor position
int cursor_x = 40;
int cursor_y = 12;

// Callback function to handle mouse events
CGEventRef eventCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef event, void* refcon) {
    if (type == kCGEventMouseMoved || type == kCGEventLeftMouseDragged || type == kCGEventRightMouseDragged) {
        CGPoint location = CGEventGetLocation(event);
        cursor_x = static_cast<int>(location.x);
        cursor_y = static_cast<int>(location.y);

        std::cout << "(x, y) = (" << cursor_x << ", " << cursor_y << ")\n";
    }
    return event;
}

int main() {
    // Create an event tap
    CGEventMask eventMask = (1 << kCGEventMouseMoved) | (1 << kCGEventLeftMouseDragged) | (1 << kCGEventRightMouseDragged);
    CFMachPortRef eventTap = CGEventTapCreate(kCGHIDEventTap, kCGHeadInsertEventTap, 0, eventMask, eventCallback, nullptr);

    if (!eventTap) {
        cerr << "Failed to create event tap" << endl;
        return -1;
    }

    // Create a run loop source and add it to the current run loop
    CFRunLoopSourceRef runLoopSource = CFMachPortCreateRunLoopSource(kCFAllocatorDefault, eventTap, 0);
    CFRunLoopAddSource(CFRunLoopGetCurrent(), runLoopSource, kCFRunLoopCommonModes);

    // Enable the event tap
    CGEventTapEnable(eventTap, true);

    // Run the loop to start receiving events
    CFRunLoopRun();

    // Cleanup
    CFRelease(eventTap);
    CFRelease(runLoopSource);

    return 0;
}

This is built using:

g++ -o mouse_test mouse_test.cpp -framework ApplicationServices

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.