Exemplo n.º 1
0
void vu_rectangle_move(vu_rectangle* r, vec2 pos)
{
    if (!r) 
        return;
    vec2 size = vu_rectangle_size(r);
    r->top_left = pos;
    r->bottom_right = VEC2_ADD(pos, size);
}
Exemplo n.º 2
0
Arquivo: cone.c Projeto: Julow/rtv1
static bool		cone_base(float *dist, t_vertex const *ray)
{
	t_vec2			tmp;

	if (ray->dir.z == 0.f)
		return (false);
	*dist = (CONE_MAX - ray->pos.z) / ray->dir.z;
	tmp = VEC2_ADD(ray->pos, VEC2_MUL1(ray->dir, *dist));
	return (VEC2_DOT(tmp, tmp) <= 1.f);
}
Exemplo n.º 3
0
void bullet_update(struct moag *m, int id)
{
    struct bullet *b = &m->bullets[id];

    if (!b->active)
        return;

    if (b->type == LADDER)
    {
        b->active--;
        b->obj.pos = VEC2_ADD(b->obj.pos, b->obj.vel);
        b->x = (int)b->obj.pos.x;
        b->y = (int)b->obj.pos.y;

        if (get_land_at(m, b->x, b->y) == 1)
        {
            explode(m, b->x, b->y + LADDER_LENGTH - b->active, 1, E_SAFE_EXPLODE);
            bullet_detonate(m, id);
        }
        return;
    }

    b->obj.pos = VEC2_ADD(b->obj.pos, b->obj.vel);
    b->obj.vel = VEC2_ADD(b->obj.vel, VEC2(0, GRAVITY));
    b->x = (int)b->obj.pos.x;
    b->y = (int)b->obj.pos.y;
    if (get_land_at(m, b->x, b->y))
    {
        bullet_detonate(m, id);
        return;
    }

    if (b->active > 1)
    {
        b->active--;
        return;
    }

    if (b->type == BOUNCER && b->active == 1)
        b->active = -BOUNCER_BOUNCES;
    if (b->type == TUNNELER && b->active == 1)
        b->active = -TUNNELER_TUNNELINGS;

    for (int i = 0; i < MAX_PLAYERS; i++)
    {
        if(DIST(m->players[i].tank.x, m->players[i].tank.y - 3,
                b->x, b->y) < 8.5)
        {
            bullet_detonate(m, id);
            return;
        }
    }

    if (m->crate.active && DIST(m->crate.x, m->crate.y - 4, b->x, b->y) < 5.5)
    {
        if (m->crate.type == TRIPLER) {
            float angle = -RAD2DEG(atan2(b->obj.vel.y, b->obj.vel.x));
            float speed = VEC2_MAG(b->obj.vel);
            fire_bullet_ang(m, b->type, b->x, b->y, angle - 20.0, speed);
            fire_bullet_ang(m, b->type, b->x, b->y, angle + 20.0, speed);
        } else if (m->crate.type == SHOTGUN) {
            bullet_detonate(m, id);
            float angle = -RAD2DEG(atan2(b->obj.vel.y, b->obj.vel.x));
            float speed = VEC2_MAG(b->obj.vel);
            int shots = SHOTGUN_PELLETS;
            for (int i = 0; i < shots; i++)
                fire_bullet_ang(m, m->crate.type, m->crate.x, m->crate.y - 4,
                        angle - (shots-1)*2 + i*4, speed*0.5);
        } else {
            bullet_detonate(m, id);
            fire_bullet(m, m->crate.type, m->crate.x, m->crate.y - 4,
                           m->crate.type != BOUNCER ? 0 :
                           b->obj.vel.x < 0 ? -0.2 :
                                               0.2, -0.2);
        }
        m->crate.active = false;
        return;
    }

    if (b->type == MIRV && b->obj.vel.y > 0)
    {
        bullet_detonate(m, id);
        return;
    }

    if (b->active)
        broadcast_bullet_chunk(m, MOVE, id);
}
Exemplo n.º 4
0
void vu_rectangle_resize(vu_rectangle* r, vec2 size)
{
   if (!r)
       return;
   r->bottom_right = VEC2_ADD(r->top_left, size); 
}