#pragma once

#include "vector.h"
//#include <d3d9.h>


class Explosion
{
public:

    // methods
    Explosion(void);
    ~Explosion(void);

    void Draw();
    void Cycle(float deltaMs);
    void ExplodeAt(const CPos &position);
    bool IsActive() { return m_Active; };

private:
    // tweaking parameters
    static const int ANIMATION_FRAMES_ROWS = 4;
    static const int ANIMATION_FRAMES_COLS = 4;
    static const int ANIMATION_FILMSTRIP_WIDTH = 256;
    static const int ANIMATION_FILMSTRIP_HEIGHT = 256;
    static const int ANIMATION_DURATION = 1000;         // duration of complete explosion sequence in milliseconds
    static const int EXPLOSION_IMAGE_RADIUS = 8;          // how big will the explosion be drawn ?
    //

    static const int ANIMATION_FRAMETIME = ANIMATION_DURATION / (ANIMATION_FRAMES_COLS * ANIMATION_FRAMES_ROWS);        // how long is each single frame visible ?
    static const int FRAME_WIDTH = ANIMATION_FILMSTRIP_WIDTH / ANIMATION_FRAMES_COLS;
    static const int FRAME_HEIGHT = ANIMATION_FILMSTRIP_HEIGHT / ANIMATION_FRAMES_ROWS;

    static const DWORD CUSTOM_FVF = D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1 | D3DFVF_TEXCOORDSIZE3(0) ;   // D3DFVF_TEX1 heisst, wir haben ein Set von Textur-Koordinaten
    struct CUSTOM_VERTEX_STRUCT    		
    {
        FLOAT X, Y, Z; 
        DWORD COLOR; 
        FLOAT U,V,W;
    };

    // members
    CVector m_Position;
    float m_AnimationTimer;       // milliseconds since the explosion has been initiated
    float m_FrameTranslationX, m_FrameTranslationY;         // used for moving the current animationframe to the drawing position
    bool m_Active;                

    LPDIRECT3DTEXTURE9 m_pFilmstrip; 
    LPDIRECT3DVERTEXBUFFER9 t_buffer;       // the pointer to the vertex buffer

};
