aboutsummaryrefslogtreecommitdiff
path: root/src/tiles.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tiles.c')
-rw-r--r--src/tiles.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/tiles.c b/src/tiles.c
index 2432736..6b7a39b 100644
--- a/src/tiles.c
+++ b/src/tiles.c
@@ -1,14 +1,16 @@
#include <stdio.h>
#include <stdlib.h>
+#include "typedef.h"
+#include "tiles.h"
#include "ppm.h"
-extern small_t *(tiles[]);
extern size_t TILES;
extern size_t TILE_WIDTH;
extern size_t TILE_HEIGHT;
-extern small_t tile_connections[];
+small_t *(tiles[TILES_CAP]);
+small_t tile_connections[TILES_CAP];
void load_tiles()
{
@@ -33,6 +35,7 @@ void print_tiles()
{
for(size_t i = 0; i < TILES; i++)
{
+ printf("%ld\n", i);
for(size_t y = 0; y < TILE_HEIGHT; y++)
{
for(size_t x = 0; x < TILE_WIDTH; x++)
@@ -43,7 +46,12 @@ void print_tiles()
}
}
-void load_connections()
+int get_tile_pixel(size_t t, size_t x, size_t y)
+{
+ return tiles[t][y * TILE_WIDTH + x];
+}
+
+small_t *load_tile_connections()
{
char file_path[32] = "files/tiles/tiles.dat";
FILE *fp = fopen(file_path, "rb");
@@ -55,11 +63,13 @@ void load_connections()
fread(tile_connections, sizeof(small_t), TILES, fp);
fclose(fp);
+
+ return tile_connections;
}
#include <dirent.h>
-size_t calc_tiles()
+void calc_tiles()
{
size_t file_count = 0;
DIR * dirp;
@@ -73,5 +83,5 @@ size_t calc_tiles()
}
closedir(dirp);
- return file_count-1;
+ TILES = file_count - 1;
}