Logo Search packages:      
Sourcecode: rafkill version File versions  Download package

hull_protect.cpp

#include "allegro.h"
#include "trigtable.h"
#include "defs.h"

#include "hull.h"
#include "hull_protect.h"

#define protect_length 35
#define protect_size 9

ProtectHull::ProtectHull( int c, int level ):
HullObject( NULL, 100000, 3, 0, level, 9, false, NULL ) {
      color = c;
      angX = rnd(360);
      angY = rnd(360);

      dirX = rnd(2) * 2 - 1;
      dirY = rnd(2) * 2 - 1;
}


void ProtectHull::angular( int & a, int d ) {
      a += d*10;
      while ( a < 0 ) a += 360;
      while ( a >= 360 ) a -= 360;
}


void ProtectHull::Draw( BITMAP * work, int x, int y ) {
      angular( angX, dirX );
      angular( angY, dirY );
      int x1 = (int)( x + tcos[ angX ] * protect_length );
      int y1 = (int)( y + tsine[ angY ] * protect_length );
      circlefill( work, x1, y1, protect_size, makecol( 186, 16, 16 ) );
      circle( work, x1, y1, protect_size, makecol( 40, 40, 40 ) );
}


bool ProtectHull::Inside( int mx, int my, int ax, int ay ) {
      //if ( abs(mx-ax)>=protect_size*2 || abs(my-ay)>=protect_size*2 )
      //    return false;
      int x1 = (int)( mx + tcos[ angX ] * protect_length );
      int y1 = (int)( my + tsine[angY ] * protect_length );
      if ( dist( x1, y1, ax, ay ) < protect_size ) {
            crash = true;
            return true;
      }
      crash = false;
      return false;
}

Generated by  Doxygen 1.6.0   Back to index