Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Suggestion] Getting the positions of a layer
#4
Okay so I tried to make a getter for the positions of a layer.
Code:
int TLN_GetLayerPosX(int nlayer)
{
    Layer* layer;
    if (nlayer >= engine->numlayers)
    {
        TLN_SetLastError(TLN_ERR_IDX_LAYER);
        return 0;
    }

    layer = &engine->layers[nlayer];
    if (layer->width == 0 || layer->height == 0)
    {
        TLN_SetLastError(TLN_ERR_REF_TILEMAP);
        return 0;
    }

    TLN_SetLastError(TLN_ERR_OK);
    if ((layer->tilemap && layer->tilemap->visible) || (layer->objects && layer->objects->visible))
    layer->ok = true;

    return layer->hstart;
}

int TLN_GetLayerPosY(int nlayer)
{
    Layer* layer;
    if (nlayer >= engine->numlayers)
    {
        TLN_SetLastError(TLN_ERR_IDX_LAYER);
        return 0;
    }

    layer = &engine->layers[nlayer];
    if (layer->width == 0 || layer->height == 0)
    {
        TLN_SetLastError(TLN_ERR_REF_TILEMAP);
        return 0;
    }

    TLN_SetLastError(TLN_ERR_OK);
    if ((layer->tilemap && layer->tilemap->visible) || (layer->objects && layer->objects->visible))
    layer->ok = true;

    return layer->vstart;
}

Is it any good? Should I improve something?
Reply


Messages In This Thread
RE: [Suggestion] Getting the positions of a layer - by System64 - 04-11-2022, 10:50 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)