#include "hostAPI.txt"

#include "global.txt"

var count;
var deflect;
var deflect2;
var i;
var j;

var type;

var bx;
var by;
var px;
var py;

func update() {
	bx = htGetBossX();
	by = htGetBossY();
	
	px = htGetPlayerX();
	py = htGetPlayerY();
	
	++j;
	if(j % 20 == 0) 
		type = randomFloat(-2, 2);
	
	deflect += type;
	deflect2 -= type;
	if(count % 2 == 0) {
		for(i=0; i<6; ++i) {
			htInsertBulletVec(2, 0, bx, by, 8, deflect+i*60);
			htSetBulletAccelerationEx(0.15, 0, 30);
			htSetBulletDeflectionEx(1, cos(count), 0, 30);
		}
		for(i=0; i<4; ++i) {
			htInsertBulletVec(2, 3, bx, by, 8, deflect2+i*90);
			htSetBulletAccelerationEx(0.15, 0, 30);
			htSetBulletDeflectionEx(-1, sin(count), 0, 30);
		}
	}

		
	++count;
}

func init() {
	count = 0;
	deflect = 0;
	deflect2 = 0;
	i = 0;
	j = 0;
	type = 0;
	
	htMoveBossTo(400, 100, 30);
	htEnableBossMagicCircle("magicCircle.png", 1);
	htSetBossMagicRotationSpeed(0.07);
	htSetBossMagicCircleColor(1.0, 0.0, 0.0, 1.0);
	
	bx = 0;
	by = 0;
}