Ejemplo n.º 1
0
void	set_color_tool2(t_data *data)
{
  t_bunny_position	pos[1];

  data->crs.pencil_pos.x = bunny_get_mouse_position()[0].x;
  data->crs.pencil_pos.y = bunny_get_mouse_position()[0].y;
  if (data->crs.pencil_pos.x - 255 <= WIN_WIDTH - 5 &&
      data->crs.pencil_pos.x >= WIN_WIDTH - 260 &&
      data->crs.pencil_pos.y >= 2 &&
      data->crs.pencil_pos.y <= 102 &&
      data->crs.left_click == 1)
{
      data->tools.color.full = getpixelcolor
	  (data->swatch.pix, poser(data->crs.pencil_pos.x -
				    (WIN_WIDTH - 260), data->crs.pencil_pos.y - 2, pos));
      data->tools.color.argb[3] = 255;
    }
}
Ejemplo n.º 2
0
void	set_color_tool(t_data *data)
{
  t_bunny_position	pos[1];

  data->crs.pencil_pos.x = bunny_get_mouse_position()[0].x;
  data->crs.pencil_pos.y = bunny_get_mouse_position()[0].y;
  if (data->crs.pencil_pos.x - 255 <= WIN_WIDTH - 5 &&
      data->crs.pencil_pos.x >= WIN_WIDTH - 260 &&
      data->crs.pencil_pos.y >= 112 &&
      data->crs.pencil_pos.y <= 142 &&
      data->crs.left_click == 1)
{
      data->swatch.col_tofade.full = getpixelcolor
	  (data->swatch.pix2, poser(data->crs.pencil_pos.x -
				    (WIN_WIDTH - 260), 0, pos));
    }
  set_color_tool2(data);
}
Ejemplo n.º 3
0
void	circle2(t_data *data, t_bunny_position *pos, int x, int y)
{
  t_color	col;

  col.full = data->tools.color.full;
  dtekpixel(data->crs.calc->pix,
	   poser(pos[1].x + x, pos[1].y + y, pos)[0], &col);
  dtekpixel(data->crs.calc->pix,
	   poser(pos[1].x + y, pos[1].y + x, pos)[0], &col);
  dtekpixel(data->crs.calc->pix,
	   poser(pos[1].x - x, pos[1].y + y, pos)[0], &col);
  dtekpixel(data->crs.calc->pix,
	   poser(pos[1].x - y, pos[1].y + x, pos)[0], &col);
  dtekpixel(data->crs.calc->pix,
	   poser(pos[1].x + x, pos[1].y - y, pos)[0], &col);
  dtekpixel(data->crs.calc->pix,
	   poser(pos[1].x + y, pos[1].y - x, pos)[0], &col);
  dtekpixel(data->crs.calc->pix,
	   poser(pos[1].x - x, pos[1].y - y, pos)[0], &col);
  dtekpixel(data->crs.calc->pix,
	   poser(pos[1].x - y, pos[1].y - x, pos)[0], &col);
}
Ejemplo n.º 4
0
int		start(t_data *data)
{
  t_color	color[2];
  int		n;
  int		i;
  t_bunny_position pos[2];

  n = -1;
  while (n <= data->swatch.pix2->clipable.clip_height)
    {
      i = 0;
      while (i <= data->swatch.pix2->clipable.clip_width)
	{
	  print_color(&color[1], i);
	  dtekpixel(data->swatch.pix2, poser(i, n, pos)[0], &color[1]);
	  i++;
	}
      n++;
    }
  fill_swatch(data);
  return (0);
}
Ejemplo n.º 5
0
//pause_jouer()
void pause_jouer(){
	int continuer = 1;
	int suivre=0;
	int debug=0;
	int posee=0;
	Point premier_clique={0,0};
	Point precedent_motion={0,0};
	Point actuel_motion={0,0};
	SDL_Rect pos;
	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;exit(0);}
			else if(event.key.keysym.sym==SDLK_d){test();}
			 if(event.key.keysym.sym==SDLK_u){
				pieces=lire_solution(7);
				actualiser_ecran();
			}
			break;

		case SDL_MOUSEBUTTONUP:
			premier_clique.x=event.button.x;
			premier_clique.y=event.button.y;
			
			if(event.button.button==SDL_BUTTON_LEFT){
				//menu
					if(premier_clique.x<=102 && premier_clique.x>=5 && premier_clique.y<=39){
						if(stage<nbr_stages) stage++;
						else stage=1;
						
						init_stage(stage);
						
					}
					if(premier_clique.x<=208 && premier_clique.x>=114 && premier_clique.y<=39){
						Piece* sol=lire_solution(stage);
						if(sol) pieces=sol;
						actualiser_ecran();
					}
					if(premier_clique.x<=312 && premier_clique.x>=216 && premier_clique.y<=39){
						acceuil();
					}
					if(premier_clique.x<=419 && premier_clique.x>=324 && premier_clique.y<=39){
						exit(0);
					}
				
				//movements
				if(!suivre){
					puts("........Transporter........");
					piece_mobile=transporter(event.button.x,event.button.y);
					if(piece_mobile!=NULL){
						suivre=1;
						if(premier_clique.x<TABLE_WIDTH) dans_table=1;else dans_table=0;
					}
					actualiser_ecran();
				}else{
					puts("........Poser.........");
					posee=poser(piece_mobile,event.button.x,event.button.y);
					if(posee){
						piece_mobile=NULL;
						dans_table=0;
						actualiser_ecran();
						suivre=0;
						
					}
				}
				puts("........................................");
			}
			else if(event.button.button=SDL_BUTTON_RIGHT){
				if(suivre){
					puts(".....rotating....");
					Point centre={event.button.x,event.button.y};
					rotate_forme(piece_mobile->forme,centre);
					actualiser_ecran();
				}
			}
			break;

		case SDL_MOUSEMOTION:
			int xm=event.motion.x,ym=event.motion.y;
			actuel_motion.x=xm;
			actuel_motion.y=ym;
			if(xm<TABLE_WIDTH) dans_table=1; else dans_table=0;
			if(suivre){
				if(piece_mobile==NULL){
					puts("probleme dans l'operation de glissage");
					exit(0);
				}
				translater_forme(piece_mobile->forme,precedent_motion,actuel_motion);
				actualiser_ecran();
			}else{
				dans_table=0;
			}
			precedent_motion.x=xm;
			precedent_motion.y=ym;

		}

		if(nbr_pieces_posees==7){
			if(!mode_devel) {
				if(stage<nbr_stages) stage++; else stage=1;
				init_stage(stage);
			continuer=0;
			}
		}
	}
}