diff options
| author | Tomas Chvatal (scarabeus) <tomas.chvatal@gmail.com> | 2008-10-22 22:51:24 +0200 |
|---|---|---|
| committer | Tomas Chvatal (scarabeus) <tomas.chvatal@gmail.com> | 2008-10-22 22:51:24 +0200 |
| commit | 44daf03024fbf7cbffa10349044786f6ab784821 (patch) | |
| tree | fe311eb22e2d853dfc18fde1a9e55d21815f4f82 /src/client/layer.c | |
| parent | e12753d2ec9db83ec08bb9db63902a82fb245cdd (diff) | |
Revert "X"
This reverts commit e12753d2ec9db83ec08bb9db63902a82fb245cdd.
Diffstat (limited to 'src/client/layer.c')
| -rwxr-xr-x | src/client/layer.c | 260 |
1 files changed, 135 insertions, 125 deletions
diff --git a/src/client/layer.c b/src/client/layer.c index cadb7c6..8e77ee4 100755 --- a/src/client/layer.c +++ b/src/client/layer.c @@ -16,20 +16,18 @@ static list_t *listLayer; static bool_t isLayerInit = FALSE; -bool_t -isLayerInicialized() +bool_t isLayerInicialized() { - return isLayerInit; + return isLayerInit; } /* * Inicializuje globalny zoznam vsrtiev */ -void -initLayer() +void initLayer() { - listLayer = newList(); - isLayerInit = TRUE; + listLayer = newList(); + isLayerInit = TRUE; } /* @@ -39,42 +37,46 @@ initLayer() * px py pw ph - suradnica casti obrazka *img ktora sa ma zobrazit * layer - vrstva na ktorej sa zobrazi obrazok */ -void -addLayer(image_t * img, - int x, int y, int px, int py, int w, int h, int player) +void addLayer(image_t *img, + int x,int y, int px,int py, + int w,int h, int player) { - layer_t *new; - layer_t *this; - int i, j; - - assert(img != NULL); - - new = malloc(sizeof(layer_t)); - new->x = x; - new->y = y; - new->w = w; - new->h = h; - new->px = px; - new->py = py; - new->layer = player; - new->image = img; - - for (i = 0; i < listLayer->count; i++) { - this = (layer_t *) listLayer->list[i]; - - if (this->layer == new->layer) { - for (j = i; j < listLayer->count; j++) { - this = (layer_t *) listLayer->list[j]; - - if (this->y + this->h > new->y + new->h) { - insList(listLayer, j, new); - return; - } - } - } - } - - addList(listLayer, new); + layer_t *new; + layer_t *this; + int i, j; + + assert( img != NULL ); + + new = malloc( sizeof(layer_t) ); + new->x = x; + new->y = y; + new->w = w; + new->h = h; + new->px = px; + new->py = py; + new->layer = player; + new->image = img; + + for( i = 0 ; i < listLayer->count ; i++ ) + { + this = (layer_t *)listLayer->list[i]; + + if( this->layer == new->layer ) + { + for( j = i ; j < listLayer->count ; j++ ) + { + this = (layer_t *)listLayer->list[j]; + + if( this->y+this->h > new->y+new->h ) + { + insList(listLayer, j, new); + return; + } + } + } + } + + addList(listLayer, new); } /* @@ -82,130 +84,138 @@ addLayer(image_t * img, * poukadane podla vrstvy a suradnice Y+H * po dokresleni sa zoznam uvolni. */ -void -drawLayer() +void drawLayer() { - layer_t *this; - int i; + layer_t *this; + int i; - for (i = 0; i < listLayer->count; i++) { - this = (layer_t *) listLayer->list[i]; + for( i = 0 ; i < listLayer->count ; i++ ) + { + this = (layer_t *)listLayer->list[i]; - drawImage(this->image, - this->x, this->y, this->px, this->py, this->w, this->h); - } + drawImage(this->image, + this->x, this->y, + this->px, this->py, + this->w, this->h); + } - //printf("listLayer->count = %d\n", listLayer->count); + //printf("listLayer->count = %d\n", listLayer->count); - destroyListItem(listLayer, free); - listLayer = newList(); + destroyListItem(listLayer, free); + listLayer = newList(); } -void -drawLayerCenter(int x, int y) +void drawLayerCenter(int x, int y) { - layer_t *this; - int screen_x, screen_y; - int i; - //int count = 0; + layer_t *this; + int screen_x, screen_y; + int i; + //int count = 0; - getCenterScreen(&screen_x, &screen_y, x, y, WINDOW_SIZE_X, WINDOW_SIZE_Y); + getCenterScreen(&screen_x, &screen_y, x, y, WINDOW_SIZE_X, WINDOW_SIZE_Y); - for (i = 0; i < listLayer->count; i++) { - this = (layer_t *) listLayer->list[i]; + for( i = 0 ; i < listLayer->count ; i++ ) + { + this = (layer_t *)listLayer->list[i]; - if (this->x + this->w < screen_x || this->x > screen_x + WINDOW_SIZE_X - || this->y + this->h < screen_y - || this->y > screen_y + WINDOW_SIZE_Y) { - continue; - } + if( this->x + this->w < screen_x || this->x > screen_x + WINDOW_SIZE_X || + this->y + this->h < screen_y || this->y > screen_y + WINDOW_SIZE_Y ) + { + continue; + } - //count++; + //count++; - drawImage(this->image, - this->x - screen_x, this->y - screen_y, - this->px, this->py, this->w, this->h); + drawImage(this->image, + this->x - screen_x, this->y - screen_y, + this->px, this->py, + this->w, this->h); - //printf("%d %d\n", this->x - screen_x, this->y - screen_y); - } + //printf("%d %d\n", this->x - screen_x, this->y - screen_y); + } - //printf("count = %d\n", count); + //printf("count = %d\n", count); - destroyListItem(listLayer, free); - listLayer = newList(); + destroyListItem(listLayer, free); + listLayer = newList(); } -void -drawLayerSplit(int local_x, int local_y, int x, int y, int w, int h) +void drawLayerSplit(int local_x, int local_y, int x, int y, int w, int h) { - layer_t *this; - int i; - //int count = 0; + layer_t *this; + int i; + //int count = 0; - for (i = 0; i < listLayer->count; i++) { - this = (layer_t *) listLayer->list[i]; + for( i = 0 ; i < listLayer->count ; i++ ) + { + this = (layer_t *)listLayer->list[i]; - if (this->x + this->w < x || this->x > x + w || - this->y + this->h < y || this->y > y + h) { - continue; - } + if( this->x + this->w < x || this->x > x + w || + this->y + this->h < y || this->y > y + h ) + { + continue; + } - //count++; + //count++; - if (local_x + (this->x - x) < local_x) { - int z; + if( local_x + (this->x - x) < local_x ) + { + int z; - z = local_x - (local_x + (this->x - x)); + z = local_x - ( local_x + (this->x - x) ); - this->x += z; - this->px += z; - this->w -= z; - } + this->x += z; + this->px += z; + this->w -= z; + } - if (local_x + (this->x - x) + this->w > local_x + w) { - this->w -= (local_x + (this->x - x) + this->w) - (local_x + w); - } + if( local_x + (this->x - x) + this->w > local_x+w ) + { + this->w -= ( local_x + (this->x - x) + this->w ) - (local_x + w); + } - if (local_y + (this->y - y) < local_y) { - int z; + if( local_y + (this->y - y) < local_y ) + { + int z; - z = local_y - (local_y + (this->y - y)); + z = local_y - ( local_y + (this->y - y) ); - this->y += z; - this->py += z; - this->h -= z; - } + this->y += z; + this->py += z; + this->h -= z; + } - if (local_y + (this->y - y) + this->h > local_y + h) { - this->h -= (local_y + (this->y - y) + this->h) - (local_y + h); - } + if( local_y + (this->y - y) + this->h > local_y+h ) + { + this->h -= ( local_y + (this->y - y) + this->h ) - (local_y + h); + } - drawImage(this->image, - local_x + (this->x - x), local_y + (this->y - y), - this->px, this->py, this->w, this->h); + drawImage(this->image, + local_x + (this->x - x), local_y + (this->y - y), + this->px, this->py, + this->w, this->h); - //printf("%d %d\n", this->x - screen_x, this->y - screen_y); - } + //printf("%d %d\n", this->x - screen_x, this->y - screen_y); + } - //printf("count = %d\n", count); + //printf("count = %d\n", count); - destroyListItem(listLayer, free); - listLayer = newList(); + destroyListItem(listLayer, free); + listLayer = newList(); } -void -flushLayer() +void flushLayer() { - destroyListItem(listLayer, free); - listLayer = newList(); + destroyListItem(listLayer, free); + listLayer = newList(); } /* * Odstrani zoznam vrtsiev z pamete. */ -void -quitLayer() +void quitLayer() { - destroyListItem(listLayer, free); - isLayerInit = FALSE; + destroyListItem(listLayer, free); + isLayerInit = FALSE; } + |