Commit 88e509a8 authored by Nicolas LIENART's avatar Nicolas LIENART

case show if construction is possible

parent 806fd5c3
......@@ -88,6 +88,7 @@ void case_initPlateau()
plateau->monster_hover = NULL;
plateau->index_case_hover = -1;
plateau->index_tour_hover = -1;
plateau->play = TRUE;
}
......
......@@ -428,24 +428,24 @@ void display_initDefaultList()
void display_printInfos()
{
if (plateau->index_case_hover == -1 && plateau->monster_hover == NULL) {
if (plateau->index_tour_hover == -1 && plateau->monster_hover == NULL) {
glCallList(gameData->default_list[plateau->joueur->type]->idListInfos);
glCallList(gameData->default_list[plateau->joueur->type]->idListIcon);
}
else if (plateau->monster_hover) {
glCallList(gameData->default_list[plateau->monster_hover->type + 6]->idListInfos);
}
else if (case_getGeneralConstructionType(mapData->cases[plateau->index_case_hover]) == TOUR) {
else if (case_getGeneralConstructionType(mapData->cases[plateau->index_tour_hover]) == TOUR) {
if (plateau->idListInfos == GL_INVALID_VALUE) {
display_genTourList(plateau->tours[plateau->index_case_hover]);
display_genTourList(plateau->tours[plateau->index_tour_hover]);
}
else {
glCallList(plateau->idListInfos);
}
}
else if (case_getGeneralConstructionType(mapData->cases[plateau->index_case_hover]) == BATIMENT) {
else if (case_getGeneralConstructionType(mapData->cases[plateau->index_tour_hover]) == BATIMENT) {
if (plateau->idListInfos == GL_INVALID_VALUE) {
display_genBatimentList(mapData->cases[plateau->index_case_hover]);
display_genBatimentList(mapData->cases[plateau->index_tour_hover]);
}
else {
glCallList(plateau->idListInfos);
......@@ -592,33 +592,11 @@ int display_drawAllProjectiles()
void display_drawSingleProjectile(Projectile* projectile)
{
/*
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();
display_drawCircle(GL_FILL);
glPopMatrix();
}
......@@ -766,7 +744,7 @@ void display_drawAllTargetRanges()
}
int caseY, caseX;
case_getCasePosition(index_case, &caseX, &caseY);
if (plateau->index_case_hover == index_case) {
if (plateau->index_tour_hover == index_case) {
glPushMatrix();
float range = 0;
switch (generalType) {
......@@ -783,6 +761,34 @@ void display_drawAllTargetRanges()
}
}
void display_drawCaseHover(int index_case)
{
int caseY, caseX;
case_getCasePosition(index_case, &caseX, &caseY);
if (plateau->joueur->action == ADD) {
if (case_isConstructible(caseX, caseY) == TRUE && plateau->joueur->argent >= tour_getPrixAchat(plateau->joueur->type)) {
glColor4ub(0, 255, 0, 50);
}
else {
glColor4ub(255, 0, 0, 50);
}
}
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glPushMatrix();
glTranslatef(caseX, caseY, 0);
glTranslatef(0.5, 0.5, 0);
glScalef(0.95,0.95,1);
display_drawSquare(GL_FILL);
glPopMatrix();
glDisable(GL_BLEND);
}
void display_drawBoard()
{
int total_cases = mapData->Xsplit * mapData->Ysplit;
......@@ -792,6 +798,11 @@ void display_drawBoard()
case_getCasePosition(index_case, &caseX, &caseY);
TypeCase type = mapData->cases[index_case];
if (index_case == plateau->index_case_hover) {
display_drawCaseHover(index_case);
}
glColor3f(1,1,1);
display_drawSingleTower(caseX, caseY, type);
}
display_drawAllTargetRanges();
......
......@@ -35,6 +35,7 @@ void display_showCursor();
void display_genTourList(Tour* tour);
void display_genBatimentList(TypeCase type);
void display_drawCaseHover(int index_case);
TextureText* display_loadTextureText(char text[]);
void display_drawSingleStat(GeneralType generalType, char text[], TextureName texture_name, char str2[]);
void display_initDefaultList();
......
......@@ -30,22 +30,27 @@ void mouse_handlePosition()
get_casesi(&caseX, &caseY, gameData->plateauGUI->dimensions);
TypeCase currentCase_type = case_getType(caseX+1, caseY+1);
if (plateau->index_case_hover != case_getCaseIndex(caseX+1, caseY+1)) {
Mix_PlayChannel(-1, gameData->sound[SNAP], 0);
}
plateau->index_case_hover = case_getCaseIndex(caseX+1, caseY+1);
if (currentCase_type == CHEMIN || currentCase_type == NOEUD || currentCase_type == ENTREE) {
mouse_checkIfMonster();
plateau->index_case_hover = -1;
plateau->index_tour_hover = -1;
}
else if (case_getGeneralConstructionType(currentCase_type) == TOUR || case_getGeneralConstructionType(currentCase_type) == BATIMENT) {
int index_case_hover = case_getCaseIndex(caseX+1, caseY+1);
if (plateau->index_case_hover != index_case_hover) {
plateau->index_case_hover = index_case_hover;
int index_tour_hover = case_getCaseIndex(caseX+1, caseY+1);
if (plateau->index_tour_hover != index_tour_hover) {
plateau->index_tour_hover = index_tour_hover;
glDeleteLists(plateau->idListInfos, 1);
plateau->idListInfos = GL_INVALID_VALUE;
}
plateau->monster_hover = NULL;
}
else {
plateau->index_case_hover = -1;
plateau->index_tour_hover = -1;
plateau->monster_hover = NULL;
}
}
......@@ -55,6 +60,7 @@ void mouse_handlePosition()
snap = TRUE;
}
plateau->index_case_hover = -1;
plateau->index_tour_hover = -1;
plateau->monster_hover = NULL;
}
......
......@@ -404,6 +404,7 @@ typedef struct Plateau {
GLuint idListMoney;
Monster *monster_hover;
int index_case_hover;
int index_tour_hover;
ListTours* listTours;
ListMonsters* listMonsters;
ListProjectiles* listProjectiles;
......
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