Added iterator operators to transmit information to iterators, so now the actor iterator can operate by layer. Added tree layers to the test map to illustrate it works by putting the player behind a tree.
Fixed a bug in actor rendering that rendered their world coordinates as screen coordinates regardless of where the camera was in relation to the world
This commit is contained in:
@@ -127,6 +127,11 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char *argv[])
|
||||
SDL_Log("Exception while loading tilemap: %s (%s)", EXCLIB_EXCEPTION->description, SDL_GetError());
|
||||
return SDL_APP_FAILURE;
|
||||
} ETRY;
|
||||
|
||||
camera.x = 0;
|
||||
camera.y = 0;
|
||||
camera.w = 640;
|
||||
camera.h = 480;
|
||||
|
||||
return SDL_APP_CONTINUE;
|
||||
}
|
||||
@@ -148,12 +153,19 @@ SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event)
|
||||
SDL_AppResult SDL_AppIterate(void *appstate)
|
||||
{
|
||||
SDL_FRect dest;
|
||||
SDL_FRect viewport = {.x = 50, .y = 50, .w = 640, .h = 480};
|
||||
b2Vec2 position;
|
||||
int i = 0;
|
||||
iterator opflags;
|
||||
|
||||
BITMASK_CLEAR(opflags.flags);
|
||||
BITMASK_ADD(opflags.flags, ITERATOR_OP_UPDATE);
|
||||
BITMASK_ADD(opflags.flags, ITERATOR_OP_RENDER);
|
||||
|
||||
GAME_draw_background(640, 480);
|
||||
tilemap_draw(renderer, &gamemap, &viewport, 0);
|
||||
SDL_EnumerateProperties(REGISTRY_ACTOR, ®istry_iterate_actor, NULL);
|
||||
for ( i = 0; i < gamemap.numlayers; i++ ) {
|
||||
opflags.layerid = i;
|
||||
tilemap_draw(renderer, &gamemap, &camera, i);
|
||||
SDL_EnumerateProperties(REGISTRY_ACTOR, ®istry_iterate_actor, (void *)&opflags);
|
||||
}
|
||||
SDL_RenderPresent(renderer);
|
||||
return SDL_APP_CONTINUE;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user