File: hull_weapon_s_l.cpp

package info (click to toggle)
rafkill 1.2.2-3.3
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 13,268 kB
  • sloc: cpp: 13,508; makefile: 64; sh: 14
file content (65 lines) | stat: -rw-r--r-- 1,120 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "spaceobj.h"
#include "bitmap.h"
#include "trigtable.h"
#include "hull_weapon.h"
#include "hull_weapon_s_l.h"

SL_WHull::SL_WHull():
HullWeapon( 0, 1, 3 ),
r1( 0 ),
r2( 3 ){}

void SL_WHull::Draw( const Bitmap & who, int x, int y ) {

	int col1 = Bitmap::makeColor( 255, 0, 0 );
	int col2 = Bitmap::makeColor( 255, 250, 250 );

	if ( r1 > r2 ) {
		/*
		circlefill( who, x, y, r1, col1 );
		circlefill( who, x, y, r2, col2 );
		*/
		who.circleFill( x, y, r1, col1 );
		who.circleFill( x, y, r2, col2 );
	}
	else {
		/*
		circlefill( who, x, y, r2, col2 );
		circlefill( who, x, y, r1, col1 );
		*/
		who.circleFill( x, y, r2, col2 );
		who.circleFill( x, y, r1, col1 );
	}

	r2++;
	r1++;
	if ( r2 > 5 ){
		r2 = 1;
	}
	if ( r1 > 5 ){
		r1 = 1;
	}
}


bool SL_WHull::Collide( int mx, int my, SpaceObject * check ) {
	// return false;

	if ( check->HitMe( mx, my ) ){
		return true;
	}

	const int LARGE = 5;

	for ( int sang = 0; sang < 360; sang += 45 ) {

		int ax = (int)(mx + Tcos(sang)*LARGE );
		int ay = (int)(my + Tsine(sang)*LARGE );
		if ( check->HitMe( ax, ay ) )
			return true;

	}

	return false;

}