#include #include "include/window_struct.h" #include "include/fx/fire.h" int CreateWindow(struct window *window_t, int x, int y, int depth, char *title) // pos a implementé { window_t->fire_t = malloc(sizeof(struct fire_)); window_t->fire_t->rootRect = malloc(sizeof(SDL_Rect)); window_t->fire_t->fireRect = malloc(sizeof(SDL_Rect)); //remplissage de la structure window_t->screen = SDL_SetVideoMode (x, y, depth, SDL_HWSURFACE); window_t->taille_x = x; window_t->taille_y = y; window_t->depth = depth; SDL_WM_SetCaption(title, NULL); //definie le nom de la fenetre return 0; } void DestroyWindow(struct window *window_t) { /*free(window_t->fire_t); free(window_t->fire_t->rootRect); free(window_t->fire_t->fireRect);*/ printf("Fermeture de la fenetre\n"); SDL_FreeSurface(window_t->screen); } void InitColors(struct window * window_t) { window_t->colors[C_NOIR] = SDL_MapRGB(window_t->screen->format, 0x00, 0x00, 0x00); window_t->colors[C_BLEU_FONCE] = SDL_MapRGB(window_t->screen->format, 0x00, 0x00, 0x80); window_t->colors[C_VERT_FONCE] = SDL_MapRGB(window_t->screen->format, 0x00, 0x80, 0x00); window_t->colors[C_CYAN_FONCE] = SDL_MapRGB(window_t->screen->format, 0x00, 0x80, 0x80); window_t->colors[C_ROUGE_FONCE] = SDL_MapRGB(window_t->screen->format, 0x80, 0x00, 0x00); window_t->colors[C_MAGENTA_FONCE] = SDL_MapRGB(window_t->screen->format, 0x80, 0x00, 0x80); window_t->colors[C_OCRE] = SDL_MapRGB(window_t->screen->format, 0x80, 0x80, 0x00); window_t->colors[C_GRIS_CLAIR] = SDL_MapRGB(window_t->screen->format, 0xC0, 0xC0, 0xC0); window_t->colors[C_GRIS] = SDL_MapRGB(window_t->screen->format, 0x80, 0x80, 0x80); window_t->colors[C_BLEU] = SDL_MapRGB(window_t->screen->format, 0x00, 0x00, 0xFF); window_t->colors[C_VERT] = SDL_MapRGB(window_t->screen->format, 0x00, 0xFF, 0x00); window_t->colors[C_CYAN] = SDL_MapRGB(window_t->screen->format, 0x00, 0xFF, 0xFF); window_t->colors[C_ROUGE] = SDL_MapRGB(window_t->screen->format, 0xFF, 0x00, 0x00); window_t->colors[C_MAGENTA] = SDL_MapRGB(window_t->screen->format, 0xFF, 0x00, 0xFF); window_t->colors[C_JAUNE] = SDL_MapRGB(window_t->screen->format, 0xFF, 0xFF, 0x00); window_t->colors[C_BLANC] = SDL_MapRGB(window_t->screen->format, 0xFF, 0xFF, 0xFF); } int KeyWindow(void) { SDL_Event event; while (SDL_WaitEvent(&event)) { switch (event.type) { case SDL_KEYDOWN: switch (event.key.keysym.sym) { case SDLK_ESCAPE: return SDLK_ESCAPE; case SDLK_LEFT: return SDLK_LEFT; case SDLK_RIGHT: return SDLK_RIGHT; case SDLK_UP: return SDLK_UP; case SDLK_DOWN: return SDLK_DOWN; default: //return 0; break; } break; // case SDL_KEYUP: default: break; } } return 0; }