#include "hostAPI.txt"

#include "global.txt"

var count;

var i;

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

var de;

func init() {
	i=0;
	count=0;
	de = 0;
}

func circle1() {
	for(i=0; i<36; ++i) {
		htInsertBulletVec(3, 2, bx, by, 3, i*10);
		htSetBulletDeflectionEx(1, 0, 0, 30);
	}
	for(i=0; i<36; ++i) {
		htInsertBulletVec(3, 3, bx, by, 2.5, i*10+5);
		htSetBulletDeflectionEx(-1, 0, 0, 30);
	}
}

func update() {
	bx = htGetBossX();
	by = htGetBossY();
	px = htGetPlayerX();
	py = htGetPlayerY();
	
	if(count >= 60 && (count < 240)) {
		if(count == 60)
			htStartTimer(30, 6, "circle1");
			
		if(count % 30 == 0) {
			var rx;
			var ry;
			rx = randomFloat(300, 500);
			ry = randomFloat(100, 200);
			htMoveBossTo(rx, ry, 30);
		}
	}
	
	if(count == 240) {
		htMoveBossTo(400, 300, 60);
		de = 0;
	}
	if(count >= 300 && (count<= 324)) {
		if(count == 300) {
			htPlayBossEnergyAnim(30);
		}
	//	if(count % 2 == 0) {
			for(i=0; i<10; ++i) {
				htInsertBulletVec(5, 2, bx, by, 3+i*0.4, 120+de);
				htSetBulletReflectTime(1, false);
			}
			for(i=0; i<10; ++i) {
				htInsertBulletVec(5, 2, bx, by, 3+i*0.4, 60-de);
				htSetBulletReflectTime(1, false);
			}
				
			de += 5;
	//	}
	}
	
	if(count > 400)
		count = 0;
		
	++count;
}
		