Changeset 24
- Timestamp:
- Dec 15, 2002, 6:16:45 PM (20 years ago)
- Location:
- ttyvaders/trunk
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
ttyvaders/trunk/doc/shapes.txt
r22 r24 26 26 _o|o_ 27 27 T|T 28 29 _ 30 ,(|). / \ 31 /,-'-.\ ,(_X_). 28 32 29 33 Bonus … … 62 66 | \ / | 63 67 68 ___ _, ._ ,^. _, ._ 69 . o |___> / | | \ | | ,-' / \ `-. 70 / / \ \ |_| \,-' `-./ 71 `' `' 72 ___ ,. ,. _ 73 <___| \ \ / / | | /`-. ,-'\ 74 \_| |_/ | | `-._\ /_,-' 75 `v' ` ' 76 77 | | | |||| |/\| 78 || || || |||||| ||/\|| 79 | | | | | | | 64 80 65 81 :%%: … … 67 83 __ __ __ ____ :%%: :%##%: :%####%: 68 84 ' ` -' `- ,-' `-. ,-' `-. ,-' `-. ,-' `-. ,-' `-. 85 86 ,--. 87 ( ) 88 `--' 89 o O 90 o ° 91 . ° 92 . 93 94 ,--. 95 ( ) 96 |||| 97 |||| 98 || 99 | 100 69 101 70 102 Explosions -
ttyvaders/trunk/src/aliens.c
r20 r24 82 82 { 83 83 case ALIEN_POOLP: 84 al->life[i] = 2;84 al->life[i] = 3; 85 85 break; 86 86 case ALIEN_BOOL: 87 al->life[i] = 2;87 al->life[i] = 3; 88 88 break; 89 89 case ALIEN_BRAH: 90 al->life[i] = 2;90 al->life[i] = 3; 91 91 break; 92 92 case ALIEN_NONE: -
ttyvaders/trunk/src/collide.c
r20 r24 18 18 break; 19 19 case WEAPON_SEEKER: 20 case WEAPON_BOMB: 20 21 if( x <= t->left[y] 21 22 || x >= t->right[y] ) 23 { 24 int damage = wp->type[i] == WEAPON_SEEKER ? 1 : 2; 25 26 add_explosion( g, ex, x, y, 0, 1, wp->type[i] == WEAPON_SEEKER ? EXPLOSION_SMALL : EXPLOSION_MEDIUM ); 27 28 if( x <= t->left[y] ) 29 { 30 t->right[y-2] -= damage - 1; 31 t->left[y-1] -= damage; 32 t->left[y] -= damage + 1; 33 t->left[y+1] -= damage; 34 t->right[y+2] -= damage - 1; 35 } 36 else 37 { 38 t->right[y-2] += damage - 1; 39 t->right[y-1] += damage; 40 t->right[y] += damage + 1; 41 t->right[y+1] += damage; 42 t->right[y+2] += damage - 1; 43 } 44 45 wp->type[i] = WEAPON_NONE; 46 } 47 break; 48 case WEAPON_LASER: 49 if( x <= t->left[y+1] 50 || x >= t->right[y+1] ) 51 { 52 add_explosion( g, ex, x, y+1, 0, 1, EXPLOSION_SMALL ); 53 54 if( x <= t->left[y+1] ) 55 { 56 t->left[y]--; 57 t->left[y+1]-=2; 58 t->left[y+2]--; 59 } 60 else 61 { 62 t->right[y]++; 63 t->right[y+1]+=2; 64 t->right[y+2]++; 65 } 66 67 wp->type[i] = WEAPON_NONE; 68 } 69 else if( x <= t->left[y] 70 || x >= t->right[y] ) 22 71 { 23 72 add_explosion( g, ex, x, y, 0, 1, EXPLOSION_SMALL ); … … 39 88 } 40 89 break; 41 case WEAPON_LASER:42 if( x <= t->left[y+1]43 || x >= t->right[y+1] )44 {45 add_explosion( g, ex, x, y+1, 0, 1, EXPLOSION_SMALL );46 47 if( x <= t->left[y+1] )48 {49 t->left[y]--;50 t->left[y+1]-=2;51 t->left[y+2]--;52 }53 else54 {55 t->right[y]++;56 t->right[y+1]+=2;57 t->right[y+2]++;58 }59 60 wp->type[i] = WEAPON_NONE;61 }62 else if( x <= t->left[y]63 || x >= t->right[y] )64 {65 add_explosion( g, ex, x, y, 0, 1, EXPLOSION_SMALL );66 67 if( x <= t->left[y] )68 {69 t->left[y-1]--;70 t->left[y]-=2;71 t->left[y+1]--;72 }73 else74 {75 t->right[y-1]++;76 t->right[y]+=2;77 t->right[y+1]++;78 }79 80 wp->type[i] = WEAPON_NONE;81 }82 break;83 90 case WEAPON_NUKE: 84 /* The nuke does not break the tunnel */ 91 case WEAPON_BEAM: 92 /* The nuke and the laser do not break the tunnel */ 85 93 break; 86 94 } … … 127 135 } 128 136 break; 137 case WEAPON_BEAM: 138 r = (29 - wp->n[i]) * (29 - wp->n[i]) / 8; 139 140 for( j = 0; j < ALIENS; j++ ) 141 { 142 if( al->type[j] == ALIEN_NONE ) 143 { 144 continue; 145 } 146 147 if( x >= al->x[j] && x <= al->x[j] + 4 148 && y >= al->y[j] + 2 && y-5-r <= al->y[j] ) 149 { 150 al->life[j] -= 4; 151 if( al->life[j] <= 0 ) 152 { 153 al->type[j] = ALIEN_NONE; 154 add_explosion( g, ex, al->x[j], al->y[j], 0, 0, EXPLOSION_MEDIUM ); 155 add_bonus( g, g->bo, al->x[j], al->y[j], GET_RAND(0,5) ? BONUS_GREEN : BONUS_LIFE ); 156 } 157 } 158 } 159 break; 160 129 161 case WEAPON_LASER: 130 162 for( j = 0; j < ALIENS; j++ ) … … 142 174 { 143 175 al->type[j] = ALIEN_NONE; 144 add_explosion( g, ex, x, y, 0, 0, EXPLOSION_MEDIUM );145 add_bonus( g, g->bo, x, y, GET_RAND(0,5) ? BONUS_GREEN : BONUS_LIFE );176 add_explosion( g, ex, al->x[j], al->y[j], 0, 0, EXPLOSION_MEDIUM ); 177 add_bonus( g, g->bo, al->x[j], al->y[j], GET_RAND(0,5) ? BONUS_GREEN : BONUS_LIFE ); 146 178 } 147 179 ok = 1; … … 154 186 { 155 187 al->type[j] = ALIEN_NONE; 156 add_explosion( g, ex, x, y+1, 0, 0, EXPLOSION_MEDIUM );157 add_bonus( g, g->bo, x, y+1, GET_RAND(0,5) ? BONUS_GREEN : BONUS_LIFE );188 add_explosion( g, ex, al->x[j], al->y[j]+1, 0, 0, EXPLOSION_MEDIUM ); 189 add_bonus( g, g->bo, al->x[j], al->y[j]+1, GET_RAND(0,5) ? BONUS_GREEN : BONUS_LIFE ); 158 190 } 159 191 ok = 1; … … 163 195 if( ok ) 164 196 { 197 add_explosion( g, ex, x, y+1, 0, 0, EXPLOSION_SMALL ); 165 198 wp->type[i] = WEAPON_NONE; 166 199 } … … 168 201 169 202 case WEAPON_SEEKER: 203 case WEAPON_BOMB: 170 204 for( j = 0; j < ALIENS; j++ ) 171 205 { … … 182 216 { 183 217 al->type[j] = ALIEN_NONE; 184 add_explosion( g, ex, x, y, 0, 0, EXPLOSION_MEDIUM );185 add_bonus( g, g->bo, x, y, GET_RAND(0,5) ? BONUS_GREEN : BONUS_LIFE );218 add_explosion( g, ex, al->x[j], al->y[j], 0, 0, EXPLOSION_MEDIUM ); 219 add_bonus( g, g->bo, al->x[j], al->y[j], GET_RAND(0,5) ? BONUS_GREEN : BONUS_LIFE ); 186 220 } 187 221 ok = 1; … … 191 225 if( ok ) 192 226 { 227 add_explosion( g, ex, x, y+1, 0, 0, wp->type[i] == WEAPON_SEEKER ? EXPLOSION_SMALL : EXPLOSION_MEDIUM ); 193 228 wp->type[i] = WEAPON_NONE; 194 229 } -
ttyvaders/trunk/src/common.h
r22 r24 1 1 2 2 #define STARS 50 3 #define WEAPONS 503 #define WEAPONS 100 4 4 #define BONUS 30 5 5 #define ALIENS 30 6 #define EXPLOSIONS 206 #define EXPLOSIONS 100 7 7 8 8 #ifdef USE_SLANG … … 53 53 typedef struct 54 54 { 55 enum { WEAPON_NONE, WEAPON_LASER, WEAPON_SEEKER, WEAPON_NUKE, WEAPON_BEAM } type[WEAPONS];55 enum { WEAPON_NONE, WEAPON_LASER, WEAPON_SEEKER, WEAPON_NUKE, WEAPON_BEAM, WEAPON_LIGHTNING, WEAPON_BOMB } type[WEAPONS]; 56 56 int x[WEAPONS]; 57 57 int y[WEAPONS]; -
ttyvaders/trunk/src/main.c
r22 r24 128 128 { 129 129 g->p->weapon = 4; 130 add_weapon( g, g->wp, g->p->x << 4, g->p->y << 4, -24, -16, WEAPON_SEEKER ); 131 add_weapon( g, g->wp, (g->p->x + 5) << 4, g->p->y << 4, 24, -16, WEAPON_SEEKER ); 130 add_weapon( g, g->wp, (g->p->x + 2) << 4, g->p->y << 4, 0, -16, WEAPON_BOMB ); 132 131 } 133 132 case ' ': … … 137 136 add_weapon( g, g->wp, g->p->x << 4, g->p->y << 4, 0, -16, WEAPON_LASER ); 138 137 add_weapon( g, g->wp, (g->p->x + 5) << 4, g->p->y << 4, 0, -16, WEAPON_LASER ); 138 /* Extra shtuph */ 139 add_weapon( g, g->wp, g->p->x << 4, g->p->y << 4, -24, -16, WEAPON_SEEKER ); 140 add_weapon( g, g->wp, (g->p->x + 5) << 4, g->p->y << 4, 24, -16, WEAPON_SEEKER ); 141 /* More shtuph */ 142 add_weapon( g, g->wp, (g->p->x + 1) << 4, (g->p->y - 1) << 4, 0, -16, WEAPON_LASER ); 143 add_weapon( g, g->wp, (g->p->x + 4) << 4, (g->p->y - 1) << 4, 0, -16, WEAPON_LASER ); 144 /* Even more shtuph */ 145 add_weapon( g, g->wp, (g->p->x + 2) << 4, (g->p->y - 1) << 4, 0, -16, WEAPON_LASER ); 146 add_weapon( g, g->wp, (g->p->x + 3) << 4, (g->p->y - 1) << 4, 0, -16, WEAPON_LASER ); 147 /* Extra shtuph */ 148 add_weapon( g, g->wp, g->p->x << 4, g->p->y << 4, -32, 0, WEAPON_SEEKER ); 149 add_weapon( g, g->wp, (g->p->x + 5) << 4, g->p->y << 4, 32, 0, WEAPON_SEEKER ); 139 150 } 140 151 break; … … 144 155 usleep(40000); 145 156 146 if( GET_RAND(0,10) == 0)157 if( !poz || skip ) 147 158 { 148 int list[3] = { ALIEN_POOLP, ALIEN_BOOL, ALIEN_BRAH }; 149 150 add_alien( g, g->al, 0, rand() % g->h / 2, list[GET_RAND(0,3)] ); 159 skip = 0; 160 161 /* XXX: to be removed */ 162 if( GET_RAND(0,10) == 0 ) 163 { 164 int list[3] = { ALIEN_POOLP, ALIEN_BOOL, ALIEN_BRAH }; 165 166 add_alien( g, g->al, 0, rand() % g->h / 2, list[GET_RAND(0,3)] ); 167 } 168 169 /* Update game rules */ 170 if( g->t->right[1] - g->t->left[1] == g->t->w ) 171 { 172 g->t->w = 85 - g->t->w; 173 } 174 175 /* Scroll and update positions */ 176 collide_player_tunnel( g, g->p, g->t, g->ex ); 177 update_player( g, g->p ); 178 collide_player_tunnel( g, g->p, g->t, g->ex ); 179 180 update_starfield( g, g->sf ); 181 update_bonus( g, g->bo ); 182 update_aliens( g, g->al ); 183 184 collide_weapons_tunnel( g, g->wp, g->t, g->ex ); 185 collide_weapons_aliens( g, g->wp, g->al, g->ex ); 186 update_weapons( g, g->wp ); 187 collide_weapons_tunnel( g, g->wp, g->t, g->ex ); 188 collide_weapons_aliens( g, g->wp, g->al, g->ex ); 189 190 update_explosions( g, g->ex ); 191 /*if(purcompteur%2)*/ update_tunnel( g, g->t ); 151 192 } 152 153 if( poz )154 {155 if( skip )156 {157 skip = 0;158 }159 else160 {161 continue;162 }163 }164 165 /* Update game rules */166 if( g->t->right[1] - g->t->left[1] == g->t->w )167 {168 g->t->w = 85 - g->t->w;169 }170 171 /* Scroll and update positions */172 collide_player_tunnel( g, g->p, g->t, g->ex );173 update_player( g, g->p );174 collide_player_tunnel( g, g->p, g->t, g->ex );175 176 update_starfield( g, g->sf );177 update_bonus( g, g->bo );178 update_aliens( g, g->al );179 180 collide_weapons_tunnel( g, g->wp, g->t, g->ex );181 collide_weapons_aliens( g, g->wp, g->al, g->ex );182 update_weapons( g, g->wp );183 collide_weapons_tunnel( g, g->wp, g->t, g->ex );184 collide_weapons_aliens( g, g->wp, g->al, g->ex );185 186 update_explosions( g, g->ex );187 /*if(purcompteur%2)*/ update_tunnel( g, g->t );188 193 189 194 /* Clear screen */ … … 196 201 draw_aliens( g, g->al ); 197 202 draw_player( g, g->p ); 203 draw_explosions( g, g->ex ); 198 204 draw_weapons( g, g->wp ); 199 draw_explosions( g, g->ex );200 205 201 206 /* Refresh */ -
ttyvaders/trunk/src/weapons.c
r22 r24 5 5 #include "common.h" 6 6 7 static void draw_bomb( int x, int y, int vx, int vy ); 7 8 static void draw_nuke( int x, int y, int frame ); 8 9 static void draw_beam( int x, int y, int frame ); … … 45 46 gfx_putchar( '@' ); 46 47 break; 48 case WEAPON_BOMB: 49 gfx_color( GRAY ); 50 gfx_goto( (wp->x[i] - wp->vx[i]) >> 4, (wp->y[i] - wp->vy[i]) >> 4 ); 51 gfx_putchar( '.' ); 52 gfx_goto( (wp->x3[i] - wp->vx[i]) >> 4, (wp->y3[i] - wp->vy[i]) >> 4 ); 53 gfx_putchar( '.' ); 54 gfx_goto( (wp->x2[i] - wp->vx[i]) >> 4, (wp->y2[i] - wp->vy[i]) >> 4 ); 55 gfx_putchar( '.' ); 56 gfx_goto( wp->x3[i] >> 4, wp->y3[i] >> 4 ); 57 gfx_putchar( '.' ); 58 gfx_goto( wp->x2[i] >> 4, wp->y2[i] >> 4 ); 59 gfx_putchar( '.' ); 60 draw_bomb( wp->x[i] >> 4, wp->y[i] >> 4, wp->vx[i], wp->vy[i] ); 61 break; 47 62 case WEAPON_BEAM: 48 63 draw_beam( wp->x[i] >> 4, wp->y[i] >> 4, wp->n[i] ); … … 73 88 } 74 89 break; 90 case WEAPON_BOMB: 75 91 case WEAPON_SEEKER: 76 92 /* Update tail */ … … 176 192 break; 177 193 case WEAPON_SEEKER: 194 case WEAPON_BOMB: 178 195 wp->x2[i] = x; 179 196 wp->y2[i] = y; … … 192 209 } 193 210 break; 211 } 212 } 213 } 214 215 static void draw_bomb( int x, int y, int vx, int vy ) 216 { 217 vy *= 2; 218 gfx_color( CYAN ); 219 220 if( vx > vy ) 221 { 222 if( vx > -vy ) /* right quarter */ 223 { 224 if( vy > vx/4 ) 225 { 226 /* -1pi/6 */ 227 gfx_goto( x-4, y-1 ); 228 gfx_putstr( "/`-." ); 229 gfx_goto( x-4, y ); 230 gfx_putstr( "`-._\\" ); 231 gfx_goto( x, y+1 ); 232 gfx_putchar( '`' ); 233 } 234 else if( vy < -vx/4 ) 235 { 236 /* 1pi/6 */ 237 gfx_goto( x-1, y-1 ); 238 gfx_putstr( "_," ); 239 gfx_goto( x-4, y ); 240 gfx_putstr( ",-' /" ); 241 gfx_goto( x-4, y+1 ); 242 gfx_putstr( "\\,-'" ); 243 } 244 else 245 { 246 /* 0pi/6 */ 247 gfx_goto( x-4, y-1 ); 248 gfx_putstr( "____" ); 249 gfx_goto( x-5, y ); 250 gfx_putstr( "|____>" ); 251 } 252 } 253 else /* top quarter */ 254 { 255 if( vx > -vy/4 ) 256 { 257 /* 2pi/6 */ 258 gfx_goto( x-1, y-1 ); 259 gfx_putstr( "_," ); 260 gfx_goto( x-2, y ); 261 gfx_putstr( "/ |" ); 262 gfx_goto( x-3, y+1 ); 263 gfx_putstr( "/ /" ); 264 gfx_goto( x-3, y+2 ); 265 gfx_putstr( "`'" ); 266 } 267 else if( vx < vy/4 ) 268 { 269 /* 4pi/6 */ 270 gfx_goto( x, y-1 ); 271 gfx_putstr( "._" ); 272 gfx_goto( x, y ); 273 gfx_putstr( "| \\" ); 274 gfx_goto( x+1, y+1 ); 275 gfx_putstr( "\\ \\" ); 276 gfx_goto( x+2, y+2 ); 277 gfx_putstr( "`'" ); 278 } 279 else 280 { 281 /* 3pi/6 */ 282 gfx_goto( x-1, y ); 283 gfx_putstr( ",^." ); 284 gfx_goto( x-1, y+1 ); 285 gfx_putstr( "| |" ); 286 gfx_goto( x-1, y+2 ); 287 gfx_putstr( "|_|" ); 288 } 289 } 290 } 291 else 292 { 293 if( vx > -vy ) /* bottom quarter */ 294 { 295 if( vx > vy/4 ) 296 { 297 /* -2pi/6 */ 298 gfx_goto( x-2, y-2 ); 299 gfx_putstr( ",." ); 300 gfx_goto( x-2, y-1 ); 301 gfx_putstr( "\\ \\" ); 302 gfx_goto( x-1, y ); 303 gfx_putstr( "\\_|" ); 304 } 305 else if( vx < -vy/4 ) 306 { 307 /* -4pi/6 */ 308 gfx_goto( x+1, y-2 ); 309 gfx_putstr( ",." ); 310 gfx_goto( x, y-1 ); 311 gfx_putstr( "/ /" ); 312 gfx_goto( x-1, y ); 313 gfx_putstr( "|_/" ); 314 } 315 else 316 { 317 /* -3pi/6 */ 318 gfx_goto( x, y-3 ); 319 gfx_putchar( '_' ); 320 gfx_goto( x-1, y-2 ); 321 gfx_putstr( "| |" ); 322 gfx_goto( x-1, y-1 ); 323 gfx_putstr( "| |" ); 324 gfx_goto( x-1, y ); 325 gfx_putstr( "`v'" ); 326 } 327 } 328 else /* left quarter */ 329 { 330 if( vy > -vx/4 ) 331 { 332 /* -5pi/6 */ 333 gfx_goto( x+1, y-1 ); 334 gfx_putstr( ",-'\\" ); 335 gfx_goto( x, y ); 336 gfx_putstr( "/_,-'" ); 337 gfx_goto( x, y+1 ); 338 gfx_putchar( '\'' ); 339 } 340 else if( vy < vx/4 ) 341 { 342 /* 5pi/6 */ 343 gfx_goto( x, y-1 ); 344 gfx_putstr( "._" ); 345 gfx_goto( x, y ); 346 gfx_putstr( "\\ `-." ); 347 gfx_goto( x+1, y+1 ); 348 gfx_putstr( "`-./" ); 349 } 350 else 351 { 352 /* 6pi/6 */ 353 gfx_goto( x+1, y-1 ); 354 gfx_putstr( "____" ); 355 gfx_goto( x, y ); 356 gfx_putstr( "<____|" ); 357 } 194 358 } 195 359 }
Note: See TracChangeset
for help on using the changeset viewer.