Ejemplo n.º 1
0
double	ft_tan(double radian)
{
	if (ft_cos(radian) != 0)
		return (ft_sin(radian) / ft_cos(radian));
	else
		return (ft_sin(radian) / 0.0000001);
}
Ejemplo n.º 2
0
double		ft_dist_corr(t_win *win, double dist, int x)
{
	double	alpha;
	double	ray_ang;

	ray_ang = (double)CAM_FOV / (double)win->width;
	alpha = ray_ang * (x - ((double)win->width / 2));
	return (ABS(dist * ft_cos(alpha)));
}
Ejemplo n.º 3
0
Archivo: inter.c Proyecto: rfrey/wolf3d
t_pix		*ft_get_v_inter(t_win *win, int x)
{
	t_pix	*pix;

	if ((!(pix = (t_pix*)malloc(sizeof(t_pix)))))
		ft_ferror(ERR_MALLOC);
	pix->ang = ft_get_alpha(win, x);
	if (pix->ang == 90 || pix->ang == 270)
		return (NULL);
	ft_set_v_inter(win, pix);
	pix->dist = ft_dist_corr(win, (CAM_X - pix->x) / ft_cos(pix->ang), x);
	return (pix);
}
Ejemplo n.º 4
0
Archivo: move.c Proyecto: rfrey/wolf3d
void		ft_key_up(t_win *win)
{
	t_pix	pix;
	t_pix	*inter;

	inter = ft_get_shorter_inter(win, WIN_WIDTH / 2);
	pix.x = CAM_X + ft_cos(CAM_ANG) * M_RUN_SPD;
	pix.y = CAM_Y + ft_sin(CAM_ANG) * M_RUN_SPD;
	if (inter->dist > M_RUN_SPD)
	{
		CAM_X = pix.x;
		CAM_Y = pix.y;
	}
	free(inter);
}
Ejemplo n.º 5
0
void		draw_circle(t_bal *bal, t_env *e)
{
	float	angle;

	angle = 0.0;
	glBegin(GL_TRIANGLE_FAN);
	if (e->lives == 3)
		glColor3f(0.2, 0.9, 0.6);
	else if (e->lives == 2)
		glColor3f(0.9, 0.2, 0.6);
	else if (e->lives == 1)
		glColor3f(0.2, 0.6, 0.9);
	glVertex2f(bal->x1, bal->y1);
	while (angle <= 2 * 3.14159265)
	{
		bal->x2 = bal->x1 + ft_sin(angle) * bal->radius;
		bal->y2 = bal->y1 + ft_cos(angle) * bal->radius;
		glVertex2f(bal->x2, bal->y2);
		angle += 0.005;
	}
	glEnd();
}
Ejemplo n.º 6
0
double			ft_tan(double angle)
{
	if (angle == 90)
		return (2000000000);
	return (ft_sin(angle) / ft_cos(angle));
}