File: gun_rotate.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 (49 lines) | stat: -rw-r--r-- 1,281 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
#include "gunobj.h"
#include "gun_rotate.h"
#include "trigtable.h"
#include "ebox.h"
#include "spaceobj.h"
#include "defs.h"
#include "weapons/weapon_rotate.h"
#include "hulls/hull_weapon_rotate.h"

WeaponRotateGun::WeaponRotateGun( int z, int d, int _smp, int al ):
WeaponObject( d, "Rotate Gun", 250000, al, z, 4 ) {
	smp = _smp;

	angX = Util::rnd( 360 );
	angY = Util::rnd( 360 );
	dX = (Util::rnd( 8 ) + 10 ) * (Util::rnd(2)*2-1);
	dY = (Util::rnd( 8 ) + 10 ) * (Util::rnd(2)*2-1);
	dwX = dX;
	dwY = dY;
	maxX = 400;
	maxY = 400;

	Bitmap temp( 20, 20 );
	temp.fill( Bitmap::MaskColor );
	temp.circleFill( 10, 10, 10, Bitmap::makeColor( 255, 0, 0 ) );
	collide = new ECollide( temp );

}

WeaponRotateGun::~WeaponRotateGun() {
	delete collide;
}

void WeaponRotateGun::MakeShot(int x, int y, vector< SpaceObject * > * Ammo, const vector< SpaceObject * > * fight ) {

	shot_counter = 24;
	int dam = 40 + (strength + 1 ) * 10;

	const double speed = -6.5;

	int base = Util::rnd( 100 );
	for ( int q = 0; q < 360; q += 360 / (strength + 4) ){
		Ammo->push_back( new Rotate( x, y, 0, speed, (q+base) % 360, 55, new Rotate_WHull( dam, collide->copy() ), alignment ) );
	}
}

WeaponObject * WeaponRotateGun::copy() {
	return new WeaponRotateGun( strength, dir, smp, alignment );
}