|
@@ -0,0 +1,80 @@
|
|
|
+#include "LaunchCircle.h"
|
|
|
+#include <cmath>
|
|
|
+
|
|
|
+LaunchCircle::LaunchCircle(int const rayon, Uint32 const couleur, int const stock)
|
|
|
+:m_rayon(rayon),m_epaisseur(40),m_stock(stock)
|
|
|
+{
|
|
|
+ m_pixel = SDL_CreateRGBSurface(SDL_HWSURFACE, 1, 1, 16,0,0,0,0);
|
|
|
+ SDL_FillRect(m_pixel,NULL,couleur);
|
|
|
+}
|
|
|
+
|
|
|
+LaunchCircle::LaunchCircle(int const rayon, Uint32 const couleur, int const stock, int const epaisseur)
|
|
|
+:m_rayon(rayon),m_epaisseur(epaisseur),m_stock(stock)
|
|
|
+{
|
|
|
+ m_pixel = SDL_CreateRGBSurface(SDL_HWSURFACE, 1, 1, 16,0,0,0,0);
|
|
|
+ SDL_FillRect(m_pixel,NULL,couleur);
|
|
|
+}
|
|
|
+
|
|
|
+LaunchCircle::~LaunchCircle()
|
|
|
+{
|
|
|
+ SDL_FreeSurface(m_pixel);
|
|
|
+}
|
|
|
+
|
|
|
+void LaunchCircle::afficher(int const x, int const y, int const valeur, SDL_Surface *screen)
|
|
|
+{
|
|
|
+
|
|
|
+ double radian((double)valeur/m_stock*2*M_PI);
|
|
|
+ radian -= M_PI_2;
|
|
|
+
|
|
|
+
|
|
|
+ double m(0);
|
|
|
+ double p(0);
|
|
|
+
|
|
|
+ m = (sin(radian))/(cos(radian));
|
|
|
+ p = -(m*x)+y;
|
|
|
+
|
|
|
+
|
|
|
+ SDL_Rect position;
|
|
|
+ for (int i(x-m_rayon); i<=x+m_rayon; i++)
|
|
|
+ {
|
|
|
+ for (int j(y-m_rayon); j<=y+m_rayon; j++)
|
|
|
+ {
|
|
|
+
|
|
|
+ if ((i-x)*(i-x)+(j-y)*(j-y)<m_rayon*m_rayon &&
|
|
|
+ (i-x)*(i-x)+(j-y)*(j-y)>m_rayon*m_rayon-m_epaisseur*m_epaisseur)
|
|
|
+ {
|
|
|
+ position.x=i;
|
|
|
+ position.y=j;
|
|
|
+ if (radian <=-M_PI_2)
|
|
|
+ {}
|
|
|
+ else if (radian >= 3*M_PI_2)
|
|
|
+ {
|
|
|
+ SDL_BlitSurface(m_pixel, 0, screen, &position);
|
|
|
+ }
|
|
|
+ else if (radian == M_PI_2)
|
|
|
+ {
|
|
|
+ if (i<=x)
|
|
|
+ SDL_BlitSurface(m_pixel, 0, screen, &position);
|
|
|
+ }
|
|
|
+ else if (radian < M_PI_2)
|
|
|
+ {
|
|
|
+ if (i<=x && j>m*i+p)
|
|
|
+ {
|
|
|
+ SDL_BlitSurface(m_pixel, 0, screen, &position);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (radian > M_PI_2)
|
|
|
+ {
|
|
|
+ if (i<=x)
|
|
|
+ {
|
|
|
+ SDL_BlitSurface(m_pixel, 0, screen, &position);
|
|
|
+ }
|
|
|
+ else if (j<m*i+p)
|
|
|
+ {
|
|
|
+ SDL_BlitSurface(m_pixel, 0, screen, &position);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|