Esempio n. 1
0
void FlagManager::RenderFlagMenu( SDL_Surface *surface )
{
    if ( selection < 0 )
        selection = 0;
    if ( selection > flagsList.size() - 1 )
        selection = flagsList.size() - 1;

    Sint16 xVerts[3] = { 10, 50, 50 };
    Sint16 yVerts[3] = { SCREEN_HEIGHT/2, SCREEN_HEIGHT/2 + 25, SCREEN_HEIGHT/2 - 25 };
    filledPolygonRGBA( surface, xVerts, yVerts, 3, 0, 0, 0, 255 );

    Sint16 xVerts2[3] = { SCREEN_WIDTH - 10, SCREEN_WIDTH - 50, SCREEN_WIDTH - 50 };
    Sint16 yVerts2[3] = { SCREEN_HEIGHT/2,SCREEN_HEIGHT/2 + 25, SCREEN_HEIGHT/2- 25 };
    filledPolygonRGBA( surface, xVerts2, yVerts2, 3, 0, 0, 0, 255 );
}
Esempio n. 2
0
//dessiner_piece
void dessiner_piece(Piece* piece){
	Sint16 xs[4],ys[4];
	int i=0,color[3],opacity=255;
	i=0;
	Point* point=piece->forme->points;
	while(point!=NULL){
		xs[i]=point->x;
		ys[i]=point->y;
		i++;
		point=point->suivant;
	}
	switch(piece->id){
		case 1:color[0]=88;color[1]=145;color[2]=225;break;
		case 2:color[0]=200;color[1]=25;color[2]=0;break;
		case 3:color[0]=150;color[1]=160;color[2]=0;break;
		case 4:color[0]=251;color[1]=144;color[2]=18;break;
		case 5:color[0]=118;color[1]=204;color[2]=66;break;
		case 6:color[0]=71;color[1]=117;color[2]=182;break;
		case 7:color[0]=255;color[1]=60;color[2]=100;break;
		}
	if(piece==piece_mobile){opacity=85;}
	filledPolygonRGBA(_ecran,xs,ys,i,color[0],color[1],color[2],opacity);
	aapolygonRGBA(_ecran,xs,ys,i,color[0],color[1],color[2],255);
	//SDL_Flip(_ecran);

}
Esempio n. 3
0
void ImportBinary(void)
{
	// Import the Polygon list from a binary file
	std::fstream Input("SaveFile.tie", std::ios_base::binary | std::ios_base::in);
	if (Input.bad())		return;
	if (!Input.good())		return;
	for (unsigned int i = 0; i < POLYGON_COUNT; i++) Input.read((char*)&PolygonList[i], sizeof(Poly));
	Input.close();

	// Clear the Evolve surface and allow a new fitness to be calculated
	ClearSurface(Evolve);
	Fitness = 0.0;
	
	printf("\n\n\nTriangle List Imported!");

	// Normally after this occurs, a single mutation would be set and the resulting fitness would be higher than
	// what is was before importing. To prevent this, calculate the fitness before returning to the loop
	
	// Draw the Evolve Image
	ClearSurface(Evolve);
	for (unsigned int i = 0; i < POLYGON_COUNT; i++)
		if (PolygonList[i].BitFlag & DEFINED_BIT)
			filledPolygonRGBA(Evolve, PolygonList[i].X, PolygonList[i].Y, VERTEX_COUNT, PolygonList[i].Color[0], PolygonList[i].Color[1], PolygonList[i].Color[2], PolygonList[i].Color[3]);

	Fitness = CalculateFitness();
	memcpy((void*)((Uint32*)Best->pixels), (void*)((Uint32*)Evolve->pixels), Evolve->pitch * Evolve->h);

	GoodMutations = 0;
	Mutations = 0;
	Attempts = 0;
	OpeningTick = SDL_GetTicks();
	OutputInformation(Fitness, GoodMutations, Mutations, Attempts, 0.0);
}
Esempio n. 4
0
/* Interface to SDL_gfx version for drawing polygon  */
int Surface::DrawPolygon(Sint16 x[], Sint16 y[], int n, int color, int fill) {
  int red = (color >> 16) & 0xff;
  int green = (color >> 4) & 0xff;
  int blue = color & 0xff;
  if (fill)
    filledPolygonRGBA(surf, x, y, n, red, green, blue, 255);
  else
    polygonRGBA(surf, x, y, n, red, green, blue, 255);
  return 0;
}
Esempio n. 5
0
void Draw_Building(way* w, char* role, RGBA* color, char* type)
{
	Sint16 *vx, *vy;
	RGBA rgba;
	node_t* node = NULL;
	double longitude, latitude, minlat, maxlat, minlon, maxlon;
	int i, j, k, index, compteur, value_tag;
	static int policy = 0;
	
	maxlat = pBound->maxlat;
	minlat = pBound->minlat;
	maxlon = pBound->maxlon;
	minlon = pBound->minlon;
	
	vx = malloc(w->size_ref * sizeof(*vx));
	vy = malloc(w->size_ref * sizeof(*vy));
	compteur = 0;

	for(i = 0; i < w->size_ref; i++)
	{
		index = search_node_dicho(w->ref[i]);
	
		if(index == FAILURE)
			continue;
		
		node = pRoot->arrayNodes[index];
		
		longitude = node->longitude;
		latitude = node->latitude;

		vx[i] = (Sint16)(long_to_pix(longitude) * pMap->width * pMap->zoom);
		vy[i] = (Sint16)(lat_to_pix(latitude) * pMap->height * pMap->zoom);

		compteur++;
	}
	
	if(type != NULL && !strcmp(type, "barrier"))
	{
		for(i = 0; i < compteur - 1; i++)
     	 	aalineRGBA(pRenderer, vx[i], vy[i], vx[i+1], vy[i+1], color->r, color->g, color->b, color->a);
	}
	else
	{
		filledPolygonRGBA(pRenderer, vx, vy, compteur, color->r, color->g, color->b, color->a);
	
		if(role == NULL)
		{
			rgba = colorConverter(BARRIER_COLOR);
			for(i = 0; i < compteur - 1; i++)
		 	 	aalineRGBA(pRenderer, vx[i], vy[i], vx[i+1], vy[i+1], rgba.r, rgba.g, rgba.b, rgba.a);
		}
    }	 	
	free(vx);
	free(vy);
}
Esempio n. 6
0
void Draw_Highway(way* w, char* role, RGBA* color, int length, char* type)
{
	Sint16 *vx, *vy;
	Sint16 mx1, my1, mx2, my2;
	RGBA rgba;
	node_t* node = NULL;
	double longitude, latitude, minlat, maxlat, minlon, maxlon, offset = 0;
	double alpha, num, distance, decimal_part;
	int i, j, index, compteur = 0;
	bool visible;
	
	maxlat = pBound->maxlat;
	minlat = pBound->minlat;
	maxlon = pBound->maxlon;
	minlon = pBound->minlon;
	
	vx = malloc(w->size_ref * sizeof(*vx));
	vy = malloc(w->size_ref * sizeof(*vy));
	
	for(i = 0; i < w->size_ref; i++)
	{
		index = search_node_dicho(w->ref[i]);
	
		if(index == FAILURE)
			continue;
		
		node = pRoot->arrayNodes[index];
		
		longitude = node->longitude;
		latitude = node->latitude;

		vx[i] = (Sint16)(long_to_pix(longitude) * pMap->width * pMap->zoom);
		vy[i] = (Sint16)(lat_to_pix(latitude) * pMap->height * pMap->zoom);

		compteur++;
	}
	
	if(type != NULL && !strcmp(type, "pedestrian"))
	{
		rgba = colorConverter(PEDESTRIAN_FILL_COLOR);
		filledPolygonRGBA(pRenderer, vx, vy, compteur, rgba.r, rgba.g, rgba.b, rgba.a);
		//rgba = colorConverter(PEDESTRIAN_CONTOUR_COLOR);
		for(i = 0; i < compteur - 1; i++)
			thickLineRGBA(pRenderer, vx[i], vy[i], vx[i+1], vy[i+1], length, rgba.r, rgba.g, rgba.b, rgba.a);
	}
	else
		for(i = 0; i < compteur - 1; i++)
			thickLineRGBA(pRenderer, vx[i], vy[i], vx[i + 1], vy[i + 1], length, color->r, color->g, color->b, color->a);
	
	free(vx);
	free(vy);
}
Esempio n. 7
0
//dessiner silhouette
void dessiner_silhouette(SDL_Surface* sur,Forme* sil){

	Forme* forme=sil;
	while(forme!=NULL){
			Sint16 xs[40],ys[40];
			int i=0,color[3],opacity=50;
			i=0;
			Point* point=forme->points;
			while(point!=NULL){
				xs[i]=point->x;
				ys[i]=point->y;
				i++;
				point=point->suivant;
			}
			color[0]=255;color[1]=255;color[2]=255;
			aapolygonRGBA(_ecran,xs,ys,i,color[0],color[1],color[2],255);
			filledPolygonRGBA(_ecran,xs,ys,i,color[0],color[1],color[2],opacity);

				if(forme->formes_vides!=NULL){
					Forme* fv=forme->formes_vides;
					while(fv!=NULL){
							i=0;
							Point* pointv=fv->points;
							while(pointv!=NULL){
								xs[i]=pointv->x;
								ys[i]=pointv->y;
								i++;
								pointv=pointv->suivant;
							}
							color[0]=255;color[1]=255;color[2]=255;
							filledPolygonRGBA(_ecran,xs,ys,i,0,0,0,200);
							aapolygonRGBA(_ecran,xs,ys,i,color[0],color[1],color[2],255);
							
							fv=fv->suivant;
					}
				}
				forme=forme->suivant;
	}
}
Esempio n. 8
0
void ClearSurface(SDL_Surface* Surface, Uint8 R, Uint8 G, Uint8 B, Uint8 A)
{
	Sint16 X[4];
	Sint16 Y[4];
	X[0] = 0;
	Y[0] = 0;
	X[1] = Surface->w;
	Y[1] = 0;
	X[2] = Surface->w;
	Y[2] = Surface->h;
	X[3] = 0;
	Y[3] = Surface->h;
	filledPolygonRGBA(Surface, X, Y, 4, R, G, B, A);
}
Esempio n. 9
0
void jhi_draw_fill_polygon(JHI_Point2d *points, int n, JHI_Color color, Uint8 alpha)
{
	Sint16 x[n];
	Sint16 y[n];
	int i;
	for (i = 0; i < n; i++)
	{
		x[i] = points[i].x;
		y[i] = points[i].y;
	}

	filledPolygonRGBA(jhi_get_window_screen(), x, y, n, colors[color].r,
			colors[color].g, colors[color].b, alpha);

}
Esempio n. 10
0
void SDLDebugDraw::DrawSolidPolygon(const b2Vec2 *vertices, int32 vertexCount, const b2Color &color) {
    Sint16 x[vertexCount];
    Sint16 y[vertexCount];
    for(int i = 0; i < vertexCount; ++i){
        b2Vec2 v = vertices[i]; //((vertices[i] + camera.wpos)*camera.getScale()) ;
        v *= camera;
        
        x[i] = (Sint16) v.x;
        y[i] = (Sint16) v.y;
    }

    filledPolygonRGBA (App::get()->ren->renderer, x, y, vertexCount, color.r, color.g, color.b, color.a);


    polygonRGBA (App::get()->ren->renderer, x, y, vertexCount, 255,255,255,255);
}
Esempio n. 11
0
void Draw_Natural(way* w, char* role, RGBA* color, char* type)
{
	Sint16 *vx, *vy;
	node_t* node = NULL;
	double longitude, latitude, minlat, maxlat, minlon, maxlon;
	int i, index, compteur = 0;
	
	maxlat = pBound->maxlat;
	minlat = pBound->minlat;
	maxlon = pBound->maxlon;
	minlon = pBound->minlon;
	
	vx = malloc(w->size_ref * sizeof(*vx));
	vy = malloc(w->size_ref * sizeof(*vy));

	for(i = 0; i < w->size_ref; i++)
	{
		index = search_node_dicho(w->ref[i]);
	
		if(index == FAILURE)
			continue;
		
		node = pRoot->arrayNodes[index];
		
		longitude = node->longitude;
		latitude = node->latitude;

		vx[i] = (Sint16)(long_to_pix(longitude) * pMap->width * pMap->zoom);
		vy[i] = (Sint16)(lat_to_pix(latitude) * pMap->height * pMap->zoom);

		compteur++;
	}

	if(type != NULL)
		if(!strcmp(type, "cliff"))
			for(i = 0; i < compteur - 1; i++)
				thickLineRGBA(pRenderer, vx[i], vy[i], vx[i + 1], vy[i + 1], CLIFF_LENGTH, color->r, color->g, color->b, color->a);
		else
			if(!strcmp(type, "coastline"))
				for(i = 0; i < compteur - 1; i++)
					aalineRGBA(pRenderer, vx[i], vy[i], vx[i + 1], vy[i + 1], color->r, color->g, color->b, color->a);
	else
		filledPolygonRGBA(pRenderer, vx, vy, compteur, color->r, color->g, color->b, color->a);
		
	free(vx);
	free(vy);
}
Esempio n. 12
0
void Renderer::drawPolygon(const b2Vec2* vertices, int32 vertexCount, Uint8 red, Uint8 green, Uint8 blue, Uint8 alpha, bool filled){
	std::vector<short> x(vertexCount);
	std::vector<short> y(vertexCount);

	for(int i=0;i<vertexCount;i++){
		b2Vec2 vec = toScreenCoords(vertices[i]);

		x[i] = (short) vec.x;
		y[i] = (short) vec.y;
	}

	if(filled){
		filledPolygonRGBA(renderer, x.data(), y.data(), vertexCount, red, green, blue, alpha);
	}else{
		polygonRGBA(renderer, x.data(), y.data(), vertexCount, red, green, blue, alpha);
	}
}
Esempio n. 13
0
void Draw_Leisure(way* w, char* role, RGBA* color, char* type)
{
	Sint16 *vx, *vy;
	RGBA rgba;
	node_t* node = NULL;
	double longitude, latitude, minlat, maxlat, minlon, maxlon;
	int i, index, compteur = 0;
	
	maxlat = pBound->maxlat;
	minlat = pBound->minlat;
	maxlon = pBound->maxlon;
	minlon = pBound->minlon;
	
	vx = malloc(w->size_ref * sizeof(*vx));
	vy = malloc(w->size_ref * sizeof(*vy));

	for(i = 0; i < w->size_ref; i++)
	{
		index = search_node_dicho(w->ref[i]);
	
		if(index == FAILURE)
			continue;
		
		node = pRoot->arrayNodes[index];
		
		longitude = node->longitude;
		latitude = node->latitude;

		vx[i] = (Sint16)(long_to_pix(longitude) * pMap->width * pMap->zoom);
		vy[i] = (Sint16)(lat_to_pix(latitude) * pMap->height * pMap->zoom);

		compteur++;
	}

	if(!strcmp(type, "garden"))
	{
		rgba = colorConverter(WHITE);
		for(i = 0; i < compteur - 1; i++)
			thickLineRGBA (pRenderer, vx[i], vy[i], vx[i+1], vy[i+1], 2, rgba.r, rgba.g, rgba.b, rgba.a);
	}
	else
		filledPolygonRGBA(pRenderer, vx, vy, compteur, color->r, color->g, color->b, color->a);
		
	free(vx);
	free(vy);
}
Esempio n. 14
0
void filledPolygon(void* s_in, int* xs, int* ys, int n, int r, int g, int b, int a)
{
    SDL_Renderer* s = (SDL_Renderer*)s_in;
    short u[n];
    short v[n];
    for (int i = 0; i < n ; i++) {
      //printf("(%i , %i  )", xs[i], ys[i]);
      u[i] = xs[i];
      v[i] = ys[i];
    }
    free(xs);
    free(ys);
    filledPolygonRGBA(s,
		      u, v,
		      n,
		      r, g, b, a);

}
Esempio n. 15
0
//actualiser_ecran
void actualiser_ecran(){

	SDL_Rect bg_pos={0,0};
	SDL_BlitSurface(bg_surface, NULL,_ecran, &bg_pos);
	if(!mode_devel) dessiner_silhouette(bg_surface,silh);
	//table?
	if(dans_table){
		Sint16 ws[4];Sint16 hs[4];
		ws[0]=0;hs[0]=0;
		ws[1]=TABLE_WIDTH;hs[1]=0;
		ws[2]=TABLE_WIDTH;hs[2]=HEIGHT-1;
		ws[3]=0;hs[3]=HEIGHT-1;
		filledPolygonRGBA(_ecran,ws,hs,4,255,255,255,25);
		
	}
	//table?
	dessiner_pieces();
	//
	SDL_Flip(_ecran);
}
Esempio n. 16
0
void EndSlopeTile::debugRender(SDL_Renderer *tgt, int x, int y, Camera const &cam) const {
	nnb::IntRect screenView = cam.getPixelViewi();
	
	Eigen::Vector2i pts[4];

	pts[0] << x * TILE_SIZE - screenView.x, y * TILE_SIZE - screenView.y;
	pts[1] << pts[0][0] + TILE_SIZE, pts[0][1];

	int deltaY = TILE_SIZE - TILE_SIZE / (float) order;

	switch (dir) {
		case nnb::Dir2::LEFT:
			pts[2] << pts[1][0], pts[1][1] + deltaY;
			pts[3] << pts[0][0], pts[0][1] + TILE_SIZE;
			break;
		case nnb::Dir2::RIGHT:
			pts[2] << pts[1][0], pts[1][1] + TILE_SIZE;
			pts[3] << pts[0][0], pts[0][1] + deltaY;
			break;
		default:
			pts[2] << pts[1][0], pts[1][1] + 1;
			pts[3] << pts[0][0], pts[0][1] + 2;
			NNB_LOG << "ERROR, DEFAULT CASE SHOULD NOT BE TRIGGERED. SHITBONKERS";
			break;
	}

	Sint16 vx[4];
	Sint16 vy[4];

	// Makes everything orientated correctly, since the whole coördinate system
	// expects (0; 0) to be in the bottom left but SDL screen expects (0; 0) to
	// be in the top left - thus we must FLIP
	// Oh, and we also convert those Vector2f[] to two int[]
	for (int i = 0; i < 4; i++) {
		pts[i][1] = SCR_H - pts[i][1];
		vx[i] = pts[i][0];
		vy[i] = pts[i][1];
	}
	
	filledPolygonRGBA(tgt, vx, vy, 4, 0, 0, 0, 255);
}
Esempio n. 17
0
void CPhysicsDebugDraw::DrawSolidPolygon(const b2Vec2* vertices, int32 vertexCount, const b2Color& color)
{

	
	Sint16 *PX = new Sint16[vertexCount];
	Sint16 *PY = new Sint16[vertexCount];
	for (int32 i = 0; i < vertexCount; i++)
		{
            Sint16 toto;
            toto = (Sint16) (vertices[i].x * C_RATIO);
            PX[i] = toto;
            toto = (Sint16) (vertices[i].y *C_RATIO);
            PY[i] = toto;
		//PY[i] = (Sint16) (C_LOGICAL_SIZE_Y -vertices[i].y);
		}
	filledPolygonRGBA(g_app->sdlRenderer,PX,PY,vertexCount,(Uint8)(color.r * 255),(Uint8)(color.g * 255),(Uint8)(color.b * 255),255);
    
	delete []PX;
	delete []PY;

}
Esempio n. 18
0
void Draw_Landuse(way* w, char* role, RGBA* color, char* type)
{
	Sint16 *vx, *vy;
	node_t* node = NULL;
	double longitude, latitude, minlat, maxlat, minlon, maxlon;
	int i, index, compteur = 0;
	
	maxlat = pBound->maxlat;
	minlat = pBound->minlat;
	maxlon = pBound->maxlon;
	minlon = pBound->minlon;
	
	vx = malloc(w->size_ref * sizeof(*vx));
	vy = malloc(w->size_ref * sizeof(*vy));

	for(i = 0; i < w->size_ref; i++)
	{
		index = search_node_dicho(w->ref[i]);
	
		if(index == FAILURE)
			continue;
		
		node = pRoot->arrayNodes[index];
		
		longitude = node->longitude;
		latitude = node->latitude;

		vx[i] = (Sint16)(long_to_pix(longitude) * pMap->width * pMap->zoom);
		vy[i] = (Sint16)(lat_to_pix(latitude) * pMap->height * pMap->zoom);

		compteur++;
	}

	filledPolygonRGBA(pRenderer, vx, vy, compteur, color->r, color->g, color->b, color->a);
		
	free(vx);
	free(vy);
}
Esempio n. 19
0
double CalculateFitness(void)
{
	double			Return;
	//unsigned char	Pixel[2];

	// Draw the Evolve Image
	ClearSurface(Evolve);
	for (unsigned int i = 0; i < POLYGON_COUNT; i++)
		if (PolygonList[i].BitFlag & DEFINED_BIT)
			filledPolygonRGBA(Evolve, PolygonList[i].X, PolygonList[i].Y, VERTEX_COUNT, PolygonList[i].Color[0], PolygonList[i].Color[1], PolygonList[i].Color[2], PolygonList[i].Color[3]);

	// Look through the pixels of both surfaces and determine the fitness of the evolving surface
	Return = 0;
	for (int y = 0; y < Target->h; y++)
		for (int x = 0; x < Target->w; x++)
		{
			ComparisonColor evolve_color(((unsigned char*)Evolve->pixels)[y * Target->pitch + x * TargetPixelSize], ((unsigned char*)Evolve->pixels)[y * Target->pitch + x * TargetPixelSize + 1], ((unsigned char*)Evolve->pixels)[y * Target->pitch + x * TargetPixelSize + 2]);
			ComparisonColor target_color(((unsigned char*)Target->pixels)[y * Target->pitch + x * TargetPixelSize], ((unsigned char*)Target->pixels)[y * Target->pitch + x * TargetPixelSize + 1], ((unsigned char*)Target->pixels)[y * Target->pitch + x * TargetPixelSize + 2]);
			Return += CompareColors(evolve_color, target_color, false);
			//// Red
			//Pixel[0] = ((unsigned char*)Target->pixels)[y * Target->pitch + x * TargetPixelSize];
			//Pixel[1] = ((unsigned char*)Evolve->pixels)[y * Evolve->pitch + x * EvolvePixelSize];
			//Return += (255 - abs((int)(Pixel[0] - Pixel[1]))) / 255.0;
			//
			//// Green
			//Pixel[0] = ((unsigned char*)Target->pixels)[y * Target->pitch + x * TargetPixelSize + 1];
			//Pixel[1] = ((unsigned char*)Evolve->pixels)[y * Evolve->pitch + x * EvolvePixelSize + 1];
			//Return += (255 - abs((int)(Pixel[0] - Pixel[1]))) / 255.0;
			//
			//// Blue
			//Pixel[0] = ((unsigned char*)Target->pixels)[y * Target->pitch + x * TargetPixelSize + 2];
			//Pixel[1] = ((unsigned char*)Evolve->pixels)[y * Evolve->pitch + x * EvolvePixelSize + 2];
			//Return += (255 - abs((int)(Pixel[0] - Pixel[1]))) / 255.0;
		}

	Return = (Return / (double)(Target->w * Target->h * 3) * 100.0);
	return Return;
}
Esempio n. 20
0
void Renderer::fillPolygon(int16_t * vx, int16_t * vy, int n, const SDL_Color &color)
{
    filledPolygonRGBA(this->renderer, vx, vy, n, color.r, color.g, color.b, color.a);
}
Esempio n. 21
0
void fillWay(Way * way){
	if(map == NULL){
		fprintf(stderr,"La map est NULL dans line fonction fillWay\n");
		return;
	}
	if(way == NULL){
		fprintf(stderr,"Le way est NULL dans line fonction fillWay\n");
		return;
	}
	ListNode * l = way->listNd;
	if(l == NULL){
		fprintf(stderr,"Le way %ld a pas de noeud : line.c fonction fill way\n",way->id );
		return;
	}
	refListNode * current =l->firstRef;
	int nbre=0;
	if(way->size != 0){
		short coord_x [way->size];
		short coord_y [way->size];
		while(current != NULL){
			Node * currentNode = searchNode(map->avl,current->nd);
			if(currentNode != NULL){
				if(currentNode->c != NULL){
					coord_x[nbre] = miseAEchelleX(currentNode->c->x,map->bounds->max->x,windows_Width);
					coord_y[nbre] = miseAEchelleY(currentNode->c->y,map->bounds->max->y,windows_Height);
					nbre++;
				}
				else{
					fprintf(stderr,"le node %ld n'a pas de coordonnees\n",current->nd );
				}
				current = current->next;
			}
			else{
				fprintf(stderr,"Le node %ld n'est pas définis dans le fichier d'entree \n",current->nd );
			}
		}
		if(way->tag != NULL && way->tag->tagKey != NULL && way->tag->c != NULL){
			if(strcmp(way->tag->tagKey,"highway")==0){
				int draw = 1;
				int thick = 0;
				if(way->tag->thick != 0){
					thick = (way->tag->thick+modifThink);
					if(thick < 1){
						draw = zoomDrawHighway(way->tag->tagValue,modifThink);
						thick = 1;
					}
					thick *= zoom;
				}
				int i;
				int x = coord_x[0];
				int y = coord_y[0];
				if(draw == 1){
					for(i=0;i<way->size;i++){
						thickLineRGBA(renderer,x,y,coord_x[i],coord_y[i],thick,way->tag->c->red,way->tag->c->green,way->tag->c->blue,255);
						if(drawContour ==1){
							int diff = 100;
							thickLineRGBA(renderer,x+thick/2,y+thick/2,coord_x[i]+thick/2,coord_y[i]+thick/2,1,checkColor(way->tag->c->red-diff),checkColor(way->tag->c->green-diff),checkColor(way->tag->c->blue-diff),255);
							thickLineRGBA(renderer,x-thick/2,y-thick/2,coord_x[i]-thick/2,coord_y[i]-thick/2,1,checkColor(way->tag->c->red-diff),checkColor(way->tag->c->green-diff),checkColor(way->tag->c->blue-diff),255);
						}
						x = coord_x[i];
						y = coord_y[i];
					}

					//highway(way,coord_y,coord_x,thick);
					//nameHighway(way,l);
				}
			}

			else{
				if(drawContour == 1){
					polygonRGBA(renderer,coord_x,coord_y,way->size,139,71,137,255);
				}
				filledPolygonRGBA(renderer,coord_x,coord_y,way->size,way->tag->c->red,way->tag->c->green,way->tag->c->blue,255);
			}
		}
		else{
			filledPolygonRGBA(renderer,coord_x,coord_y,way->size,0,0,255,255);
		}
	}
}
Esempio n. 22
0
static void Draw_skill_icons (SDL_Surface *screen, struct character *player) {
    SDL_Rect rect= {350 * scale, (top ? 0 : (practise ? ky - (double)kx/1920 * 150 : ky - (double)kx/1920 * 90))
                    , skill_icons[0][0]->w, skill_icons[0][0]->h
                   };
    if(!top && kyBottom > rect.y - 10*scale)
        kyBottom = rect.y - 10*scale;
    int i,j;
    for(j=0; j < (practise ? 2 : 1); j++) {
        for(i=0; i<skill_num; i++) {
            if(j == 0)
                BlitSurface(skill_bg, NULL, screen, &rect);
            BlitSurface(skill_icons[j][i], NULL, screen, &rect);
            // A Cooldownok kirajzolása
            if(j == 0) {
                int time = GetTicks();
                int percent = 0;
                bool available = false;
                bool current = false;
                switch (i) {
                case skill_a_melee:
                    if(player->act == a_walk)
                        available = true;
                    if(player->act == a_melee)
                        current = true;
                    if(player->melee.a_cd > time)
                        percent = ((player->melee.a_cd - time) * 100) / player->a_melee_cd;
                    break;
                case skill_s_melee:
                    if(player->act == a_walk || player->act == jump || player->act == air)
                        available = true;
                    if(player->act == s_melee)
                        current = true;
                    if(player->melee.s_cd > time)
                        percent = ((player->melee.s_cd - time) * 100) / player->s_melee_cd;
                    break;
                case skill_s_walk:
                    if( (player->act == a_walk || player->act == jump) && player->jump.second == false)
                        available = true;
                    if(player->act == s_walk)
                        current = true;
                    if(player->walk.cd > time)
                        percent = ((player->walk.cd - time) * 100) / player->s_walk_cd;
                    break;
                case skill_def:
                    if(player->act == a_walk || player->act == a_melee)
                        available = true;
                    if(player->act == def)
                        current = true;
                    if(player->def.cd > time)
                        percent = ((player->def.cd - time) * 100) / player->def_cd;
                    break;
                case skill_jump_attack1:
                    if(player->act == jump && player->jump.second == false)
                        available = true;
                    if(player->act == jump_attack)
                        current = true;
                    if(player->jump.cd1 > time)
                        percent = ((player->jump.cd1 - time) * 100) / player->jump_attack_cd;
                    break;
                case skill_jump_attack2:
                    if(player->act == jump && player->jump.second == false)
                        available = true;
                    if(player->act == jump_attack2)
                        current = true;
                    if(player->jump.cd2 > time)
                        percent = ((player->jump.cd2 - time) * 100) / player->jump_attack_cd;
                    break;
                case skill_counter:
                    if(player->act == a_walk || player->act == hit
                            || player->act == a_melee || player->act == ground)
                        available = true;
                    if(player->act == counter)
                        current = true;
                    if(player->counter.cd > time)
                        percent =  ((player->counter.cd - time) * 100) / player->counter_cd;
                    break;
                case skill_a_ranged:
                    if(player->act == a_walk)
                        available = true;
                    if(player->act == a_ranged)
                        current = true;
                    if(player->ranged.a_cd > time)
                        percent =  ((player->ranged.a_cd - time) * 100) / player->a_cast_cd;
                    break;
                case skill_s_ranged:
                    if(player->act == a_walk)
                        available = true;
                    if(player->act == s_ranged)
                        current = true;
                    if(player->ranged.s_cd > time)
                        percent =  ((player->ranged.s_cd - time) * 100) / player->s_cast_cd;
                    break;
                default:
                    break;
                }
                if(!available && !current)
                    boxRGBA(screen, rect.x, rect.y, rect.x + rect.w, rect.y + rect.h, 0, 0, 0, 125);
                if(percent != 0 && !current) { // A hátralévő cooldown kirajzolása
                    int w =skill_icons[j][i]->w, h = skill_icons[j][i]->h;
                    Sint16 x[7] = {w/2 + w*(100-percent)/24, w, w, 0, 0, w/2, w/2};
                    Sint16 y[7] = {0, 0, h, h, 0, 0, h/2};
                    int n;
                    if(percent > 87) {
                        n=7;
                    } else if(percent > 62) {
                        n=6;
                        y[1] = h*(88-percent)/25;
                    } else if(percent > 37) {
                        n=5;
                        x[2] = w*(percent-38)/25;
                    } else if(percent > 12) {
                        n=4;
                        y[3] = h*(percent-13)/25;
                    } else {
                        n=3;
                        x[4] = w*(13-percent)/24;
                    }
                    int k;
                    for(k=0; k<7; k++) {
                        x[k] += rect.x;
                        y[k] += rect.y;
                    }
                    filledPolygonRGBA(screen, (const Sint16*) (x + 7-n), (const Sint16*) (y + 7-n), n, 0, 0, 0, 125);
                }
                if(current)
                    BlitSurface(current_bg, NULL, screen, &rect);
            }
            rect.x += skill_icons[j][i]->w + 1;
        }
        rect.x = 350 * scale;
        rect.y += (int)((double)kx/1920 * 90);
    }
}
Esempio n. 23
0
void highway(Way *way, short coord_y[way->size],short coord_x[way->size],int thick){
	Sint16 coord_xNode[4] = {0.0,0.0,0.0,0.0};
	Sint16 coord_yNode[4] = {0.0,0.0,0.0,0.0};
	int i;
	for(i = 1;i < way->size;i++){

		if(i == 1){
			float length = distanceXY(coord_x[i-1],coord_y[i-1],coord_x[i],coord_y[i]);
			float fx = normalize(coord_y[i-1],coord_y[i],length);
			float gx = fx;
			float fy = 0.0-normalize(coord_x[i-1],coord_x[i],length);
			float gy = fy;
			coord_xNode[0] = fx;
			coord_xNode[1] = gx;
			coord_yNode[0] = fy;
			coord_yNode[1] = gy;
			float coeff = (coord_y[i-1]-coord_y[i])/(coord_x[i-1]-coord_x[i]);
			if(coeff>0){
				extremite(coord_x[i-1],fx*thick/2,gx*thick/2,coord_xNode,1,1);
				extremite(coord_y[i-1],fy*thick/2,gy*thick/2,coord_yNode,1,1);
			}
			else{
				extremite(coord_x[i-1],fx*thick/2,gx*thick/2,coord_xNode,0,1);
				extremite(coord_y[i-1],fy*thick/2,gy*thick/2,coord_yNode,0,1);
			}
		}
		if(i==way->size-1){
			int j;
			for(j=0;j<4;j++){
				printf("Fin X : %d, Y %d\n",coord_xNode[j],coord_yNode[j] );
			}
			printf("\n");
			float length = distanceXY(coord_x[i-1],coord_y[i-1],coord_x[i],coord_y[i]);
			float fx = normalize(coord_y[i-1],coord_y[i],length);
			float gx = fx;
			float fy = 0.0-normalize(coord_x[i-1],coord_x[i],length);
			float gy = fy;
			coord_xNode[2] = fx;
			coord_xNode[3] = gx;
			coord_yNode[2] = fy;
			coord_yNode[3] = gy;
			float coeff = (coord_y[i-1]-coord_y[i])/(coord_x[i-1]-coord_x[i]);
			if(coeff>0){
				extremite(coord_x[i],fx*thick/2,gx*thick/2,coord_xNode,1,2);
				extremite(coord_y[i],fy*thick/2,gy*thick/2,coord_yNode,1,2);
			}
			else{
				extremite(coord_x[i],fx*thick/2,gx*thick/2,coord_xNode,0,2);
				extremite(coord_y[i],fy*thick/2,gy*thick/2,coord_yNode,0,2);
			}
			for(j=0;j<4;j++){
				printf("Fin XX : %d, Y %d\n",coord_xNode[j],coord_yNode[j] );
			}
			printf("\n");

			filledPolygonRGBA(renderer,coord_xNode,coord_yNode,4,255,0,0,255);
		}
		else{
			float lengthAB = distanceXY(coord_x[i-2],coord_y[i-2],coord_x[i-1],coord_y[i-1]);
			float resABy = normalize(coord_y[i-2],coord_y[i-1],lengthAB);
			float resABx = normalize(coord_x[i-2],coord_x[i-1],lengthAB);

			float lengthBC = distanceXY(coord_x[i-1],coord_y[i-1],coord_x[i],coord_y[i]);
			float resBCx = normalize(coord_x[i-1],coord_x[i],lengthBC);
			float resBCy = normalize(coord_y[i-1],coord_y[i],lengthBC);

			float X = (resABx - resBCx)*thick/2;
			float Y = (resABy - resBCy)*thick/2;

			double angleCal = angle(coord_x[i-2],coord_y[i-2],coord_x[i-1],coord_y[i-1],coord_x[i],coord_y[i]);
			if(angleCal >0){
				midle(coord_x[i-1],X,0,coord_xNode);
				midle(coord_y[i-1],Y,0,coord_yNode);
			}
			else{
				midle(coord_x[i-1],X,1,coord_xNode);
				midle(coord_y[i-1],Y,1,coord_yNode);
			}
			int j;
			for(j=0;j<4;j++){

				printf("Inter X : %d, Y %d\n",coord_xNode[j],coord_yNode[j] );
			}
			printf("\n");
			filledPolygonRGBA(renderer,coord_xNode,coord_yNode,4,255,0,0,255);
			if(i !=way->size-1){
				swap(coord_yNode);
				swap(coord_xNode);
			}
		}
		thickLineRGBA(renderer,coord_x[i-1],coord_y[i-1],coord_x[i],coord_y[i],thick,way->tag->c->red,way->tag->c->green,way->tag->c->blue,105);
	}
}
Esempio n. 24
0
//////test function
void test(){

	//////play test
	int xs[50],ys[50],index=0;

	SDL_Rect bgpos={0,0};
	int continuer=1;
	Point premier_clique;
	int x=0,y=0;
	int on=0;
	Point first={0,0};
	SDL_Event event;
	while (continuer)
	{
		SDL_WaitEvent(&event);
		switch(event.type)
		{
		case SDL_QUIT:
			continuer = 0;
			exit(0);
			break;
		case SDL_KEYDOWN:
			if(event.key.keysym.sym==SDLK_a){continuer=0;puts("quit");exit(0);}
			if(event.key.keysym.sym==SDLK_d){continuer=0;}
			if(event.key.keysym.sym==SDLK_DELETE){
				if(index>0) index--;
				actualiser_ecran();
				dessiner_courbe(_ecran,index,xs,ys);
				if(index==0) on=0;
			}
			if(event.key.keysym.sym==SDLK_s){
				Piece* p=pieces;
				puts("coordonnes de solution");
				while(p!=NULL){
					Point* po=p->forme->points;
					printf("piece %d \n",p->id);
					while(po!=NULL){
						printf(" %f %f ",po->x,po->y);
						po=po->suivant;
					}
					p=p->suivant;
				}
				garder_solution(80);
			puts("\n*********fin solution********");
			}
			break;

		case SDL_MOUSEBUTTONUP:
			x=event.button.x;
			y=event.button.y;
			//chech end
			if(abs(xs[0]-x)<5 && abs(ys[0]-y)<5){
				lineRGBA(_ecran,xs[index-1],ys[index-1],xs[0],ys[0],255,255,255,255);
				Sint16 xss[50],yss[50];
				int k=0;
				puts("***** points de polygone formé *****");
				printf("%d points\n",index);
				for(k=0;k<index;k++)
				{
					printf("%d %d ",xs[k],ys[k]);
					xss[k]=xs[k];yss[k]=ys[k];}
				puts("\n************************************");
				filledPolygonRGBA(_ecran,xss,yss,index,255,0,0,230);

				continuer=0;
			}else{
				//not end
				xs[index]=x;ys[index]=y;
				if(on){
					actualiser_ecran();
					dessiner_courbe(_ecran,index+1,xs,ys);
				
				}else{
					dessiner_plus(x,y,255,0,0);
					on=1;
					premier_clique.x=x;premier_clique.y=y;
				}
				index++;
			}
			SDL_Flip(_ecran);
			break;
		case SDL_MOUSEMOTION:
			x=event.motion.x;
			y=event.motion.y;
			break;
		}
		SDL_Flip(_ecran);
	}

}
Esempio n. 25
0
void draw_hex(SDL_Surface *screen, Hex h, int i, int j, TTF_Font *font) {
    int r, g, blue, alpha;
    alpha = 255;
    SDL_Color text_color = {255, 255, 255};
    char text_label[16];
    
    switch (h.content) {
        case VIDE: {
            r = 150;
            g = 150;
            blue = 150;
            strcpy(text_label, "VIDE");
            break;
        }
        case OBSTACLE: {
            r = 90;
            g = 90;
            blue = 90;
            strcpy(text_label, "OBSTACLE");
            break;
        }
        case EGOUT: {
            if (h.label == 0) {
                r = 130;
                g = 142;
                blue = 35;
                sprintf(text_label, "(O) EGOUT %d", h.id);
            } else if (h.label == 1) {
                r = 140;
                g = 154;
                blue = 110;
                sprintf(text_label, "(F) EGOUT %d", h.id);
            }
            break;
        }
        case LAMPE: {
            if (h.label > 0) {
                // yellow (lit lamp post)
                r = 255;
                g = 255;
                blue = 0;
                text_color.r = 0;
                text_color.g = 0;
                text_color.b = 0;
            } else {
                // gray
                r = 150;
                g = 150;
                blue = 110;   
            }
            sprintf(text_label, "(%d) LAMPE %d", h.label, h.id);
            break;
        }
        case SORTIE: {
            r = 255;
            g = 255;
            blue = 255;
            text_color.r = 0;
            text_color.g = 0;
            text_color.b = 0;
            sprintf(text_label, "SORTIE %d", h.id);
            break;
        }
        case BARRAGE: {
            r = 25;
            g = 25;
            blue = 25;
            sprintf(text_label, "BARRAGE %d", h.id);
            break;
        }
        case MAIGRET: {
            // brown
            r = 139;
            g = 69;
            blue = 19;
            strcpy(text_label, "MAIGRET");
            break;
        }
        case POIROT: {
            // red
            r = 255;
            g = 0;
            blue = 0;
            strcpy(text_label, "POIROT");
            break;
        }
        case LUMIERE: {
            // yellow
            r = 0;
            g = 255;
            blue = 255;
            text_color.r = 0;
            text_color.g = 0;
            text_color.b = 0;
            strcpy(text_label, "LUMIERE");
            break;
        }
        case LEGOUTIER: {
            // orange
            r = 255;
            g = 140;
            blue = 0;
            text_color.r = 0;
            text_color.g = 0;
            text_color.b = 0;
            strcpy(text_label, "LEGOUTIER");
            break;
        }
        case GERBER: {
            // blue
            r = 0;
            g = 0;
            blue = 255;
            strcpy(text_label, "GERBER");
            break;
        }
        case CRUCHOT: {
            // dark blue
            r = 0;
            g = 0;
            blue = 128;
            strcpy(text_label, "CRUCHOT");
            break;
        }
        case FREUD: {
            // purple
            r = 160;
            g = 32;
            blue = 240;
            text_color.r = 0;
            text_color.g = 0;
            text_color.b = 0;
            strcpy(text_label, "FREUD");
            break;
        }
        case DISCRETE: {
            // green
            r = 34;
            g = 139;
            blue = 34;
            strcpy(text_label, "DISCRETE");
            break;
        }
    }
    
    if (h.seen == 1) {
        text_color.r = 255;
        text_color.g = 255;
        text_color.b = 0;
    }
    
    int xi = 0, yi = 500;
    // int x = xi + (a + c) * i;
    int x = xi + (a + c) * i;
    int y = yi - 2 * b * j + b * i;
    short s[6] = { x, x + a, x + a + c, x + 2 * c, x + a + c, x + a }; 
    short t[6] = { y + b, y, y, y + b, y + 2 * b, y + 2 * b };
    
    filledPolygonRGBA(screen, 
        s, t,
        6,
        r, g, blue, alpha);
    
    polygonRGBA(screen, 
        s, t,
        6,
        255, 255, 255, 255);
        
    // compute the metrics of the text to display
    int width, height;
    TTF_SizeUTF8(font, text_label, &width, &height);
    // compute the corresponding text
    SDL_Rect rect;
    rect.x = x + (2 * c - width) / 2;
    rect.y = y + (2 * b - height) / 2;
    // draw the text
    SDL_Surface *text_surface;
    if(!(text_surface = TTF_RenderText_Solid(font, text_label, text_color))) {
        fprintf(stderr, "TTF_RenderText_Solid: %s\n", TTF_GetError());
    } else {
        SDL_BlitSurface(text_surface, NULL, screen, &rect);
    }
    SDL_FreeSurface(text_surface);
    
    if (h.content == MAIGRET) {
        // draw the arrow indicating the lantern's direction
        int ybase, ynorth, ywest, yeast;
        int xbase, xnorth, xwest, xeast;
        
        switch(h.label) {
            case 1: {
                xbase = x + c;
                ybase = y + (3 * b) / 4;
                ynorth = ybase - b / 2;
                xnorth = xbase;
                xwest = xnorth - 6;
                ywest = ynorth + 6;
                xeast = xnorth + 6;
                yeast = ywest;
                break;
            }
            case 2: {
                ybase = y + (3 * b) / 4;
                xbase = x + c;
                ynorth = ybase - b / 4;
                xnorth = xbase - (b * 87) / 200;
                ywest = ynorth + 6;
                xwest = xnorth + 2;
                yeast = ynorth - 2;
                xeast = xnorth + 6;
                break;
            }
            case 3: {
                xbase = x + c;
                ybase = y + (5 * b) / 4;
                ynorth = ybase + b / 4;
                xnorth = xbase - (b * 87) / 200;
                xwest = xnorth + 6;
                ywest = ynorth + 2;
                xeast = xnorth + 2;
                yeast = ynorth - 6;
                break;
            }
            case 4: {
                xbase = x + c;
                ybase = y + (5 * b) / 4;
                ynorth = ybase + b / 2;
                xnorth = xbase;
                xwest = xnorth - 6;
                ywest = ynorth - 6;
                xeast = xnorth + 6;
                yeast = ywest;
                break;
            }
            case 5: {
                xbase = x + c;
                ybase = y + (5 * b) / 4;
                ynorth = ybase + b / 4;
                xnorth = xbase + (b * 87) / 200;
                xwest = xnorth - 2;
                ywest = ynorth - 6;
                xeast = xnorth - 6;
                yeast = ynorth + 2;
                break;
            }
            case 6: {
                ybase = y + (3 * b) / 4;
                xbase = x + c;
                ynorth = ybase - b / 4;
                xnorth = xbase + (b * 87) / 200;
                ywest = ynorth - 2;
                xwest = xnorth - 6;
                yeast = ynorth + 6;
                xeast = xnorth - 2;
                break;
            }
        }
        
        // main line
        lineRGBA(screen, xbase, ybase, xnorth, ynorth,
            255, 255, 0, 255);
        // west part
        lineRGBA(screen, xwest, ywest, xnorth, ynorth,
            255, 255, 0, 255);
        // east part
        lineRGBA(screen, xeast, yeast, xnorth, ynorth,
            255, 255, 0, 255);
    }
}