Changeset 47 for libcaca


Ignore:
Timestamp:
Dec 23, 2002, 12:39:15 AM (20 years ago)
Author:
Sam Hocevar
Message:
  • seekers and homing bombs react more quickly.
  • 16 seekers on fragbomb explosion instead of 12.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • libcaca/trunk/src/weapons.c

    r45 r47  
    44 *                 All Rights Reserved
    55 *
    6  *   $Id: weapons.c,v 1.10 2002/12/22 23:01:35 sam Exp $
     6 *   $Id: weapons.c,v 1.11 2002/12/22 23:39:15 sam Exp $
    77 *
    88 *   This program is free software; you can redistribute it and/or modify
     
    139139                wp->n[i]--;
    140140
    141                 /* Estimate our position in 2 frames */
    142                 xnew = wp->x[i] + 4 * wp->vx[i];
    143                 ynew = wp->y[i] + 4 * wp->vy[i];
     141                /* Estimate our position next frames */
     142                xnew = wp->x[i] + wp->vx[i];
     143                ynew = wp->y[i] + wp->vy[i];
    144144
    145145                xmin = xnew;
     
    170170                dy = ymin - wp->y[i];
    171171
    172                 /* Normalize and update speed */
     172                /* Normalize direction */
    173173                if( dx | dy )
    174174                {
    175                     int norm = r00t( dx * dx + dy * dy );
    176 
    177                     wp->vx[i] = (7 * wp->vx[i] + (dx * 48) / norm ) / 8;
    178                     wp->vy[i] = (7 * wp->vy[i] + (dy * 24) / norm ) / 8;
    179                 }
     175                    int norm = r00t( dx * dx + 4 * dy * dy );
     176                    dx = dx * 32 / norm;
     177                    dy = dy * 32 / norm;
     178                }
     179
     180                /* Find our new speed */
     181                dx = (dx + 3 * wp->vx[i]) / 4;
     182                dy = (dy + 3 * wp->vy[i]) / 4;
     183
     184                /* Normalize speed */
     185                if( dx | dy )
     186                {
     187                    int norm = r00t( dx * dx + 4 * dy * dy );
     188                    wp->vx[i] = dx * 32 / norm;
     189                    wp->vy[i] = dy * 32 / norm;
     190                }
     191
    180192                break;
    181193
     
    186198                    int coords[] =
    187199                    {
    188                         24,  0,   -24,  0,    0,  24,     0, -24,
    189                         24,  8,   -24,  8,   24,  -8,   -24,  -8,
    190                         16, 16,   -16, 16,   16, -16,   -16, -16
     200                        32,  0,   -32,  0,    0,  16,     0, -16,
     201                        24, 12,   -24, 12,   24, -12,   -24, -12,
     202                        28,  8,   -28,  8,   28,  -8,   -28,  -8,
     203                        16, 14,   -16, 14,   16, -14,   -16, -14
    191204                    };
    192205
    193                     for( j = 0; j < 12; j++ )
     206                    for( j = 0 ; j < sizeof(coords) / sizeof(int) ; j += 2 )
    194207                    {
    195                         add_weapon( g, g->wp, wp->x[i] + coords[2*j], wp->y[i] + coords[2*j+1], coords[2*j], coords[2*j+1], WEAPON_SEEKER );
     208                        add_weapon( g, g->wp, wp->x[i] + coords[j], wp->y[i] + coords[j+1], coords[j], coords[j+1], WEAPON_SEEKER );
    196209                    }
    197210
Note: See TracChangeset for help on using the changeset viewer.