razterizer / termin8or Goto Github PK
View Code? Open in Web Editor NEWA slimmed down curses-like header-only library. Good for terminal-based games and such.
License: MIT License
A slimmed down curses-like header-only library. Good for terminal-based games and such.
License: MIT License
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
Refer to code in my slack boll-plank.
Among other things, centralize refactor and centralize per top-level Keyboard classes into the Termin8or lib.
Use a BSP-tree and FBM to modify the wall shapes.
Fix it so that it works on Windows and also so that it is more generic.
In programs such as Pilot Episode
and LapSim Lite
etc, the text (font) glyphs are typed in by hand, piece by piece. We want to replace this adhoc code with the new ASCII Font rendering system.
I'm not entirely sure what I meant when I wrote this ticket.
Here you can see that:
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.