/******************************************************************************
*******************************************************************************

	Bubble Fight EX
	relminator
	http://rel.betterwebber.com


	Centipede class


*******************************************************************************
******************************************************************************/

#include <nds.h>
#include <vector>
#include <cstdio>

#include "EntityContainer.h"
#include "StarFighter.h"
#include "Vector2df32.h"
#include "Spline.h"
#include "cearn_atan.h"
#include "Explosion.h"

#ifndef CENTIPEDE_H
#define CENTIPEDE_H

#define CENTIPEDE_MAX_SEGMENTS 128

//------------------------------------------------------------------------------
//	Centipede Enemy
//------------------------------------------------------------------------------
class Centipede {

public:
	friend class CentipedeContainer;
	
	Centipede();
	~Centipede();
	void Update();
	void LoadPath( int _sx, int _sy, int _ex, int _ey );
	
private:

	
	s32		x;
	s32		y;
	int		Frame;
	int 	Counter;
	bool	Active;
	int 	Hp;
	
	Vector2df32  LastPoint;
	
	EN_DRAW_MODE DrawMode;

	Vector2df32  Segments[CENTIPEDE_MAX_SEGMENTS];
	Spline 		 Path;
	
	void ResetSegments()
	{
		for( int i = 0; i < CENTIPEDE_MAX_SEGMENTS; i++ )
		{
			Segments[i].x = inttof32(300);
			Segments[i].y = inttof32(96);
		}
	}

};

//------------------------------------------------------------------------------
//	Centipede Container
//------------------------------------------------------------------------------
class CentipedeContainer : public EntityContainer
{	

public:

	CentipedeContainer();
    ~CentipedeContainer();
    void Init( int Palette, glImage* const Sprites );
    virtual void UpdateEntities();
	virtual void DrawEntities();
	virtual bool Collide( StarFighter &Star );
	virtual void KillAllEntities();
	void Spawn(  int _x, int _y  );
	
	virtual int NumEntities() 
	{
		return numEntities;
	}
	
private:
	int numEntities;
	
	glImage *Images;
	int ColorTable;
	
	std::vector<Centipede> Centipedes;
	
	
};

#endif // CENTIPEDE_H
