selection: Create it's dedicated class

This commit is contained in:
2026-01-13 13:39:02 +01:00
parent f45c83dd77
commit 55341973b3
6 changed files with 141 additions and 60 deletions

24
includes/snapping.hpp Normal file
View File

@@ -0,0 +1,24 @@
/*
* File name: selection.cpp
* Author: lejulien
* Date created: 01-01-1970 00:59:59
// Date modified: 12-01-2026 21:30:10
* ------
*/
#pragma once
#include <types.hpp>
#include <raylib.h>
#include <cmath>
Vector2 snapToGrid(Vector2 screen, int cell_size) {
return {static_cast<float>(round(screen.x / cell_size) * cell_size),
static_cast<float>(round(screen.y / cell_size) * cell_size)};
}
Vector2i screenToGrid(Vector2 screen, int cell_size) {
return {static_cast<int>(round(screen.x / cell_size)),
static_cast<int>(round(screen.y / cell_size))};
}