Browse Source

Add gbuffer.h

master
cancel 6 years ago
parent
commit
76e8e65e13
  1. 9
      field.h
  2. 11
      gbuffer.h
  3. 1
      sim.c

9
field.h

@ -27,12 +27,3 @@ typedef enum {
} Field_load_error; } Field_load_error;
Field_load_error field_load_file(char const* filepath, Field* field); Field_load_error field_load_file(char const* filepath, Field* field);
inline Glyph gbuffer_peek_relative(Gbuffer gbuffer, Usz height, Usz width,
Usz y, Usz x, Isz delta_y, Isz delta_x) {
Isz y0 = (Isz)y + delta_y;
Isz x0 = (Isz)x + delta_x;
if (y0 < 0 || x0 < 0 || (Usz)y0 >= height || (Usz)x0 >= width)
return '.';
return gbuffer[(Usz)y0 * width + (Usz)x0];
}

11
gbuffer.h

@ -0,0 +1,11 @@
#pragma once
#include "base.h"
inline Glyph gbuffer_peek_relative(Gbuffer gbuffer, Usz height, Usz width,
Usz y, Usz x, Isz delta_y, Isz delta_x) {
Isz y0 = (Isz)y + delta_y;
Isz x0 = (Isz)x + delta_x;
if (y0 < 0 || x0 < 0 || (Usz)y0 >= height || (Usz)x0 >= width)
return '.';
return gbuffer[(Usz)y0 * width + (Usz)x0];
}

1
sim.c

@ -1,5 +1,6 @@
#include "field.h" #include "field.h"
#include "mark.h" #include "mark.h"
#include "gbuffer.h"
#include "sim.h" #include "sim.h"
//////// Utilities //////// Utilities

Loading…
Cancel
Save