示例#1
0
void CRoom_2x1::checkPtrs(int pixelCheck)
{
	nullPtrs();

	for (int i = 0; i < m_pRoom_collision->size(); ++i)
	{
		CRoom* pRoom = m_pRoom_collision->at(i);

		if (this->equals(pRoom))
		{
			continue;
		}

		// general logic:
		// if not found (false)
		//		then check to see if the room is found
		//		& set to true if found, false if not

		// [OPTIMIZATION]: have a better checking columns algorithm for 1x2 or 2x1 or 1x2 to exit checking early

		check_up(pRoom, pixelCheck);
		check_down(pRoom, pixelCheck);
		check_left(pRoom, pixelCheck);
		check_right(pRoom, pixelCheck);
	}
}
/* This function will search any winner move */
int is_finish(struct game *myGame, struct move *currMove){
    /* this flag will holds the result of every checks */
    int winner_flag;
    
    winner_flag = 0;
    winner_flag += check_down(myGame, currMove);
    winner_flag += check_same_line(myGame, currMove);
    winner_flag += check_diagonal(myGame, currMove);
    
    /* at this point the flag can have a value in [0...3]
     if it is > 0 it means that one of the check function returns 1
     thus there is a winner */
    if (winner_flag > 0) {
        /* set the winner */
        myGame->winner  = currMove->player;
        printf("The winner is: %c \n", myGame->winner);
        return 1;
    }
    /* check if it is tie */
    else if (check_last_row(myGame)){
        puts("Tie !");
        return 1;
    };
    /* no winner, the match can continue */
    return 0;
    
}
示例#3
0
int		check_dir(char **maze, t_list **closed,
			  t_list **open, t_data *node)
{
  check_up(maze, closed, open, node);
  check_right(maze, closed, open, node);
  check_down(maze, closed, open, node);
  check_left(maze, closed, open, node);
  return (0);
}
示例#4
0
文件: move.c 项目: rclanget/2048
t_map 	*fusion_down(t_map *map)
{
	t_map *head;

	head = map;
	while (head->next)
		head = head->next;
	while (head)
	{
		if (head->value >= 0)
			head = check_down(head);
		head = head->prev;
	}
	return (map);
}
示例#5
0
文件: am_i.c 项目: Azhr4n/Lem-ipc
int			am_i_circle(t_player *player)
{
	int		nb;

	nb = 0;
	if (check_left(player) && check_left_p(player))
		nb++;
	if (check_right(player) && check_right_p(player))
		nb++;
	if (check_up(player) && check_up_p(player))
		nb++;
	if (check_down(player) && check_down_p(player))
		nb++;
	if (nb >= 2)
		return (1);
	return (0);
}
示例#6
0
文件: move.c 项目: rclanget/2048
t_map 	*check_down(t_map *map)
{
	t_map 	*head;
	int 	rec;

	head = map;
	rec = 0;
	while (head && head->prev)
	{
		head = head->prev;
		if (head && (head->x == map->x) && (head->value == map->value) && !head->lock)
		{
			head = add_val(head, map->position, (head->value + map->value));
			head = add_val(head, head->position, -1);
			rec = 1;
			break;
		}
		else if (head && (head->x == map->x) && (((head->value != map->value) && (head->value != -1)) || (head->value == map->value && head->lock)))
			break;
	}
	return (rec ? check_down(map) : map);
}
示例#7
0
文件: main.cpp 项目: lastab/BagChal
int check_possible_movement(int j,int k)
{
    int count=0;
        if( check_up(j,k)==0)
    {
        move_loc[count][0]=j;
        move_loc[count][1]=k-1;
  //      draw_target(move_loc[count][0],move_loc[count][1]);
        count++;
    }
        if( check_down(j,k)==0)
    {
        move_loc[count][0]=j;
        move_loc[count][1]=k+1;
    //    draw_target(move_loc[count][0],move_loc[count][1]);        
        count++;
    }
        if( check_left(j,k)==0)
    {
        move_loc[count][0]=j-1;
        move_loc[count][1]=k;
      //  draw_target(move_loc[count][0],move_loc[count][1]);        
        count++;
    }
        if( check_right(j,k)==0)
    {
        move_loc[count][0]=j+1;
        move_loc[count][1]=k;
        //draw_target(move_loc[count][0],move_loc[count][1]);        
        count++;
    }
    if((j+k)%2==0)
    {
        if( check_up_left(j,k)==0)
    {
        move_loc[count][0]=j-1;
        move_loc[count][1]=k-1;
//        draw_target(move_loc[count][0],move_loc[count][1]);        
        count++;
    }
        if( check_up_right(j,k)==0)
    {
        move_loc[count][0]=j+1;
        move_loc[count][1]=k-1;
  //      draw_target(move_loc[count][0],move_loc[count][1]);        
        count++;
    }
        if( check_down_left(j,k)==0)
    {
        move_loc[count][0]=j+1;
        move_loc[count][1]=k+1;
    //    draw_target(move_loc[count][0],move_loc[count][1]);        
        count++;
    }
        if( check_down_right(j,k)==0)
    {
        move_loc[count][0]=j-1;
        move_loc[count][1]=k+1;
      //  draw_target(move_loc[count][0],move_loc[count][1]);        
        count++;
    }
    }   
    return count;
}    
示例#8
0
文件: main.cpp 项目: lastab/BagChal
int check_possible_jump_movement(int j,int k)
{
    int count=0;
    if( check_up(j,k)==2 && check_up(j,k-1)==0)
    {
        jump_loc[count][0]=j;
        jump_loc[count][1]=k-2;        
//        draw_target(jump_loc[count][0],jump_loc[count][1]);
        count++;
    }
        if( check_down(j,k)==2 && check_down(j,k+1)==0)
    {
        jump_loc[count][0]=j;
        jump_loc[count][1]=k+2;        
  //      draw_target(jump_loc[count][0],jump_loc[count][1]);        
        count++;
    }
        if( check_left(j,k)==2 && check_left(j-1,k)==0)
    {
        jump_loc[count][0]=j-2;
        jump_loc[count][1]=k;        
    //    draw_target(jump_loc[count][0],jump_loc[count][1]);        
        count++;                
    }
        if( check_right(j,k)==2 && check_right(j+1,k)==0)
    {
        jump_loc[count][0]=j+2;
        jump_loc[count][1]=k;        
      //  draw_target(jump_loc[count][0],jump_loc[count][1]);        
        count++;
    }
    if((j+k)%2==0)
    {
        if( check_up_left(j,k)==2 && check_up_left(j-1,k-1)==0)
    {
        jump_loc[count][0]=j-2;
        jump_loc[count][1]=k-2;        
        //draw_target(jump_loc[count][0],jump_loc[count][1]);        
        count++;
    }
        if( check_up_right(j,k)==2  && check_up_right(j+1,k-1)==0)
    {
        jump_loc[count][0]=j+2;
        jump_loc[count][1]=k-2;        
//        draw_target(jump_loc[count][0],jump_loc[count][1]);
        count++;
    }
        if( check_down_left(j,k)==2 && check_down_left(j+1,k+1)==0)
    {
        jump_loc[count][0]=j+2;
        jump_loc[count][1]=k+2;        
  //      draw_target(jump_loc[count][0],jump_loc[count][1]);
        count++;
    }
        if( check_down_right(j,k)==2 && check_down_right(j-1,k+1)==0)
    {
        jump_loc[count][0]=j-2;
        jump_loc[count][1]=k+2;        
    //    draw_target(jump_loc[count][0],jump_loc[count][1]);        
        count++;
    }
    }
    return count;    
}
示例#9
0
文件: main.cpp 项目: lastab/BagChal
int check_movement_ok(int j,int k,int m,int n)
{
  int count=0;
    int ok=0;  
        if( check_up(j,k)==0)
    {
        move_loc[count][0]=j;
        move_loc[count][1]=k-1;
        if(move_loc[count][0]==m && move_loc[count][1]==n)
        ok=1;
        count++;
    }
        if( check_down(j,k)==0)
    {
        move_loc[count][0]=j;
        move_loc[count][1]=k+1;
        if(move_loc[count][0]==m && move_loc[count][1]==n)
        ok=1;
        count++;
    }
        if( check_left(j,k)==0)
    {
        move_loc[count][0]=j-1;
        move_loc[count][1]=k;
        if(move_loc[count][0]==m && move_loc[count][1]==n)
        ok=1;
        count++;
    }
        if( check_right(j,k)==0)
    {
        move_loc[count][0]=j+1;
        move_loc[count][1]=k;
        if(move_loc[count][0]==m && move_loc[count][1]==n)
        ok=1;
        count++;
    }
    if((j+k)%2==0)
    {
        if( check_up_left(j,k)==0)
    {
        move_loc[count][0]=j-1;
        move_loc[count][1]=k-1;
        if(move_loc[count][0]==m && move_loc[count][1]==n)
        ok=1;
        count++;
    }
        if( check_up_right(j,k)==0)
    {
        move_loc[count][0]=j+1;
        move_loc[count][1]=k-1;
        if(move_loc[count][0]==m && move_loc[count][1]==n)
        ok=1;
        count++;
    }
        if( check_down_left(j,k)==0)
    {
        move_loc[count][0]=j+1;
        move_loc[count][1]=k+1;
        if(move_loc[count][0]==m && move_loc[count][1]==n)
        ok=1;
        count++;
    }
        if( check_down_right(j,k)==0)
    {
        move_loc[count][0]=j-1;
        move_loc[count][1]=k+1;
        if(move_loc[count][0]==m && move_loc[count][1]==n)
        ok=1;
        count++;
    }
    }           

    return ok;
}
示例#10
0
文件: main.cpp 项目: lastab/BagChal
int check_jump_movement_ok(int j,int k,int m,int n)
{
  int count=0;
    int ok=0;

    if( check_up(j,k)==2 && check_up(j,k-1)==0)
    {
        jump_loc[count][0]=j;
        jump_loc[count][1]=k-2;        
        if(jump_loc[count][0]==m && jump_loc[count][1]==n)
        ok=1;
        count++;
    }
        if( check_down(j,k)==2 && check_down(j,k+1)==0)
    {
        jump_loc[count][0]=j;
        jump_loc[count][1]=k+2;        
        if(jump_loc[count][0]==m && jump_loc[count][1]==n)
        ok=1;
        count++;
    }
        if( check_left(j,k)==2 && check_left(j-1,k)==0)
    {
        jump_loc[count][0]=j-2;
        jump_loc[count][1]=k;        
        if(jump_loc[count][0]==m && jump_loc[count][1]==n)
        ok=1;
        count++;        
    }
        if( check_right(j,k)==2 && check_right(j+1,k)==0)
    {
        jump_loc[count][0]=j+2;
        jump_loc[count][1]=k;        
        if(jump_loc[count][0]==m && jump_loc[count][1]==n)
        ok=1;
        count++;        
    }
    if((j+k)%2==0)
    {
        if( check_up_left(j,k)==2 && check_up_left(j-1,k-1)==0)
    {
        jump_loc[count][0]=j-2;
        jump_loc[count][1]=k-2;        
        if(jump_loc[count][0]==m && jump_loc[count][1]==n)
        ok=1;
        count++;
    }
        if( check_up_right(j,k)==2  && check_up_right(j+1,k-1)==0)
    {
        jump_loc[count][0]=j+2;
        jump_loc[count][1]=k-2;        
        if(jump_loc[count][0]==m && jump_loc[count][1]==n)
        ok=1;
        count++;
    }
        if( check_down_left(j,k)==2 && check_down_left(j+1,k+1)==0)
    {
        jump_loc[count][0]=j+2;
        jump_loc[count][1]=k+2;        
        if(jump_loc[count][0]==m && jump_loc[count][1]==n)
        ok=1;
        count++;
    }
        if( check_down_right(j,k)==2 && check_down_right(j-1,k+1)==0)
    {
        jump_loc[count][0]=j-2;
        jump_loc[count][1]=k+2;        
        if(jump_loc[count][0]==m && jump_loc[count][1]==n)
        ok=1;
        count++;
    }
    }                          
    return ok;
}