diff options
| author | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-06-28 16:38:35 +0000 |
|---|---|---|
| committer | oroborus <oroborus@0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e> | 2008-06-28 16:38:35 +0000 |
| commit | 2d776fcd61be168e1ff0ff2e4a5e71835e7cea19 (patch) | |
| tree | 7cf274897bf540d5332d446f583ffd066e4e2e1d /src/gun.c | |
| parent | b877ae23ac5d380ab3aa48d7724045cf4883b186 (diff) | |
- prekopanie adresarovej struktury, prva cast
git-svn-id: http://opensvn.csie.org/tuxanci_ng@77 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e
Diffstat (limited to 'src/gun.c')
| -rw-r--r-- | src/gun.c | 350 |
1 files changed, 0 insertions, 350 deletions
diff --git a/src/gun.c b/src/gun.c deleted file mode 100644 index dceec63..0000000 --- a/src/gun.c +++ /dev/null @@ -1,350 +0,0 @@ -// -#include <stdio.h> -#include <stdlib.h> -#include <assert.h> - -#include "main.h" -#include "arena.h" -#include "tux.h" -#include "shot.h" -#include "myTimer.h" -#include "item.h" -#include "gun.h" -#include "proto.h" -#include "net_multiplayer.h" - -#ifndef PUBLIC_SERVER -#include "sound.h" -#include "fake_audio.h" -#include "screen_world.h" -#include "interface.h" -#include "term.h" -#endif - -#ifdef PUBLIC_SERVER -#include "publicServer.h" -#endif - -static void modificiationCopuse(int courser, int right_x, int right_y, int *dest_x, int *dest_y) -{ - assert( dest_x != NULL ); - assert( dest_y != NULL ); - - switch( courser ) - { - case TUX_UP : - *dest_x = right_y; - *dest_y = -right_x; - break; - case TUX_RIGHT : - *dest_x = right_x; - *dest_y = right_y; - break; - case TUX_LEFT : - *dest_x = -right_x; - *dest_y = right_y; - break; - case TUX_DOWN : - *dest_x = right_y; - *dest_y = right_x; - break; - default : - assert( ! "V premennej courser je zly smer !" ); - break; - } -} - -static void addShotTrivial(tux_t *tux, int x, int y, int px, int py, int gun) -{ - int dest_x = 0, dest_y = 0; - int dest_px = 0, dest_py = 0; - shot_t *shot; - - modificiationCopuse(tux->position, px, py, &dest_px, &dest_py); - modificiationCopuse(tux->position, x, y, &dest_x, &dest_y); - - if( gun == GUN_LASSER ) - { - switch( tux->position ) - { - case TUX_UP : - dest_y -= GUN_LASSER_HORIZONTAL; - break; - case TUX_RIGHT : - break; - case TUX_LEFT : - dest_x -= GUN_LASSER_HORIZONTAL; - break; - case TUX_DOWN : - break; - } - } - - shot = newShot(tux->x + dest_x, tux->y + dest_y, dest_px, dest_py, gun, tux->id); - -/* - if( isFreeSpace( getCurrentArena(), shot->x, shot->y, shot->w, shot->h ) == 0 ) - { - destroyShot(shot); - return; - } -*/ - //addList( getCurrentArena()->listShot, shot ); - addObjectToSpace(getCurrentArena()->spaceShot, shot); - - if( getNetTypeGame() == NET_GAME_TYPE_SERVER ) - { - client_t *thisClient; - - thisClient = getClientFromTux(tux); - - if( thisClient != NULL ) - { - proto_send_shot_server(PROTO_SEND_ONE, thisClient, shot); - } - - proto_send_shot_server(PROTO_SEND_ALL_SEES_TUX, thisClient, shot); - } - -} - -static void addShot(tux_t *tux,int x, int y, int px, int py) -{ - int gun; - - if( getNetTypeGame() == NET_GAME_TYPE_CLIENT ) - { - return; - } - - if( tux->gun == GUN_BOMBBALL ) - { - gun = GUN_BOMBBALL; - } - else if( tux->gun == GUN_LASSER ) - { - gun = GUN_LASSER; - } - else - { - gun = GUN_SIMPLE; - } - - if( tux->bonus == BONUS_4X ) - { - int zal; - int i; - - zal = tux->position; - - for( i = 0 ; i < 4 ; i++ ) - { - switch( i ) - { - case 0 : tux->position = TUX_UP; break; - case 1 : tux->position = TUX_RIGHT; break; - case 2 : tux->position = TUX_LEFT; break; - case 3 : tux->position = TUX_DOWN; break; - } - - addShotTrivial(tux, x, y, px, py, gun); - } - - tux->position = zal; - } - else - { - addShotTrivial(tux, x, y, px, py, gun); - } -} - -static void shotInGunSimpe(tux_t *tux) -{ - addShot(tux, 0, 0, +5, 0); -} - -static void shotInGunDualSimpe(tux_t *tux) -{ - addShot(tux, 0, -10, +6, 0); - addShot(tux, 0, +10, +6, 0); -} - -static void shotInGunScatter(tux_t *tux) -{ - int i; - - for( i = -2 ; i <= +2 ; i++ ) - { - addShot(tux, 0, 0, +8, i); - } -} - -static void timer_addShotTimer(void *p) -{ - tux_t *tux; - int id; - int gun; - - id = * ((int *)p); - free(p); - - tux = getObjectFromSpaceWithID(getCurrentArena()->spaceTux, id); - - if( tux == NULL )return; - - if( tux->status != TUX_STATUS_ALIVE )return; - - gun = tux->gun; - tux->gun = GUN_SIMPLE; - addShot(tux, 0, 0, +6, 0); - tux->gun = gun; -} - -static void shotInGunTommy(tux_t *tux) -{ - int i; - - for( i = 0 ; i < 10 ; i++ ) - { - addTaskToTimer(getCurrentArena()->listTimer, TIMER_ONE, timer_addShotTimer, newInt(tux->id), i * 100 ); - } -} - -static void timer_addLaserTimer(void *p) -{ - tux_t *tux; - int id; - int gun; - - id = * ((int *)p); - free(p); - - tux = getObjectFromSpaceWithID(getCurrentArena()->spaceTux, id); - - if( tux == NULL )return; - - if( tux->status != TUX_STATUS_ALIVE )return; - - gun = tux->gun; - tux->gun = GUN_LASSER; - - addShot(tux, 0, 0, +10, 0); - - tux->gun = gun; -} - -static void shotInGunLasser(tux_t *tux) -{ - int i; - - for( i = 0 ; i < 50 ; i++ ) - { - addTaskToTimer(getCurrentArena()->listTimer, TIMER_ONE, timer_addLaserTimer, newInt(tux->id), i * 10 ); - } -} - -static void putInGunMine(tux_t *tux) -{ - int x, y; - arena_t *arena; - - x = tux->x; - y = tux->y; - - switch( tux->position ) - { - case TUX_UP : - y += TUX_HEIGHT; - break; - case TUX_RIGHT : - x -= TUX_WIDTH; - break; - case TUX_LEFT : - x += TUX_WIDTH; - break; - case TUX_DOWN : - y -= TUX_HEIGHT; - break; - } - - arena = getCurrentArena(); - - if( isFreeSpace(getCurrentArena(), x, y, ITEM_MINE_WIDTH, ITEM_MINE_HEIGHT) ) - { - item_t *item; - -#ifndef PUBLIC_SERVER - char msg[STR_SIZE]; - playSound("put_mine", SOUND_GROUP_BASE); - sprintf(msg, "tux with id %d pu mine\n", tux->id); - appendTextInTerm(msg); -#endif - - tux->shot[tux->gun]--; - - if( getNetTypeGame() != NET_GAME_TYPE_CLIENT ) - { - item = newItem(x, y, ITEM_MINE, tux->id); - - if( getNetTypeGame() == NET_GAME_TYPE_SERVER ) - { - proto_send_additem_server(PROTO_SEND_ALL, NULL, item); - } - - addObjectToSpace(arena->spaceItem, item ); - } - } -} - -static void shotInGunBombball(tux_t *tux) -{ - addShot(tux, 0, 0, +10, 0); -} - -void shotInGun(tux_t *tux) -{ - if( tux->bonus != BONUS_SHOT && tux->gun != GUN_MINE ) - { - tux->shot[tux->gun]--; - } - - switch( tux->gun ) - { - case GUN_SIMPLE : -#ifndef PUBLIC_SERVER - playSound("gun_revolver", SOUND_GROUP_BASE); -#endif - shotInGunSimpe(tux); - break; - case GUN_DUAL_SIMPLE : -#ifndef PUBLIC_SERVER - playSound("gun_revolver", SOUND_GROUP_BASE); -#endif - shotInGunDualSimpe(tux); - break; - case GUN_SCATTER : -#ifndef PUBLIC_SERVER - playSound("gun_scatter", SOUND_GROUP_BASE); -#endif - shotInGunScatter(tux); - break; - case GUN_TOMMY : -#ifndef PUBLIC_SERVER - playSound("gun_tommy", SOUND_GROUP_BASE); -#endif - shotInGunTommy(tux); - break; - case GUN_LASSER : -#ifndef PUBLIC_SERVER - playSound("gun_lasser", SOUND_GROUP_BASE); -#endif - shotInGunLasser(tux); - break; - case GUN_BOMBBALL : - shotInGunBombball(tux); - break; - case GUN_MINE : - putInGunMine(tux); - break; - } -} |