historique
This commit is contained in:
parent
cfb9a0739f
commit
b679c9b7a5
3
launcher.sh
Normal file
3
launcher.sh
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
bin/hex
|
BIN
ressources/.east/Boom.mp3
Normal file
BIN
ressources/.east/Boom.mp3
Normal file
Binary file not shown.
BIN
ressources/.east/Boom.png
Normal file
BIN
ressources/.east/Boom.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 751 KiB |
BIN
ressources/.east/Boom.wav
Normal file
BIN
ressources/.east/Boom.wav
Normal file
Binary file not shown.
@ -12,6 +12,7 @@
|
|||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
#include "affichage_menu_principal.h"
|
#include "affichage_menu_principal.h"
|
||||||
#include "sound.h"
|
#include "sound.h"
|
||||||
|
#include "SDL/SDL_mixer.h"
|
||||||
|
|
||||||
void deplacement_menu_mouse (menu_t m, const SDL_Event* event)
|
void deplacement_menu_mouse (menu_t m, const SDL_Event* event)
|
||||||
{
|
{
|
||||||
@ -125,6 +126,73 @@ void deplacement_menu_key (menu_t m, SDLKey key)
|
|||||||
play_clik();
|
play_clik();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void boom (SDL_Surface* window)
|
||||||
|
{
|
||||||
|
SDL_Surface* tmp = IMG_Load ("ressources/.east/Boom.png");
|
||||||
|
SDL_Surface* boom = rotozoomSurface(tmp, .0, fmin(window->h / (float)tmp->h, window->w / (float)tmp->w), 1);
|
||||||
|
SDL_Rect p = {(window->w - boom->w) / 2, (window->h - boom->h) / 2};
|
||||||
|
SDL_Surface* lum = SDL_CreateRGBSurface (SDL_HWSURFACE, window->w, window->h, window->format->BitsPerPixel, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
SDL_FreeSurface(tmp);
|
||||||
|
tmp = SDL_CreateRGBSurface (SDL_HWSURFACE, window->w, window->h, window->format->BitsPerPixel, 0, 0, 0, 0);
|
||||||
|
SDL_BlitSurface (window, NULL, tmp, NULL);
|
||||||
|
|
||||||
|
Mix_Chunk* boomS = Mix_LoadWAV("ressources/.east/Boom.wav");
|
||||||
|
Mix_VolumeChunk (boomS, .1 * MIX_MAX_VOLUME);
|
||||||
|
if (boomS == NULL)
|
||||||
|
fprintf (stderr, "ressources/.east/Boom.mp3 : %s\n", SDL_GetError());
|
||||||
|
Mix_PlayChannel(0, boomS, 0);
|
||||||
|
|
||||||
|
bool end = false;
|
||||||
|
|
||||||
|
int i = 255;
|
||||||
|
while (i >= 0)
|
||||||
|
{
|
||||||
|
if (!(SDL_GetTicks() % 40))
|
||||||
|
{
|
||||||
|
SDL_FillRect (window, NULL, SDL_MapRGB (window->format, 0, 0, 0));
|
||||||
|
|
||||||
|
SDL_BlitSurface (boom, NULL, window, &p);
|
||||||
|
|
||||||
|
Uint32 white = SDL_MapRGB (window->format, 255, 255, 255);
|
||||||
|
SDL_FillRect (lum, NULL, white);
|
||||||
|
SDL_SetAlpha(lum, SDL_SRCALPHA, i);
|
||||||
|
SDL_BlitSurface (lum, NULL, window, NULL);
|
||||||
|
SDL_Flip (window);
|
||||||
|
i -= 4;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Uint32 black = SDL_MapRGB (window->format, 0, 0, 0);
|
||||||
|
SDL_FillRect (lum, NULL, black);
|
||||||
|
SDL_SetAlpha(lum, SDL_SRCALPHA, 1);
|
||||||
|
|
||||||
|
while (i < 256)
|
||||||
|
{
|
||||||
|
if (!(SDL_GetTicks() % 10))
|
||||||
|
{
|
||||||
|
SDL_BlitSurface (lum, NULL, window, NULL);
|
||||||
|
SDL_Flip (window);
|
||||||
|
i += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while (!end)
|
||||||
|
{
|
||||||
|
SDL_Event e;
|
||||||
|
SDL_PollEvent (&e);
|
||||||
|
if (e.type == SDL_QUIT || (e.type == SDL_KEYDOWN && e.key.keysym.sym == SDLK_ESCAPE))
|
||||||
|
end = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
SDL_BlitSurface (tmp, NULL, window, NULL);
|
||||||
|
|
||||||
|
SDL_FreeSurface(tmp);
|
||||||
|
SDL_FreeSurface(boom);
|
||||||
|
SDL_FreeSurface(lum);
|
||||||
|
Mix_FreeChunk (boomS);
|
||||||
|
}
|
||||||
|
|
||||||
bool selection_menu (menu_t m, int* r)
|
bool selection_menu (menu_t m, int* r)
|
||||||
{
|
{
|
||||||
switch (10 * m->cur.x + m->cur.y)
|
switch (10 * m->cur.x + m->cur.y)
|
||||||
@ -140,6 +208,7 @@ bool selection_menu (menu_t m, int* r)
|
|||||||
*r = M_HEX;
|
*r = M_HEX;
|
||||||
if (m->c == 15)
|
if (m->c == 15)
|
||||||
{
|
{
|
||||||
|
boom (m->window);
|
||||||
m->c = 0;
|
m->c = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -14,18 +14,20 @@ int selection (plateau_t p, curseur_t c)
|
|||||||
if (0 <= c.x && c.x < NBSIDE && 0 <= c.y && c.y < NBSIDE && p->grid [c.x * NBSIDE + c.y] == 0)
|
if (0 <= c.x && c.x < NBSIDE && 0 <= c.y && c.y < NBSIDE && p->grid [c.x * NBSIDE + c.y] == 0)
|
||||||
{
|
{
|
||||||
p->grid [c.x * NBSIDE + c.y] = PLAYER(p->player);
|
p->grid [c.x * NBSIDE + c.y] = PLAYER(p->player);
|
||||||
|
p->hist [p->nb_coups++] = c.x * NBSIDE + c.y;
|
||||||
p->player = !p->player;
|
p->player = !p->player;
|
||||||
Affiche_hexagon(p, c.x, c.y, PLAYER(p->player));
|
Affiche_hexagon(p, c.x, c.y, PLAYER(p->player));
|
||||||
return testGagne (p->grid, PLAYER(!p->player));
|
return testGagne (p->grid, PLAYER(!p->player));
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
/*for (int x = 0; x < NBSIDE; ++x)
|
/*for (int x = 0; x < NBSIDE; ++x)
|
||||||
{
|
{
|
||||||
for (int y = 0; y < NBSIDE; ++y)
|
for (int y = 0; y < NBSIDE; ++y)
|
||||||
printf ("%d ", p->grid [y * NBSIDE + x]);
|
printf ("%d ", p->hist [y * NBSIDE + x]);
|
||||||
printf ("\n");
|
printf ("\n");
|
||||||
}
|
}
|
||||||
printf ("\n");*/
|
printf ("\n");*/
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void deplacement (plateau_t p, SDL_Event* event, curseur_t* c)
|
void deplacement (plateau_t p, SDL_Event* event, curseur_t* c)
|
||||||
|
@ -435,6 +435,9 @@ void banane (SDL_Surface* window)
|
|||||||
end = true;
|
end = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SDL_BlitSurface (erase, NULL, window, &p);
|
||||||
|
SDL_Flip (window);
|
||||||
|
|
||||||
for (int i = 0; i < 8; ++i)
|
for (int i = 0; i < 8; ++i)
|
||||||
{
|
{
|
||||||
SDL_FreeSurface (gif [i]);
|
SDL_FreeSurface (gif [i]);
|
||||||
|
@ -125,9 +125,13 @@ plateau_t init_plateau (SDL_Surface* window)
|
|||||||
{
|
{
|
||||||
plateau_t p = malloc (sizeof (struct s_plateau));
|
plateau_t p = malloc (sizeof (struct s_plateau));
|
||||||
p->grid = malloc (sizeof (int) * NBSIDE * NBSIDE);
|
p->grid = malloc (sizeof (int) * NBSIDE * NBSIDE);
|
||||||
for (int x = 0; x < NBSIDE; ++x)
|
p->hist = malloc (sizeof (int) * NBSIDE * NBSIDE);
|
||||||
for (int y = 0; y < NBSIDE; ++y)
|
for (int x = 0; x <= NBSIDE * NBSIDE; ++x)
|
||||||
p->grid [x * NBSIDE + y] = 0;
|
{
|
||||||
|
p->grid [x] = 0;
|
||||||
|
p->hist [x] = 0;
|
||||||
|
}
|
||||||
|
p->nb_coups = 0;
|
||||||
p->window = window;
|
p->window = window;
|
||||||
p->player = false;
|
p->player = false;
|
||||||
define_rayon(p);
|
define_rayon(p);
|
||||||
|
@ -41,6 +41,7 @@ void en_jeu (SDL_Surface* window)
|
|||||||
end = selection (plateau, c);
|
end = selection (plateau, c);
|
||||||
else if (SDLK_UP <= event.key.keysym.sym && event.key.keysym.sym <= SDLK_LEFT)
|
else if (SDLK_UP <= event.key.keysym.sym && event.key.keysym.sym <= SDLK_LEFT)
|
||||||
deplacement(plateau, &event, &c);
|
deplacement(plateau, &event, &c);
|
||||||
|
east1 (window, event.key.keysym.sym);
|
||||||
break;
|
break;
|
||||||
case SDL_MOUSEBUTTONUP:
|
case SDL_MOUSEBUTTONUP:
|
||||||
end = selection (plateau, c);
|
end = selection (plateau, c);
|
||||||
|
@ -55,6 +55,8 @@ typedef struct s_plateau {
|
|||||||
int marge_hori;
|
int marge_hori;
|
||||||
SDL_Surface* window;
|
SDL_Surface* window;
|
||||||
int *grid;
|
int *grid;
|
||||||
|
int *hist;
|
||||||
|
int nb_coups;
|
||||||
bool player;
|
bool player;
|
||||||
}* plateau_t;
|
}* plateau_t;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user