#include "Weapon.h"

Weapon::Weapon(){
	range = 100;

	pos[0] = -0.205;
	pos[1] = 0.090;
	pos[2] = 0.075;

	origin[0] = 0;
	origin[1] = 0;
	origin[2] = 0;

	direction[0] = 1;
	direction[1] = 0;
	direction[2] = 0;

	isbeingfired = false;
}

Weapon::fire(){
	float red= 0.71;
	float green = 0.31;
	float blue = 0.35;
	float redchange = red/range;
	float greenchange = green/range;
	float bluechange = blue/range;
	dest[0] = origin[0] + direction[0];
	dest[1] = origin[1] + direction[1];
	dest[2] = origin[2] + direction[2];
	glPushMatrix();
	glLineWidth(2.0);
	for (int i = 0; i < range; i++){
		glColor3f(red, green, blue);
		glBegin(GL_LINES);
			glVertex3fv(origin);
			glVertex3fv(dest);
		glEnd();

		origin[0] = dest[0];
		origin[1] = dest[1];
		origin[2] = dest[2];

		dest[0] = origin[0] + direction[0];
		dest[1] = origin[1] + direction[1];
		dest[2] = origin[2] + direction[2];

		red = red - redchange;
		green = green - greenchange;
		blue = blue - bluechange;
	}
	
	origin[0] = 0;
	origin[1] = 0;
	origin[2] = 0;

	glPopMatrix();
}