Example #1
0
bool Runner::rotation_posibility() {
    BlockType cur_left = check_left(current_status, face);
    BlockType last_left = check_left(last_status, last_face);

    if (cur_left != BlockType::WALL
        && last_left == BlockType::WALL) {
        return true;
    }
    else return false;
}
Example #2
0
void	my_key(t_tetris *st, t_tetriminos *elem, int *x, int *y)
{
  int	key;
  int	i;
  int	j;

  i = *x;
  j = *y;
  if ((key = get_key(st)) == 1)
    {
      if (check_left(i, j, st, elem) == 0)
	*x = *x - 1;
    }
  else if (key == 2)
    {
      if (check_right(i, j, st, elem) == 0)
	*x = *x + 1;
    }
  else if (key == 3)
    check_left_rotate(i, j, st, elem);
  else if (key == 4)
    drop_tetri(y, x, st, elem);
  else if (key == 5)
    xexit(st, "See you again :)\n");
  else if (key == 6)
    while (get_key(st) != 6);
}
Example #3
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);
	}
}
Example #4
0
t_bool	check_grammar_exec(t_token *b, t_token *e)
{
  t_token	*tmp;
  int		word;
  int		pipe;
  int		res;

  tmp = b;
  word = 0;
  pipe = 0;
  while (tmp && tmp != e)
    {
      if (!word && tmp->id == PIPE)
	return (puterror(NULL_CMD, NULL));
      word = (tmp->id == WORD) ? (1) : (0);
      pipe = (tmp->id == PIPE) ? (1) : (0);
      tmp = tmp->next;
    }
  if (pipe)
    return (puterror(NULL_CMD, NULL));

  res = there_are_red(b, e);
  if (res == 1 && check_left(b, e) != TRUE)
    return (FALSE);
  else if (res == 2 && check_right(b, e) != TRUE)
    return (FALSE);
  return (TRUE);
}
Example #5
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);
}
Example #6
0
void		check_win(int last_x, int last_y, t_data *powf)
{
	char	p;

	p = powf->board[last_y * powf->col + last_x];
	if (check_up(p, last_x, last_y, powf)
		|| check_left(p, last_x, last_y, powf)
		|| check_up_left(p, last_x, last_y, powf)
		|| check_up_right(p, last_x, last_y, powf))
		powf->winner = p;
	powf->nmatch = 0;
}
Example #7
0
 void run()
 {
   for (short row = 0; row < n; ++ row)
   {
     min_paths[0][row] = Data::weights[0][row];
   }
   for (short col = 1; col < m; ++col)
   {
     check_left(col);
     check_up_and_down(col);
   }   
 }
Example #8
0
File: move.c Project: rclanget/2048
t_map 	*fusion_left(t_map *map)
{
	t_map *head;

	head = map;
	while (head)
	{
		if (head->value >= 0)
			head = check_left(head);
		head = head->next;
	}
	return (map);
}
Example #9
0
int			check_win(t_gboard *p4, int player)
{
	if (check_lines(p4, player) == 1 || check_columns(p4, player) == 1
		|| check_left(p4, player, 4) == 1 || check_right(p4, player, 4) == 1)
	{
		if (player != p4->ia_id)
		{
			ft_putendl("Congratulation human... you win.");
			ft_putendl("   .... This time !!!");
		}
		return (1);
	}
	return (0);
}
Example #10
0
int main()
{
    init();

    while(true)
    {
        check_right();
        check_left();
        check_move();
        check_scroll();
        
       // wait(0.005);
    }
}
Example #11
0
int		check_order(char **tab)
{
  int		i;

  i = 0;
  while (tab[i])
    {
      if (check_left(tab, i) == -1)
	return (-1);
      if (check_right(tab, i) == -1)
	return (-1);
      i++;
    }
  return (0);
}
Example #12
0
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);
}
Example #13
0
static void		add_tree(t_op **tree, t_op *save)
{
    t_op		*tmp;

    tmp = NULL;
    if (!save)
        return ;
    if (!*tree)
        *tree = save;
    else
    {
        tmp = *tree;
        while (!save->top)
        {
            if (save->nbr < tmp->nbr)
                check_right(&tmp, &save);
            else
                check_left(&tmp, &save);
        }
    }
}
Example #14
0
int	verify_playable(char** map, int x, int y, int player)
{
	if (map[y][x] != 0)
		return -1;
	if (check_top(map, x, y, player) == 0)
		return 0;
	if (check_bottom(map, x, y, player) == 0)
		return 0;
	if (check_left(map, x, y, player) == 0)
		return 0;
	if (check_right(map, x, y, player) == 0)
		return 0;
	if (check_top_left(map, x, y, player) == 0)
		return 0;
	if (check_top_right(map, x, y, player) == 0)
		return 0;
	if (check_bottom_left(map, x, y, player) == 0)
		return 0;
	if (check_bottom_right(map, x, y, player) == 0)
		return 0;
	return -1;
}
Example #15
0
File: move.c Project: rclanget/2048
t_map 	*check_left(t_map *map)
{
	t_map 	*head;
	int 	rec;

	head = map;
	rec = 0;
	while (head && (head->y == map->y) && (head->prev && head->prev->y == map->y))
	{
		head = head->prev;
		if (head && (head->value == map->value) && !head->lock)
		{
			head = add_val(head, head->position, (head->value + map->value));
			head = add_val(head, map->position, -1);
			rec = 1;
			break;
		}
		else if (head && (((head->value != map->value) && (head->value != -1)) || (head->value == map->value && head->lock)))
			break;
	}
	return (rec ? check_left(map) : map);
}
Example #16
0
int	check_axe(t_terrain* button, t_terrain* terrain)
{
    if (check_left(button, terrain))
    {
        move_left(button, terrain);
        return (1);
    }
    else if (check_right(button, terrain))
    {
        move_right(button, terrain);
        return (1);
    }
    else if (check_top(button, terrain))
    {
        move_top(button, terrain);
        return (1);
    }
    else if (check_bot(button, terrain))
    {
        move_bot(button, terrain);
        return (1);
    }
    return (0);
}
Example #17
0
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;
}
Example #18
0
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;
}
Example #19
0
static int test_traverse(struct stringmap *map, struct test_entry *strings, size_t size, FILE *out) {
	size_t sp = 0;
	size_t stack_alloc = 16;
	struct stringmap_node **stack = NULL;
	struct stringmap_node *n;
	void *leaf;
	#define check(lri) do { \
			leaf = n->lr[lri]; \
			if (!size--) \
				err("Fewer items in tree than counted"); \
			if (tecmp(leaf, strings++)) \
				err("%s leaf has incorrect string", lri ? "Left" : "Right"); \
		} while(0)
	#define check_left() check(0)
	#define check_right() check(1)
	
	if (map->count != size)
		err("map->count != size");
	
	if (map->count == 0)
		return 1;
	
	if (map->count == 1) {
		leaf = (struct test_entry*)map->root;
		if (!tecmp(leaf, &strings[0]))
			return 1;
		else
			err("Only leaf in tree has incorrect value");
	}
	
	stack = malloc(sizeof(*stack) * stack_alloc);
	n = map->root;
	
	for (;;) {
		//descend left
		while (!n->left_is_leaf) {
			stack[sp++] = n;
			n = n->lr[0];
			
			if (sp >= stack_alloc) {
				stack_alloc += stack_alloc;
				stack = realloc(stack, sizeof(*stack) * stack_alloc);
			}
		}
		
		check_left();
		
	ascend_right:
		while (n->right_is_leaf) {
			check_right();
			
			if (!sp)
				goto done; //we finished up the last entry
			n = stack[--sp];
		}
		
		//descend right
		n = n->lr[1];
		while (n->left_is_leaf) {
			check_left();
			
			if (n->right_is_leaf) {
				check_right();
				
				if (!sp)
					goto done;
				n = stack[--sp];
				goto ascend_right; //sorry
			}
			n = n->lr[1];
		}
	}
	
done:
	if (size != 0)
		err("More items in tree than counted");
	
	free(stack);
	return 1;
	
fail:
	if (stack)
		free(stack);
	return 0;
	
	#undef check
	#undef check_left
	#undef check_right
}
Example #20
0
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;    
}
Example #21
0
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;
}