Separate object layers, asign layers to proper slots
This commit is contained in:
40
game/main.c
40
game/main.c
@@ -15,7 +15,28 @@ typedef struct Game {
|
||||
|
||||
static Game GAME = {};
|
||||
|
||||
bool handleGameObjects(BzTileObjectLayer *objectLayer) {
|
||||
for (i32 i = 0; i < objectLayer->objectCount; i++) {
|
||||
BzTileObject object = objectLayer->objects[i];
|
||||
if (bzStringDefaultHash("camera") == object.id) {
|
||||
printf("Got camera\n");
|
||||
GAME.camera.target.x = object.shape.x;
|
||||
GAME.camera.target.y = object.shape.y;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool init(Game *game) {
|
||||
int screenWidth = 1280;
|
||||
int screenHeight = 720;
|
||||
|
||||
game->camera = (Camera2D){ 0 };
|
||||
game->camera.target = (Vector2) {0, 0};
|
||||
game->camera.offset = (Vector2) {screenWidth / 2.0f, screenHeight / 2.0f};
|
||||
game->camera.rotation = 0.0f;
|
||||
game->camera.zoom = 1.0f;
|
||||
|
||||
game->terrainTileset = bzTilesetCreate( &(BzTilesetDesc) {
|
||||
.path="assets/terrain.tsj",
|
||||
.texturePath="assets/terrain.png"
|
||||
@@ -28,18 +49,19 @@ bool init(Game *game) {
|
||||
game->map = bzTileMapCreate(&(BzTileMapDesc) {
|
||||
.path="assets/maps/test.tmj",
|
||||
.tilesets[0]=game->terrainTileset,
|
||||
.tilesets[1]=game->buildingsTileset
|
||||
.tilesets[1]=game->buildingsTileset,
|
||||
|
||||
.layers[0]=(BzTileLayerDesc) {"Terrain", NULL},
|
||||
.layers[1]=(BzTileLayerDesc) {"Foliage", NULL},
|
||||
.layers[2]=(BzTileLayerDesc) {"Trees", NULL},
|
||||
.layers[3]=(BzTileLayerDesc) {"TreesS", NULL},
|
||||
.layers[4]=(BzTileLayerDesc) {"Buildings", NULL},
|
||||
|
||||
.objectLayers[0]=(BzTileObjectsDesc) {"Game", handleGameObjects},
|
||||
.objectLayers[1]=(BzTileObjectsDesc ) {"Entities", NULL}
|
||||
});
|
||||
|
||||
|
||||
int screenWidth = 1280;
|
||||
int screenHeight = 720;
|
||||
|
||||
game->camera = (Camera2D){ 0 };
|
||||
game->camera.target = (Vector2) {0, 0};
|
||||
game->camera.offset = (Vector2) {screenWidth / 2.0f, screenHeight / 2.0f};
|
||||
game->camera.rotation = 0.0f;
|
||||
game->camera.zoom = 1.0f;
|
||||
return true;
|
||||
}
|
||||
void deinit(Game *game) {
|
||||
|
||||
Reference in New Issue
Block a user