summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2023-07-11 01:59:45 +0100
committerdavidovski <david@davidovski.xyz>2023-07-11 01:59:45 +0100
commite8b6b1f0ee8b825443972b99b191fd5a85437008 (patch)
tree8680b4ea5e424b72e1e044f06ab9ae5d3003ef24 /src
parent86da5bd3b0b5e0a8d9e68534297ca0446d2f735d (diff)
make consistent variable names
Diffstat (limited to 'src')
-rw-r--r--src/tiled.c4
-rw-r--r--src/tiledfile.c29
-rw-r--r--src/tiledfile.h2
3 files changed, 18 insertions, 17 deletions
diff --git a/src/tiled.c b/src/tiled.c
index 0cdd8f1..49f957f 100644
--- a/src/tiled.c
+++ b/src/tiled.c
@@ -46,8 +46,8 @@ void initTiled(Tiled *tiled, TiledMap tiledMap) {
textureFromPixels(&tiled->atlasTexture,
tiledMap.atlasData,
- tiledMap.atlasSize[0] * tiledMap.tilesize,
- tiledMap.atlasSize[1] * tiledMap.tilesize);
+ tiledMap.atlasSize[0] * tiledMap.tileSize,
+ tiledMap.atlasSize[1] * tiledMap.tileSize);
renderTilemapTexture(&tiled->tilemapTexture, tiledMap);
diff --git a/src/tiledfile.c b/src/tiledfile.c
index a8de9cd..d6d4b1b 100644
--- a/src/tiledfile.c
+++ b/src/tiledfile.c
@@ -59,37 +59,38 @@ int readb(char * out, size_t noBytes, FILE * file) {
//! load tilemap data from file
TiledMap loadTiledMap(char * filename) {
- TiledMap tiledmap;
+ TiledMap tiledMap;
FILE * file;
if (!(file = fopen(filename, "rb"))) {
fprintf(stderr, "Failed to load %s\n", filename);
- return tiledmap;
+ return tiledMap;
}
// skip header
fseek(file, 10, SEEK_CUR);
// 4 bytes for int width
- readb((char *)&tiledmap.width, 4, file);
+ readb((char *)&tiledMap.width, 4, file);
// 4 bytes for int height
- readb((char *)&tiledmap.height, 4, file);
+ readb((char *)&tiledMap.height, 4, file);
- size_t layoutSize = tiledmap.width*tiledmap.height;
- tiledmap.tilelayout = malloc(layoutSize);
- fread(tiledmap.tilelayout, layoutSize, 1, file);
+ size_t layoutSize = tiledMap.width*tiledMap.height;
+ tiledMap.tilelayout = malloc(layoutSize);
+ fread(tiledMap.tilelayout, layoutSize, 1, file);
// read the pixel size of each tile
- readb((char *)&tiledmap.tilesize, 4, file);
+ readb((char *)&tiledMap.tileSize, 4, file);
// read the atlas size
- readb((char *)&tiledmap.atlasSize[0], 4, file);
- readb((char *)&tiledmap.atlasSize[1], 4, file);
+ readb((char *)&tiledMap.atlasSize[0], 4, file);
+ readb((char *)&tiledMap.atlasSize[1], 4, file);
// read the atlas itself
- size_t atlasSizeBytes = tiledmap.atlasSize[0]*tiledmap.tilesize*tiledmap.atlasSize[1]*tiledmap.tilesize*4;
- tiledmap.atlasData = malloc(atlasSizeBytes);
- fread(tiledmap.atlasData, atlasSizeBytes, (size_t) 1, file);
+ size_t atlasSizeBytes = tiledMap.atlasSize[0]*tiledMap.tileSize*tiledMap.atlasSize[1]*tiledMap.tileSize*4;
+ tiledMap.atlasData = malloc(atlasSizeBytes);
+ fread(tiledMap.atlasData, atlasSizeBytes, (size_t) 1, file);
fclose(file);
- return tiledmap;
+ return tiledMap;
}
+
diff --git a/src/tiledfile.h b/src/tiledfile.h
index c9bd573..929dabc 100644
--- a/src/tiledfile.h
+++ b/src/tiledfile.h
@@ -4,7 +4,7 @@ typedef struct TiledMap {
int width;
int height;
char * tilelayout;
- int tilesize;
+ int tileSize;
int atlasSize[2];
Color * atlasData;
} TiledMap;