summaryrefslogtreecommitdiff
path: root/game.c
blob: 1cfc1a15a2e776d2b6dccc966b48b77bb296bf23 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <glad/glad.h>
#include <GLFW/glfw3.h>

#include "game.h"

#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))

int mouse_x = 0, mouse_y = 0;

void key_callback(int key, int scancode, int action, int mods) {
  if (action != GLFW_PRESS) return;
  switch (key) {
    case GLFW_KEY_ENTER:
      break;
    case GLFW_KEY_BACKSPACE:
      break;
  }
}

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) {}
}

void draw_image(decoded_image img) {
  // 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;
}