domino-dungeon/game.c

36 lines
843 B
C
Raw Normal View History

2025-10-13 21:18:09 +02:00
#include <glad/glad.h>
#include <GLFW/glfw3.h>
#include "game.h"
2025-10-14 04:11:36 +02:00
#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))
#define CLAMP(x,a,b) (MIN(MAX(x,a),b))
2025-10-13 21:18:09 +02:00
2025-10-14 04:11:36 +02:00
int mouse_x = 0, mouse_y = 0;
void key_callback(int key, int scancode, int action, int mods) {
2025-10-13 21:18:09 +02:00
if (action != GLFW_PRESS) return;
switch (key) {
case GLFW_KEY_ENTER:
break;
case GLFW_KEY_BACKSPACE:
break;
}
}
2025-10-14 04:11:36 +02:00
void cursor_position_callback(int xpos, int ypos) {
mouse_x = xpos;
mouse_y = ypos;
}
void mouse_button_callback(int button, int action, int mods) {
if (button == GLFW_MOUSE_BUTTON_RIGHT && action == GLFW_PRESS) {}
}
2025-10-13 21:18:09 +02:00
void draw_image(decoded_image img) {
2025-10-14 04:11:36 +02:00
// for (int i = 0; i < img.buf_size; i++) img.buf[i] = i;
img.buf[CLAMP(mouse_y, 0, img.height) * img.width +
CLAMP(mouse_x, 0, img.width)] = -1;
2025-10-13 21:18:09 +02:00
}