diff options
| author | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-04-15 19:28:48 +0000 |
|---|---|---|
| committer | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-04-15 19:28:48 +0000 |
| commit | a8bec57e7a9be7b1fa36ef8be618db4e46cbd599 (patch) | |
| tree | 1af5e651f4ff628f99393109e3352dbd7b1f39f4 /src/shot.c | |
| parent | c8223ce77a4dbf57be272d10c4e1d31f69bd516e (diff) | |
- oprava chyby #0007 #0006 #0005
- nova zbran bombball
- client dostava svoju vlastnu poziciu od servera kazdych 5000 ms
git-svn-id: http://opensvn.csie.org/tuxanci_ng@45 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/shot.c')
| -rw-r--r-- | src/shot.c | 103 |
1 files changed, 97 insertions, 6 deletions
@@ -6,6 +6,8 @@ #include "main.h" #include "shot.h" #include "gun.h" +#include "wall.h" +#include "pipe.h" #include "net_multiplayer.h" #include "proto.h" @@ -24,6 +26,7 @@ static SDL_Surface *g_shot_simple; static SDL_Surface *g_shot_lasserX; static SDL_Surface *g_shot_lasserY; +static SDL_Surface *g_shot_bombball; #endif @@ -45,6 +48,7 @@ void initShot() g_shot_simple = addImageData("shot.png", IMAGE_ALPHA, "shot", IMAGE_GROUP_BASE); g_shot_lasserX = addImageData("lasserX.png", IMAGE_NO_ALPHA, "lasserX", IMAGE_GROUP_BASE); g_shot_lasserY = addImageData("lasserY.png", IMAGE_NO_ALPHA, "lasserY", IMAGE_GROUP_BASE); + g_shot_bombball = addImageData("bombball.png", IMAGE_ALPHA, "bombball", IMAGE_GROUP_BASE); #endif @@ -103,6 +107,15 @@ shot_t* newShot(int x,int y, int px, int py, int gun, tux_t *author) } break; + case GUN_BOMBBALL : + new->w = GUN_BOMBBALL_WIDTH; + new->h = GUN_BOMBBALL_HEIGHT; + +#ifndef PUBLIC_SERVER + new->img = g_shot_bombball; +#endif + break; + default : assert( ! "Premenna weapon ma zlu hodnotu !" ); break; @@ -111,6 +124,28 @@ shot_t* newShot(int x,int y, int px, int py, int gun, tux_t *author) return new; } +shot_t* getShotID(list_t *listShot, int id) +{ + shot_t *thisShot; + int i; + + assert( listShot != NULL ); + + for( i = 0 ; i < listShot->count ; i++ ) + { + thisShot = (shot_t *)listShot->list[i]; + assert( thisShot != NULL ); + + if( thisShot->id == id ) + { + return thisShot; + } + } + + return NULL; +} + + #ifndef PUBLIC_SERVER void drawShot(shot_t *p) @@ -158,6 +193,51 @@ int isConflictWithListShot(list_t *listShot, int x, int y, int w, int h) return 0; } +static int myAbs(int n) +{ + return ( n > 0 ? n : -n ); +} + + +static int getRandomCourse(int x, int y) +{ + int ret; + + do{ + switch( random() % 3 ) + { + case 0 : + ret = y; + break; + case 1 : + ret = -y; + break; + case 2 : + ret = 0; + break; + } + }while( ret == x ); + + return ret; +} + +void boundBombBall(shot_t *shot) +{ + if( shot->gun != GUN_BOMBBALL ) + { + return; + } + + shot->px = getRandomCourse(shot->px, +10); + shot->py = getRandomCourse(shot->py, +10); + shot->isCanKillAuthor = 1; + + if( getNetTypeGame() == NET_GAME_TYPE_SERVER ) + { + proto_send_shot_server(PROTO_SEND_ALL, NULL, shot); + } +} + void eventMoveListShot(list_t *listShot) { shot_t *thisShot; @@ -172,7 +252,23 @@ void eventMoveListShot(list_t *listShot) thisShot->x += thisShot->px; thisShot->y += thisShot->py; - +/* + if( thisShot->gun == GUN_BOMBBALL && ( + isConflictWithListWall(getCurrentArena()->listWall, thisShot->x, thisShot->y, thisShot->w, thisShot->h) || + isConflictWithListPipe(getCurrentArena()->listPipe, thisShot->x, thisShot->y, thisShot->w, thisShot->h) ) ) + { + if( getNetTypeGame() != NET_GAME_TYPE_CLIENT ) + { + boundBombBall(thisShot); + } + else + { + delListItem(listShot, i, destroyShot); + i--; + continue; + } + } +*/ if( thisShot->x+thisShot->w < 0 || thisShot->x > WINDOW_SIZE_X || thisShot->y+thisShot->h < 0 || thisShot->y > WINDOW_SIZE_Y ) { @@ -183,11 +279,6 @@ void eventMoveListShot(list_t *listShot) } } -static int myAbs(int n) -{ - return ( n > 0 ? n : -n ); -} - static int getSppedShot(shot_t *shot) { return ( myAbs(shot->px) > myAbs(shot->py) ? myAbs(shot->px) : myAbs(shot->py) ); |