File: hull_weapon_cork.cpp

package info (click to toggle)
rafkill 1.2.2-4
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 13,268 kB
  • ctags: 5,074
  • sloc: cpp: 13,508; makefile: 64; sh: 14
file content (71 lines) | stat: -rw-r--r-- 1,628 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
66
67
68
69
70
71
#include "spaceobj.h"
#include "trigtable.h"
#include "hull_weapon.h"
#include "hull_weapon_cork.h"
#include "rgbhandle.h"
#include <deque>

#include <stdio.h>

static const int MAX_CORKS = 14;

Cork_WHull::Cork_WHull( int str ):
HullWeapon( 0, 1, str ),
ang( 0 ) {

	for ( int q = 0; q < 2; q++ )
		shade[q] = new int[ MAX_CORKS ];
	for ( int q = 0; q < MAX_CORKS; q++ )
		list.push_back( 0 );

	int r, g, b;
	float h, s, v;
	h = Util::rnd( 360 );
	s = 0.9;
	v = 1.0;
	Bitmap::hsvToRGB( h, s, v, &r, &g, &b );

	Util::blend_palette( shade[0], MAX_CORKS, Bitmap::makeColor(r,g,b), Bitmap::makeColor(0,0,0) );

	h = Util::rnd( 360 );
	Bitmap::hsvToRGB( h, s, v, &r, &g, &b );
	Util::blend_palette( shade[1], MAX_CORKS, Bitmap::makeColor(r,g,b), Bitmap::makeColor(0,0,0) );

}

Cork_WHull::~Cork_WHull() {
	for ( int q = 0; q < 2; q++ )
		delete[] shade[q];
	list.clear();
}

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

	ang = ( ang + 17 ) % 360;

	list.pop_back();
	list.push_front( ang );
	int yval = y;
	int col = 0;
	for ( deque< int >::iterator it = list.begin(); it != list.end(); it++, yval -= 2, col++) {
		/*
		circlefill( who, (int)(x+rsine[*it]*7), yval, 1, shade[0][col] );
		circlefill( who, (int)(x+rsine[360-*it]*7), yval, 1, shade[1][col] );
		*/
		const int size = 4;
		int mx = (int)(x + Rsine(*it) * size);
		int my = yval;
		who.circleFill( mx, my, 1, shade[0][col] );
		x = (int)(x + Rsine(360-*it) * size);
		who.circleFill( mx, my, 1, shade[1][col] );
	}

}

bool Cork_WHull::Collide( int mx, int my, SpaceObject * check ) {
	if ( check->HitMe( mx, my ) )
		return true;

	return false;

}