void graphicsDraw(){ SDL_SetRenderDrawColor(gfx.renderer, 0, 0, 0, 255); SDL_RenderClear(gfx.renderer); if(show_fps == 1) updateFPS(); drawUnits(); SDL_RenderPresent(gfx.renderer); }
/******************************************************* * paintGL() * * Description: The primary painting function for the * OpenGL widget. Everything is drawn here at the * specified update rate. * * Inputs: none * * Outputs: none * * Return: none *******************************************************/ void GLWidget::paintGL() { // Handle title screen. if (!isBattle) { updateTitleScreen(); return; } // Capture pending status. if (!isPending && !isEffect) { for (int i = 0; i < MAX_MAP_UNITS; i++) { // Update the action time (unitTest). if (unit[i].actionTime >= 100 && unit[i].status==UNIT_OK) //the dead shall not move :o { if (unit[i].team == USER_UNIT) { // Play 'ready' sound. QSound *soundBkgnd = new QSound("sounds/blip.wav"); soundBkgnd->play(); } // The unit is ready to go, so pause the game. battleMap.gridCell[unit[i].vLocation][unit[i].hLocation].unit->isPending = true; isPending = true; // Tell mechanics to handle AI. mech->handleAI(); break; } unit[i].actionTime += 0.005 * unit[i].actionRate; } } // Clear the background. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Draw items. drawBackground(); drawGrid(); drawUnits(); drawHeaderInfo(); if (isEffect) { drawEffects(); } }
int main (void) { char uInput= ' '; path *P; unit ** U; int i; U = malloc(sizeof(unit*) * 10); P = createPath(20, 3); for (i = 0; i < 10; i++) { U[i] = createUnit(0,P->x[i],P->y[i]); U[i]->health = U[i]->health - (i * 10); U[i]->pathIndex = i; U[i]->type = i%3; printf("%d\n",U[i]->x); } getch(); initscr(); start_color(); init_pair(text, 7,0); init_pair(blue, 4,0); init_pair(red, 1,0); init_pair(orange, 3,0); init_pair(green, 2,0); while (uInput != 'q') { drawMap(P,20); drawUnits(P,U,10); refresh(); uInput = getch(); } endwin(); printPath(P,20); return(0); }
void MiniMapView::render() { if( world==0 ) return; if( world->game.isPaused() ) return; World &wx = *world; int mk = std::max( 1, wx.terrain().width()*wx.terrain().height()/(128*128) ); if( terr.width() != w() || terr.height()!= h() ){ rtime = tcount - mk*200; tmpPix = Tempest::Pixmap(w(), h(), true); update(); } if( needToUpdateTerrainV && rtime2+mk*50 < tcount ){ needToUpdateTerrainV = false; rtime2 = tcount; Tempest::Pixmap& terr = tmpPix; Tempest::Pixmap::Pixel pix; pix.r = 0; pix.g = 0; pix.b = 0; pix.a = 255; int tw = wx.terrain().width(), th = wx.terrain().height(); for( int i=0; i<terr.width(); ++i ) for( int r=0; r<terr.height(); ++r ){ int terrX = (i*tw) /terr.width(); int terrY = (r*th)/terr.height(); pix.r = 0; pix.g = 0; pix.b = 0; if( wx.terrain().depthAt(terrX, terrY) > World::coordCastD(0.2) ){ pix.b = 255; pix.g = 128; } else { float n[3] = {}; wx.terrain().normalAt(terrX,terrY,n); float l = n[2]; int h = 165; if( wx.terrain().isEnable(terrX,terrY) ){ h += std::max(0, std::min(int(l*90), 90) ); } else { h += std::max(0, std::min(int(l*20), 20) ); } Tempest::Color cl = wx.terrain().colorAt(terrX, terrY); pix.r = cl.r()*h; pix.g = cl.g()*h; pix.b = cl.b()*h; //pix.g = 50+h; } terr.set(i,r, pix); } this->terr = Tempest::Texture2d(); this->terr = res.ltexHolder.create(terr, false, false); } if( //needToUpdateTerrain || tcount >= rtime+mk*40 || tcount < rtime ){ rtime = tcount; Tempest::Pixmap::Pixel pix = {0,0,0,0}; Tempest::Pixmap& renderTo = tmpPix; renderTo.fill(pix); drawUnits(renderTo, wx); //aceptFog(renderTo, wx.game.player().fog() ); units = Tempest::Texture2d(); units = res.ltexHolder.create(renderTo, false, false); Tempest::Pixmap& fogTex = tmpPix; aceptFog(fogTex, wx.game.player().fog() ); fog = Tempest::Texture2d(); fog = res.ltexHolder.create(fogTex, false, false); } if( originalCb != wx.cameraBounds() ){ originalCb = wx.cameraBounds(); camBounds = originalCb; int sx = wx.terrain().width()*Terrain::quadSize, sy = wx.terrain().height()*Terrain::quadSize; for( int r=0; r<4; ++r ){ camBounds.x[r] = (camBounds.x[r]*w())/sx; camBounds.y[r] = (camBounds.y[r]*h())/sy; } update(); } //hud = res.ltexHolder.create(hudPx, false, false); needToUpdateTerrain = false; ++tcount; }
int overmindAttack(gameMap_t * self, sf::RenderWindow & window, selection_t * cUnit,sf::Sprite & aCell, sf::Sprite & aEnemy, cursor_t * gCur, sf::Sprite & gameBackground, sf::Sprite & gameInterface, sf::Sprite & gameMenu, sf::Sprite & gameEndTurn, int player, sf::Sprite & cTc, player_t*pl, sf::Sprite & cBc //, //int XI, //int YJ ){ for(int i = 0;i<cellNumX;i++){ for(int j = 0;j<cellNumY;j++){ if(cUnit->cell==NULL){ return 0; } if ((float)sqrt((cUnit->cell->iX-i)*(cUnit->cell->iX-i)+(cUnit->cell->jY-j)*(cUnit->cell->jY-j)) <= (float)(cUnit->cell->unit->aRange)) { std::string tmp; if(self->cell[i][j].unit!=NULL && self->cell[i][j].unit->player != 1 && self->cell[i][j].obj_un_null == 1) { self->cell[i][j].obj_un_null = 0; std::string tmp; tmp = pathFind(cUnit->cell->iX,cUnit->cell->jY,i,j,self); if(tmp!="" && calculateLength(tmp) <= cUnit->cell->unit->aRange && cUnit->cell->unit->cPoints>0){ int tmpD = tmp[0] - 48; self->cell[i][j].obj_un_null = 1; cUnit->cell->unit->direction = tmpD; window.clear(sf::Color::Black); window.draw(gameBackground); drawUnits(self,window); window.draw(gameInterface); window.draw(gameMenu); drawMinMap(window,player,self); window.draw(gameEndTurn); drawPlayer(window,1,pl); //pData(window,cUnit); sf::Texture tmpT; sf::Sprite tmpS; tmpT.loadFromFile(self->cell[i][j].unit->sprites.path[10]); tmpS.setTexture(tmpT); tmpS.setPosition(self->cell[i][j].X + rand()%50+20,self->cell[i][j].Y + rand()%50+20); window.draw(tmpS); sf::Texture tmpT1; sf::Sprite tmpS1; tmpT1.loadFromFile(self->cell[i][j].unit->sprites.path[11+self->cell[i][j].unit->direction]); tmpS1.setTexture(tmpT1); tmpS1.setPosition(self->cell[i][j].X,self->cell[i][j].Y); window.draw(tmpS1); window.display(); Sleep(400); cUnit->cell->unit->cPoints-=1; int tmpDmg = cUnit->cell->unit->dmg - self->cell[i][j].unit->armor; if(tmpDmg<0){tmpDmg=0;} self->cell[i][j].unit->hp-=tmpDmg; if(self->cell[i][j].unit->hp<=0){ sf::Texture tmpT; sf::Sprite tmpS; tmpT.loadFromFile(self->cell[i][j].unit->sprites.path[8]); tmpS.setTexture(tmpT); tmpS.setPosition(self->cell[i][j].X,self->cell[i][j].Y); window.clear(sf::Color::Black); window.draw(gameBackground); drawUnits(self,window); window.draw(gameInterface); window.draw(gameMenu); drawMinMap(window,player,self); window.draw(gameEndTurn); drawPlayer(window,1,pl); window.draw(cBc); window.draw(tmpS); window.display(); Sleep(400); deleteUnit(self->cell[i][j].unit); self->cell[i][j].unit = NULL; self->cell[i][j].obj_un_null = 0; return 1; } return 1; }else{ self->cell[i][j].obj_un_null = 1; } } } } } return 0; }
int overmindFoundResources(gameMap_t * self, sf::RenderWindow & window, selection_t * cUnit, sf::Sprite & aCell, sf::Sprite & aEnemy, cursor_t * gCur, sf::Sprite & gameBackground, sf::Sprite & gameInterface, sf::Sprite & gameMenu, sf::Sprite & gameEndTurn, int player, sf::Sprite & cTc, player_t*pl, sf::Sprite & cBc,int XI,int YJ,resources_t * OP){ int tmpWay = 10000; int tmpCount; for(int i = 0;i<OP->count;i++){ if(OP->op[i]->object->currentPlayer!=1){ std::string tmp; self->cell[OP->op[i]->iX][OP->op[i]->jY].obj_un_null=0; tmp = pathFind(cUnit->cell->iX,cUnit->cell->jY,OP->op[i]->iX,OP->op[i]->jY,self); if(tmpWay>calculateLength(tmp)){ tmpCount = i; } self->cell[OP->op[i]->iX][OP->op[i]->jY].obj_un_null=1; } } int tmpXX1 = cUnit->cell->iX; int tmpYY1 = cUnit->cell->jY; int tmpXX2 = OP->op[tmpCount]->iX+1; int tmpYY2 = OP->op[tmpCount]->jY+1; std::string tmp = pathFind(tmpXX1,tmpYY1,tmpXX2,tmpYY2,self); if(tmp!=""){ goto startMoving; } tmp = pathFind(cUnit->cell->iX,cUnit->cell->jY,OP->op[tmpCount]->iX,OP->op[tmpCount]->jY+1,self); if(tmp!=""){ goto startMoving; } tmp = pathFind(cUnit->cell->iX,cUnit->cell->jY,OP->op[tmpCount]->iX+1,OP->op[tmpCount]->jY,self); if(tmp!=""){ goto startMoving; } tmp = pathFind(cUnit->cell->iX,cUnit->cell->jY,OP->op[tmpCount]->iX+1,OP->op[tmpCount]->jY-1,self); if(tmp!=""){ goto startMoving; } tmp = pathFind(cUnit->cell->iX,cUnit->cell->jY,OP->op[tmpCount]->iX-1,OP->op[tmpCount]->jY+1,self); if(tmp!=""){ goto startMoving; } tmp = pathFind(cUnit->cell->iX,cUnit->cell->jY,OP->op[tmpCount]->iX-1,OP->op[tmpCount]->jY,self); if(tmp!=""){ goto startMoving; } tmp = pathFind(cUnit->cell->iX,cUnit->cell->jY,OP->op[tmpCount]->iX,OP->op[tmpCount]->jY-1,self); if(tmp!=""){ goto startMoving; } tmp = pathFind(cUnit->cell->iX,cUnit->cell->jY,OP->op[tmpCount]->iX-1,OP->op[tmpCount]->jY-1,self); if(tmp!=""){ goto startMoving; } return 0; startMoving:; int tmpCP; int tmpInt = tmp[0] - 48; if(tmpInt==0||tmpInt==2||tmpInt==4||tmpInt==6){ tmpCP=-1; }else{ tmpCP=-2; } if(cUnit->cell->unit->cPoints+tmpCP>=0){ cUnit->cell->unit->cPoints+=tmpCP; //cUnit->cell->unit->direction=tmpInt; cUnit->cell->unit->direction = tmpInt; /* *Start move! */ int tmpX = cUnit->cell->iX; int tmpY = cUnit->cell->jY; self->cell[tmpX][tmpY].obj_un_null=0; int tmpCX = cUnit->cell->X; int tmpCY = cUnit->cell->Y; sf::Texture tmpT; sf::Sprite tmpS; int tX = cUnit->cell->iX; int tY = cUnit->cell->jY; tmpT.loadFromFile(cUnit->cell->unit->sprites.path[cUnit->cell->unit->direction]); tmpS.setTexture(tmpT); switch(tmpInt){ case 0: tX+=1; break; case 1: tX+=1; tY+=1; break; case 2: tY+=1; break; case 3: tX-=1; tY+=1; break; case 4: tX-=1; break; case 5: tX-=1; tY-=1; break; case 6: tY-=1; break; case 7: tY-=1; tX+=1; break; } for(int a = 0 ; a<10;a++){ switch(tmpInt){ case 0: tmpCX+=10; break; case 1: tmpCX+=10; tmpCY+=10; break; case 2: tmpCY+=10; break; case 3: tmpCX-=10; tmpCY+=10; break; case 4: tmpCX-=10; break; case 5: tmpCX-=10; tmpCY-=10; break; case 6: tmpCY-=10; break; case 7: tmpCY-=10; tmpCX+=10; break; } Sleep(20); window.clear(sf::Color::Black); window.draw(gameBackground); drawUnits(self,window); /* window.draw(gameInterface); window.draw(gameMenu); drawMinMap(window,player,self); window.draw(gameEndTurn); drawPlayer(window,player,pl);*/ tmpS.setPosition(tmpCX,tmpCY); window.draw(tmpS); window.draw(gameInterface); window.draw(gameMenu); drawMinMap(window,player,self); window.draw(gameEndTurn); drawPlayer(window,player,pl); window.draw(cTc); window.draw(cBc); window.display(); } self->cell[tX][tY].unit = self->cell[tmpX][tmpY].unit; self->cell[tX][tY].obj_un_null=1; cUnit->cell = &self->cell[tX][tY]; cUnit->status = 1; int TEST = cUnit->cell->unit->cPoints; self->cell[tmpX][tmpY].unit = NULL; window.clear(sf::Color::Black); window.draw(gameBackground); drawUnits(self,window); /* window.draw(gameInterface); window.draw(gameMenu); drawMinMap(window,player,self); window.draw(gameEndTurn); drawPlayer(window,player,pl);*/ tmpS.setPosition(tmpCX,tmpCY); window.draw(tmpS); window.draw(gameInterface); window.draw(gameMenu); drawMinMap(window,player,self); window.draw(gameEndTurn); drawPlayer(window,player,pl); window.draw(cTc); window.draw(cBc); window.display(); return 1; } return 0; }
void createUnit(gameMap_t * self, player_t * player, int cPlayer, int type, sf::RenderWindow & window, selection_t * cUnit, sf::Sprite & gameBackground, sf::Sprite & gameInterface, sf::Sprite & gameMenu, sf::Sprite & gameEndTurn, sf::Sprite & cTc, sf::Sprite & cBc){ if(cPlayer == 0){ for(int i = 9;i<16;i++){ if(self->cell[i][0].unit==NULL&&self->cell[i][0].obj_un_null==0){ if(type == 3){ self->cell[i][0].unit = newTank(cPlayer);} if(type == 4){ self->cell[i][0].unit = newBuggy(cPlayer);} if(player->resourcesPlayer1<self->cell[i][0].unit->cost){ deleteUnit(self->cell[i][0].unit); self->cell[i][0].unit = NULL; self->cell[i][0].obj_un_null=0; return; } player->resourcesPlayer1-=self->cell[i][0].unit->cost; sf::Texture tmpT; sf::Sprite tmpS; tmpT.loadFromFile(self->cell[i][0].unit->sprites.path[self->cell[i][0].unit->direction]); tmpS.setTexture(tmpT); int tmpX = self->cell[i][0].X; int tmpY = self->displacementY; for(int j = 0;j<60;j++){ tmpY+=5; tmpS.setPosition(tmpX,tmpY); window.clear(sf::Color::Black); window.draw(gameBackground); drawUnits(self,window); window.draw(tmpS); window.draw(gameInterface); window.draw(gameMenu); drawMinMap(window,cPlayer,self); window.draw(gameEndTurn); drawPlayer(window,cPlayer,player); window.draw(cTc); window.draw(cBc); window.display(); } self->cell[i][0].obj_un_null=1; return; } } return; } if(cPlayer == 1){ for(int i = 27;i<34;i++){ if(self->cell[i][18].unit==NULL&&self->cell[i][18].obj_un_null==0){ if(type == 3){ self->cell[i][18].unit = newTank(cPlayer);} if(type == 4){ self->cell[i][18].unit = newBuggy(cPlayer);} if(player->resourcesPlayer2 < self->cell[i][18].unit->cost){ deleteUnit(self->cell[i][0].unit); self->cell[i][0].unit = NULL; self->cell[i][0].obj_un_null=0; return; } player->resourcesPlayer2-=self->cell[i][18].unit->cost; sf::Texture tmpT; sf::Sprite tmpS; tmpT.loadFromFile(self->cell[i][18].unit->sprites.path[self->cell[i][18].unit->direction]); tmpS.setTexture(tmpT); int tmpX = self->cell[i][18].X; int tmpY = self->displacementY; tmpY+=map_height; for(int j = 0;j<80;j++){ tmpY-=5; tmpS.setPosition(tmpX,tmpY); window.clear(sf::Color::Black); window.draw(gameBackground); drawUnits(self,window); window.draw(tmpS); window.draw(gameInterface); window.draw(gameMenu); drawMinMap(window,cPlayer,self); window.draw(gameEndTurn); drawPlayer(window,cPlayer,player); window.draw(cTc); window.draw(cBc); window.display(); } self->cell[i][18].obj_un_null=1; return; } } return; } }
void findWay(gameMap_t * self, sf::RenderWindow & window, selection_t * cUnit, sf::Sprite & aCell, sf::Sprite & aEnemy, cursor_t * gCur, sf::Sprite & gameBackground, sf::Sprite & gameInterface, sf::Sprite & gameMenu, sf::Sprite & gameEndTurn, int player, sf::Sprite & cTc, player_t*pl, sf::Sprite & cBc){ if(cUnit->status==0){ return; } for(int i = 0;i<cellNumX;i++){ for(int j = 0;j<cellNumY;j++){ int added = 0; if (cUnit->cell!=NULL&&(float)sqrt((cUnit->cell->iX-i)*(cUnit->cell->iX-i)+(cUnit->cell->jY-j)*(cUnit->cell->jY-j)) <= (float)(cUnit->cell->unit->cPoints) || (float)sqrt((cUnit->cell->iX-i)*(cUnit->cell->iX-i)+(cUnit->cell->jY-j)*(cUnit->cell->jY-j)) <= (float)(cUnit->cell->unit->aRange)) { std::string tmp; int tmpSt = self->cell[i][j].obj_un_null; if(self->cell[i][j].unit!=NULL && self->cell[i][j].unit->player != cUnit->cell->unit->player && self->cell[i][j].obj_un_null == 1) { self->cell[i][j].obj_un_null = 0; tmpSt = 1; } tmp = pathFind(cUnit->cell->iX,cUnit->cell->jY,i,j,self); if(tmp!="" && calculateLength(tmp)<=cUnit->cell->unit->cPoints){ aCell.setPosition(self->cell[i][j].X,self->cell[i][j].Y); window.draw(aCell); if(gCur->status==1&&gCur->cell->iX == i &&gCur->cell->jY == j && tmp!=""&& self->cell[gCur->cell->iX][gCur->cell->jY].unit == NULL){ if (sf::Mouse::isButtonPressed(sf::Mouse::Left)){ cUnit->cell->unit->cPoints-=calculateLength(tmp); int tmpInt = tmp[0] - 48; cUnit->cell->unit->direction=tmpInt; int tmpX = 0, tmpY = 0; cUnit->cell->unit->direction = tmpInt; tmpX = cUnit->cell->iX; tmpY = cUnit->cell->jY; self->cell[tmpX][tmpY].obj_un_null=0; int tmpCX = cUnit->cell->X; int tmpCY = cUnit->cell->Y; for(int l = 0;l<tmp.length();l++){ int tmpD = tmp[l] - 48; cUnit->cell->unit->direction = tmpD; sf::Texture tmpT; sf::Sprite tmpS; tmpT.loadFromFile(cUnit->cell->unit->sprites.path[cUnit->cell->unit->direction]); tmpS.setTexture(tmpT); for(int a = 0 ; a<10;a++){ switch(tmpD){ case 0: tmpCX+=10; break; case 1: tmpCX+=10; tmpCY+=10; break; case 2: tmpCY+=10; break; case 3: tmpCX-=10; tmpCY+=10; break; case 4: tmpCX-=10; break; case 5: tmpCX-=10; tmpCY-=10; break; case 6: tmpCY-=10; break; case 7: tmpCY-=10; tmpCX+=10; break; } Sleep(20); window.clear(sf::Color::Black); window.draw(gameBackground); drawUnits(self,window); /* window.draw(gameInterface); window.draw(gameMenu); drawMinMap(window,player,self); window.draw(gameEndTurn); drawPlayer(window,player,pl);*/ tmpS.setPosition(tmpCX,tmpCY); window.draw(tmpS); window.draw(gameInterface); window.draw(gameMenu); drawMinMap(window,player,self); window.draw(gameEndTurn); drawPlayer(window,player,pl); window.draw(cTc); window.draw(cBc); pData(window,cUnit); window.display(); } } self->cell[gCur->cell->iX][gCur->cell->jY].unit = cUnit->cell->unit; self->cell[gCur->cell->iX][gCur->cell->jY].obj_un_null=1; added = 1; setSelect(&self->cell[gCur->cell->iX][gCur->cell->jY],cUnit); self->cell[tmpX][tmpY].unit = NULL; } } } if(tmpSt == 1 && tmp!="" && calculateLength(tmp)<=cUnit->cell->unit->aRange&&cUnit->cell->unit->cPoints>0){ aEnemy.setPosition(self->cell[i][j].X,self->cell[i][j].Y); window.draw(aEnemy); if(gCur->status==1&&gCur->cell->iX == i &&gCur->cell->jY == j&& self->cell[gCur->cell->iX][gCur->cell->jY].unit != NULL && cUnit->cell->unit->player!=self->cell[i][j].unit->player){ if (sf::Mouse::isButtonPressed(sf::Mouse::Left)){ if(added!=1){ self->cell[i][j].obj_un_null = tmpSt; } int tmpD = tmp[0] - 48; cUnit->cell->unit->direction = tmpD; window.clear(sf::Color::Black); window.draw(gameBackground); drawUnits(self,window); sf::Texture tmpT; sf::Sprite tmpS; tmpT.loadFromFile(self->cell[i][j].unit->sprites.path[10]); tmpS.setTexture(tmpT); tmpS.setPosition(self->cell[i][j].X + rand()%50+20,self->cell[i][j].Y + rand()%50+20); window.draw(tmpS); window.draw(gameInterface); window.draw(gameMenu); drawMinMap(window,player,self); window.draw(gameEndTurn); drawPlayer(window,player,pl); pData(window,cUnit); sf::Texture tmpT1; sf::Sprite tmpS1; tmpT1.loadFromFile(self->cell[i][j].unit->sprites.path[11+cUnit->cell->unit->direction]); tmpS1.setTexture(tmpT1); tmpS1.setPosition(cUnit->cell->X,cUnit->cell->Y); window.draw(tmpS1); window.display(); Sleep(400); cUnit->cell->unit->cPoints-=1; int tmpDmg = cUnit->cell->unit->dmg - self->cell[i][j].unit->armor; if(tmpDmg<0){tmpDmg=0;} self->cell[i][j].unit->hp-=tmpDmg; if(self->cell[i][j].unit->hp<=0){ sf::Texture tmpT; sf::Sprite tmpS; tmpT.loadFromFile(self->cell[i][j].unit->sprites.path[8]); tmpS.setTexture(tmpT); tmpS.setPosition(self->cell[i][j].X,self->cell[i][j].Y); window.clear(sf::Color::Black); window.draw(gameBackground); drawUnits(self,window); window.draw(gameInterface); window.draw(gameMenu); drawMinMap(window,player,self); window.draw(gameEndTurn); drawPlayer(window,player,pl); pData(window,cUnit); window.draw(cBc); window.draw(tmpS); window.display(); Sleep(400); deleteUnit(self->cell[i][j].unit); self->cell[i][j].unit = NULL; self->cell[i][j].obj_un_null = 0; return; } } } } if(added!=1){ self->cell[i][j].obj_un_null = tmpSt; } } } } }
void gameClient(sf::RenderWindow & window,char * mapName){ int i,/*displacementX=0,displacementY=0,*/ menu=0; gameMap_t map; // int redrawMMAP = 1; cursor_t gCur; gCur.status = 0; gCur.cell = NULL; player_t players; players.resourcesPlayer1 = 400; players.resourcesPlayer2 = 400; // player_t player2; unsigned int currentPlayerTurn=0; selection_t select; select.status=0; select.cell=NULL; createMap(&map); /* Set textures. */ sf::Texture background, interface_image,menu1,menu2,grind,cursor,pCourse,endTurn1,endTurn2,sel,enemy,fpT,spT,cT1,cT2,cB1,cB2; sf::Sprite gameBackground,gameInterface,gameMenu,gameGrind,gameCursor,aCell,gameEndTurn,cSel,cEnemy,cpT,cTc,cBc; menu1.loadFromFile("gameInterface/menu.png"); fpT.loadFromFile("gameInterface/fpTurn.png"); spT.loadFromFile("gameInterface/spTurn.png"); enemy.loadFromFile("gameInterface/enemyCell.png"); sel.loadFromFile("gameInterface/selected.png"); menu2.loadFromFile("gameInterface/menuConfirmed.png"); grind.loadFromFile("maps/grind.png"); endTurn1.loadFromFile("gameInterface/endTurn.png"); endTurn2.loadFromFile("gameInterface/endTurnConfirmed.png"); cT1.loadFromFile("gameInterface/cTank.png"); cT2.loadFromFile("gameInterface/cTankC.png"); cB1.loadFromFile("gameInterface/cBuggy.png"); cB2.loadFromFile("gameInterface/cBuggyC.png"); //test addUnit(&map,window,0,TANK,15,0); addUnit(&map,window,0,BUGGY,12,0); addUnit(&map,window,0,TANK,9,0); addUnit(&map,window,1,TANK,27,18); addUnit(&map,window,1,BUGGY,30,18); addUnit(&map,window,1,TANK,33,18); addObject(&map,window,0,20,12); addObject(&map,window,0,10,10); addObject(&map,window,0,30,8); cpT.setPosition(130,0); cursor.loadFromFile("gameInterface/setCell.png"); pCourse.loadFromFile("gameInterface/availableCell.png"); background.loadFromFile(mapName); interface_image.loadFromFile("gameInterface/mainInterface.png"); gameBackground.setTexture(background); cSel.setTexture(sel); aCell.setTexture(pCourse); gameGrind.setTexture(grind); gameInterface.setTexture(interface_image); cEnemy.setTexture(enemy); gameCursor.setTexture(cursor); drawMinMap(window,currentPlayerTurn,&map); while (window.isOpen()){ cameraMouseMove(window,&map); mouseEvents(window,&map); menu=gameSelection(window,gameMenu,menu1,menu2,gameEndTurn,endTurn1,endTurn2,cTc,cT1,cT2,cBc,cB1,cB2); gameBackground.setPosition(map.displacementX,map.displacementY); gameInterface.setPosition(-1,-1); gameMenu.setPosition(1700,0); gameEndTurn.setPosition(1500,5); cTc.setPosition(1680,750); cBc.setPosition(1680,890); selectUnit(&map,window,cSel,&select,currentPlayerTurn); if(select.status==1){ cSel.setPosition(select.cell->X,select.cell->Y); } sf::Event event; if (sf::Mouse::isButtonPressed(sf::Mouse::Left)&&menu==1){ if(pauseMenu(window)==0){ break; } } if (sf::Mouse::isButtonPressed(sf::Mouse::Left)&&menu>=3){ createUnit(&map,&players,currentPlayerTurn,menu,window,&select,gameBackground,gameInterface,gameMenu,gameEndTurn,cTc,cBc); } if (sf::Mouse::isButtonPressed(sf::Mouse::Left)&&menu==2){ isEnd(&map,window,endFn); getOP(&map,&players); getResources(&map,currentPlayerTurn,&players); deleteSelect(&select); overmind(&map,window,&select,aCell,cEnemy,&gCur,gameBackground,gameInterface,gameMenu,gameEndTurn,currentPlayerTurn,cTc,&players,cBc); endTurn(&map); Sleep(500); } if (sf::Mouse::isButtonPressed(sf::Mouse::Right)){ deleteSelect(&select); } while (window.pollEvent(event)) { if (event.type == sf::Event::Closed) { window.close(); } } window.clear(sf::Color::Black); window.draw(gameBackground); drawUnits(&map,window); if(cursorConfirm(window,&map,gameCursor,&gCur)==1){ window.draw(gameCursor); } if(select.status==1){ window.draw(cSel); findWay(&map,window,&select,aCell,cEnemy,&gCur,gameBackground,gameInterface,gameMenu,gameEndTurn,currentPlayerTurn,cTc,&players,cBc); } window.draw(gameInterface); if(select.status==1){ pData(window,&select); } window.draw(gameMenu); window.draw(gameEndTurn); drawMinMap(window,currentPlayerTurn,&map); drawPlayer(window,currentPlayerTurn,&players); window.draw(cTc); window.draw(cBc); window.display(); } }