#include "m_logo.h" #include "jdraw.h" #include "jinput.h" #include "controller.h" #include "config.h" #include namespace modules { namespace logo { struct pixel_t { int x, y; float distance; float angle; float di, dd, ai, ad; }; pixel_t pixels[200]; int num_pixels = 0; float d = 1; float a = 0; void get_dist_angle_from_xy(int pixel); void calculate_coords_from_dist_angle(int pixel); void init() { srand(SDL_GetTicks()); num_pixels = 0; draw::surface *surf = draw::getSurface("jailgames.gif"); for (int y=0; yh; ++y) for (int x=0; xw; ++x) if (surf->pixels[x+y*surf->w]!=0) { pixels[num_pixels].x = x; pixels[num_pixels].y = y; get_dist_angle_from_xy(num_pixels); pixels[num_pixels].dd = float((rand()%5)+1)/100.0f; pixels[num_pixels].ad = float((rand()%10)+1); pixels[num_pixels].di = 1; pixels[num_pixels].ai = 0; for (int i=0; i<40; ++i) { pixels[num_pixels].di += pixels[num_pixels].dd; pixels[num_pixels].ai += pixels[num_pixels].ad; } num_pixels++; } } int steps=0; bool loop() { if (input::keyPressed(SDL_SCANCODE_ESCAPE) || controller::pressed(KEY_JUMP) || controller::pressed(KEY_PICK) ) { return false; } draw::cls(2); draw::color(1); if (steps < 40) { for (int i=0; i280) { return false; } draw::render(); steps++; return true; } void get_dist_angle_from_xy(int pixel) { int x = pixels[pixel].x - 25; int y = 3 - pixels[pixel].y; pixels[pixel].distance = sqrtf(x*x + y*y); pixels[pixel].angle = atan2f(y, x)/(M_PI/180.0f); } void calculate_coords_from_dist_angle(int pixel) { pixels[pixel].x = 25 + roundf(cosf((pixels[pixel].angle+pixels[pixel].ai)*(M_PI/180.0f)) * (pixels[pixel].distance*pixels[pixel].di)); pixels[pixel].y = 3 - roundf(sinf((pixels[pixel].angle+pixels[pixel].ai)*(M_PI/180.0f)) * (pixels[pixel].distance*pixels[pixel].di)); } } }