From b56004caaa4e1c2b682e5f3391239321acc41b8a Mon Sep 17 00:00:00 2001 From: oroborus Date: Fri, 22 Aug 2008 16:37:04 +0000 Subject: - moznost nastavit ako sa ma screen splitnut tuxanci-svn --split-vertical alebo tuxanci-svn --split-horizontal git-svn-id: http://opensvn.csie.org/tuxanci_ng@239 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e --- src/base/arena.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++---- src/base/arena.h | 7 ++++++- src/client/game.c | 1 + src/client/layer.c | 19 +++++++++++++++++-- 4 files changed, 70 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/base/arena.c b/src/base/arena.c index 1284e95..3a72eba 100644 --- a/src/base/arena.c +++ b/src/base/arena.c @@ -18,6 +18,7 @@ #endif static arena_t *currentArena; +static int splitType; void setCurrentArena(arena_t *p) { @@ -29,6 +30,23 @@ arena_t* getCurrentArena() return currentArena; } +void initArena() +{ + splitType = SCREEN_SPLIT_VERTICAL; + + if( getParam("--split-vertical") ) + { + splitType = SCREEN_SPLIT_VERTICAL; + printf("SCREEN_SPLIT_VERTICAL\n"); + } + + if( getParam("--split-horizontal") ) + { + splitType = SCREEN_SPLIT_HORIZONTAL; + printf("SCREEN_SPLIT_HORIZONTAL\n"); + } +} + arena_t* newArena(int w, int h) { arena_t *new; @@ -191,12 +209,28 @@ static void drawSplitArenaForTux(arena_t *arena, tux_t *tux, int location_x, int { int screen_x, screen_y; - getCenterScreen(&screen_x, &screen_y, tux->x, tux->y, WINDOW_SIZE_X/2, WINDOW_SIZE_Y); - + switch( splitType ) + { + case SCREEN_SPLIT_HORIZONTAL : + getCenterScreen(&screen_x, &screen_y, tux->x, tux->y, WINDOW_SIZE_X, WINDOW_SIZE_Y/2); + break; + case SCREEN_SPLIT_VERTICAL : + getCenterScreen(&screen_x, &screen_y, tux->x, tux->y, WINDOW_SIZE_X/2, WINDOW_SIZE_Y); + break; + } + drawBackground(arena, screen_x, screen_y); drawObjects(arena, screen_x, screen_y); - drawLayerSplit(location_x, location_y, screen_x, screen_y, WINDOW_SIZE_X/2, WINDOW_SIZE_Y); + switch( splitType ) + { + case SCREEN_SPLIT_HORIZONTAL : + drawLayerSplit(location_x, location_y, screen_x, screen_y, WINDOW_SIZE_X, WINDOW_SIZE_Y/2); + break; + case SCREEN_SPLIT_VERTICAL : + drawLayerSplit(location_x, location_y, screen_x, screen_y, WINDOW_SIZE_X/2, WINDOW_SIZE_Y); + break; + } } void drawSplitArena(arena_t *arena) @@ -207,7 +241,15 @@ void drawSplitArena(arena_t *arena) if( tux != NULL ) { - drawSplitArenaForTux(arena, tux, WINDOW_SIZE_X/2, 0); + switch( splitType ) + { + case SCREEN_SPLIT_HORIZONTAL : + drawSplitArenaForTux(arena, tux, 0, WINDOW_SIZE_Y/2); + break; + case SCREEN_SPLIT_VERTICAL : + drawSplitArenaForTux(arena, tux, WINDOW_SIZE_X/2, 0); + break; + } } tux = getControlTux(TUX_CONTROL_KEYBOARD_LEFT); diff --git a/src/base/arena.h b/src/base/arena.h index 392738b..1a326c3 100644 --- a/src/base/arena.h +++ b/src/base/arena.h @@ -13,6 +13,9 @@ #define random rand #endif +#define SCREEN_SPLIT_HORIZONTAL 1 +#define SCREEN_SPLIT_VERTICAL 2 + #include "list.h" #include "space.h" @@ -24,8 +27,9 @@ typedef struct arena_struct image_t *background; #endif int w, h; + list_t *listTimer; - //list_t *listTux; + space_t *spaceShot; space_t *spaceTux; space_t *spaceItem; @@ -37,6 +41,7 @@ typedef struct arena_struct extern void setCurrentArena(arena_t *p); extern arena_t* getCurrentArena(); +extern void initArena(); extern arena_t* newArena(int w, int h); extern int conflictSpace(int x1,int y1,int w1,int h1,int x2,int y2,int w2,int h2); extern int isFreeSpace(arena_t *arena, int x, int y, int w, int h); diff --git a/src/client/game.c b/src/client/game.c index b0d2322..faf89bb 100644 --- a/src/client/game.c +++ b/src/client/game.c @@ -48,6 +48,7 @@ static void initGame() initSDL(); initFont(FONT_FILE , FONT_SIZE); initLayer(); + initArena(); initImageData(); #ifndef NO_SOUND initAudio(); diff --git a/src/client/layer.c b/src/client/layer.c index 5aa8124..770a916 100755 --- a/src/client/layer.c +++ b/src/client/layer.c @@ -158,9 +158,8 @@ void drawLayerSplit(int local_x, int local_y, int x, int y, int w, int h) if( local_x + (this->x - x) < local_x ) { - //this->x = local_x; int z; - z = ( local_x + (this->x - x) + this->w ) - local_x; + z = local_x - ( local_x + (this->x - x) ); this->x += z; @@ -173,6 +172,22 @@ void drawLayerSplit(int local_x, int local_y, int x, int y, int w, int h) this->w -= ( local_x + (this->x - x) + this->w ) - (local_x + w); } + if( local_y + (this->y - y) < local_y ) + { + int z; + + z = local_y - ( local_y + (this->y - y) ); + + 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); + } + drawImage(this->image, local_x + (this->x - x), local_y + (this->y - y), this->px, this->py, -- cgit v1.2.3