integer math

This commit is contained in:
Jorijn van der Graaf 2025-11-23 04:04:53 +01:00
commit 5ff43e240c
27 changed files with 922 additions and 1011 deletions

View file

@ -24,8 +24,8 @@ Make sure that the window has focus.
## Highlighted Code Snippet
```cpp
EventListener<MousePoint> clickListener(&window.onMouseLeftClick, [](MousePoint point){
std::cout << std::format("Clicked on X:{} Y:{}!", point.x, point.y);
EventListener<MousePoint> clickListener(&window.onMouseLeftClick, [&window](MousePoint point){
std::cout << std::format("Clicked on X:{} Y:{}!", MappedToPixel(point.x, window.width), MappedToPixel(point.y, window.height));
});
EventListener<void> keyAListener(&window.onKeyDown['a'], [](){

View file

@ -4,15 +4,13 @@ import std;
using namespace Crafter;
int main() {
// Create a Wayland window named "HelloWindow" with resolution 1280x720
// (window creation explained in HelloWindow example)
Window window("HelloWindow", 1280, 720);
WindowWayland window(1280, 720, "Hello Input!");
// Listen for left mouse click events on the window
// The callback receives the MousePoint struct containing the click coordinates in float pixels from the top left corner
EventListener<MousePoint> clickListener(&window.onMouseLeftClick, [](MousePoint point){
EventListener<MousePoint> clickListener(&window.onMouseLeftClick, [&window](MousePoint point){
// Print the coordinates where the user clicked
std::cout << std::format("Clicked on X:{} Y:{}!", point.x, point.y) << std::endl;
std::cout << std::format("Clicked on X:{} Y:{}!", MappedToPixel(point.x, window.width), MappedToPixel(point.y, window.height)) << std::endl;
});
// Listen specifically for the 'a' key being pressed down
@ -29,6 +27,6 @@ int main() {
std::cout << std::format("Pressed the {} key!", key) << std::endl;
});
// Start the window event loop, unless the window is started events will not trigger.
//Start the window event loop, unless the window is started events will not trigger.
window.StartSync();
}