Commit 806fd5c3 authored by Nicolas LIENART's avatar Nicolas LIENART

New sounds and round projectile

parent f9f5a254
File added
File added
......@@ -51,6 +51,7 @@ void case_gameData_init() {
exit(EXIT_FAILURE);
}
gameData->gameState = MAINMENU;
gameData->button_hover = NULL;
gameData->default_list = NULL;
};
......@@ -66,6 +67,7 @@ void case_initPlateau()
plateau->idListIcon = GL_INVALID_VALUE;
plateau->idListMoney = GL_INVALID_VALUE;
plateau->joueur = player_init(mapData->argent);
plateau->listMonsters = monster_initListMonster();
plateau->listTours = tour_initListTours();
......@@ -188,6 +190,7 @@ void case_addConstruction(int caseX, int caseY)
tour_add(type, index_case);
}
else if (generalType == BATIMENT) {
Mix_PlayChannel(-1, gameData->sound[CENTRAL], 0);
updateAllTower();
printf("adding building\n");
// Fonction de placement de batiment
......
......@@ -404,7 +404,8 @@ void display_initDefaultList()
glPushMatrix();
glTranslatef(15, position*35+15, 0);
sprintf(str, "%f", 0.01/mapData->dataMonsters[type].mass);
float speed = (0.01/mapData->dataMonsters[type].mass) * 1000;
sprintf(str, "%d", (int) speed);
display_drawSingleStat(generalType, str, SPEED_TEX, NULL);
position++;
glPopMatrix();
......@@ -591,14 +592,34 @@ int display_drawAllProjectiles()
void display_drawSingleProjectile(Projectile* projectile)
{
glColor3d(255,0,255);
/*
glColor3d(255,0,255);
glBegin(GL_TRIANGLES);
glVertex2f(projectile->x, projectile->y-0.1);
glVertex2f(projectile->x+0.1, projectile->y+0.1);
glVertex2f(projectile->x-0.1, projectile->y+0.1);
glEnd();
*/
glPushMatrix();
glTranslatef(projectile->x, projectile->y, 0);
glScalef(0.1, 0.1, 1);
int angles = 360;
double angleStep = 2*M_PI/angles;
double currentAngle = 0;
glBegin(GL_TRIANGLE_FAN);
glColor3ub(150,239,134);
glVertex2f(0,0);
glColor3ub(45,247,9);
while (currentAngle < 2*M_PI) {
glVertex2f(0.5 * cos(currentAngle), 0.5 * sin(currentAngle));
currentAngle += angleStep;
}
glEnd();
glPopMatrix();
}
void display_mapList(GLuint id)
......
......@@ -3,8 +3,28 @@
void mouse_handlePosition()
{
GUI *current_section = mouse_getSection();
static Bool snap = FALSE;
if (current_section->name == PLATEAU && gameData->gameState == LEVELPLAY) {
if (gameData->gameState == MAINMENU) {
if (gameData->button_hover != mouse_GUIbutton(gameData->mainMenuGUI)) {
gameData->button_hover = mouse_GUIbutton(gameData->mainMenuGUI);
snap = TRUE;
}
}
else if (gameData->gameState == LOSEMENU || gameData->gameState == WINMENU) {
if (gameData->button_hover != mouse_GUIbutton(gameData->endMenuGUI)) {
gameData->button_hover = mouse_GUIbutton(gameData->endMenuGUI);
snap = TRUE;
}
}
if (gameData->button_hover != NULL && snap == TRUE) {
Mix_PlayChannel(-1, gameData->sound[SNAP], 0);
snap = FALSE;
}
else if (current_section->name == PLATEAU && gameData->gameState == LEVELPLAY) {
gameData->button_hover = NULL;
int caseX;
int caseY;
get_casesi(&caseX, &caseY, gameData->plateauGUI->dimensions);
......@@ -30,9 +50,14 @@ void mouse_handlePosition()
}
}
else if (gameData->gameState == LEVELPLAY) {
if (gameData->button_hover != mouse_GUIbutton(current_section)) {
gameData->button_hover = mouse_GUIbutton(current_section);
snap = TRUE;
}
plateau->index_case_hover = -1;
plateau->monster_hover = NULL;
}
}
......@@ -116,7 +141,10 @@ void mouse_handleButtonClick(ButtonName button_name)
void mouse_handleClick()
{
GUI *current_section = mouse_getSection();
if (gameData->button_hover) {
Mix_PlayChannel(-1, gameData->sound[HITWOOD], 0);
mouse_handleButtonClick(gameData->button_hover->name);
}
if(gameData->gameState == LEVELPLAY) {
if (current_section->name == PLATEAU) {
int casex, casey;
......@@ -127,25 +155,6 @@ void mouse_handleClick()
printf("%f %f\n", casex_f, casey_f);
case_handleAction(casex +1, casey +1);
}
Button *buttonClicked = mouse_GUIbutton(current_section);
if (buttonClicked) {
mouse_handleButtonClick(buttonClicked->name);
printf("%d\n", buttonClicked->name +1);
}
}
else if (gameData->gameState == MAINMENU) {
Button *buttonClicked = mouse_GUIbutton(gameData->mainMenuGUI);
if (buttonClicked) {
mouse_handleButtonClick(buttonClicked->name);
printf("%d\n", buttonClicked->name +1);
}
}
else if (gameData->gameState == LOSEMENU || gameData->gameState == WINMENU) {
Button *buttonClicked = mouse_GUIbutton(gameData->endMenuGUI);
if (buttonClicked) {
mouse_handleButtonClick(buttonClicked->name);
printf("%d\n", buttonClicked->name +1);
}
}
}
......
......@@ -6,7 +6,7 @@ void sound_init()
printf("%s", Mix_GetError());
}
gameData->sound = malloc(sizeof(Mix_Music*)*10);
gameData->sound = malloc(sizeof(Mix_Music*)*13);
if (!gameData->sound) {
printf("ERROR ALLOC : sound");
exit(CHK_ERROR_ALLOC);
......@@ -49,4 +49,13 @@ void sound_init()
son = Mix_LoadWAV("sound/levelWin.wav");
gameData->sound[WINLEVEL] = son;
son = Mix_LoadWAV("sound/snap.wav");
gameData->sound[SNAP] = son;
son = Mix_LoadWAV("sound/hit-wood.wav");
gameData->sound[HITWOOD] = son;
son = Mix_LoadWAV("sound/bleep.wav");
gameData->sound[BLEEP] = son;
}
......@@ -57,7 +57,10 @@ typedef enum Sound {
GENE,
BOS,
LOSELEVEL,
WINLEVEL
WINLEVEL,
SNAP,
HITWOOD,
BLEEP
} Sound;
typedef struct Wave {
......@@ -350,21 +353,6 @@ typedef struct ListMonsters {
Monster* firstMonster;
} ListMonsters;
typedef struct Plateau {
Bool play;
Etat* joueur;
GLuint idListInfos;
GLuint idListIcon;
GLuint idListMoney;
Monster *monster_hover;
int index_case_hover;
ListTours* listTours;
ListMonsters* listMonsters;
ListProjectiles* listProjectiles;
Wave currentWave;
Tour **tours;
} Plateau;
typedef struct Div {
int x;
int y;
......@@ -408,6 +396,21 @@ typedef struct Button {
ButtonName name;
} Button;
typedef struct Plateau {
Bool play;
Etat* joueur;
GLuint idListInfos;
GLuint idListIcon;
GLuint idListMoney;
Monster *monster_hover;
int index_case_hover;
ListTours* listTours;
ListMonsters* listMonsters;
ListProjectiles* listProjectiles;
Wave currentWave;
Tour **tours;
} Plateau;
typedef enum SectionName {
BODY,
FOOTER,
......@@ -454,6 +457,7 @@ typedef struct GameData {
Texture** textures;
Mix_Chunk** sound;
DefaultList **default_list;
Button *button_hover;
GUI *bodyGUI;
GUI *plateauGUI;
GUI *bottomGUI;
......
......@@ -161,6 +161,7 @@ void tour_remove(Tour* tour)
}
tour_list->next = tour_list->next->next;
}
Mix_PlayChannel(-1, gameData->sound[BLEEP], 0);
free(tour);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment