void meteor_launcher::launch() { auto side = next_int(0, 3); int x = 0, y = 0; int x1 = 0, y1 = 0; if (side == 0) { x = -500; y = next_int(0, height); x1 = width; y1 = next_int(0, height); } if (side == 1) { x = next_int(0, width); y = height + 500; x1 = next_int(0, width); y1 = 0; } if (side == 2) { x = width + 500; y = next_int(0, height); x1 = 0; y1 = next_int(0, height); } if (side == 3) { x = next_int(0, width); y = -500; x1 = next_int(0, width); y1 = height; } ent_asteroid *a; a = &w->add_entity<ent_asteroid>(); a->C(com_box).pos = vec2(x, y); a->C(com_movement).vel = normalize(vec2(x1, y1) - vec2(x, y)) * next_int(7, 12); a->C(com_texture).filename = "asteroid.png"; a->C(com_spin).rotation = next_float(0.01, 0.1); cout << "METEOR!!!!!!" << endl; last_launch = t.get_ticks(); launch_period = launch_period - 50 > SEC / 2 ? launch_period - 50 : SEC / 2; }
std::pair<Interval,Interval> Interval::bisect(double ratio) const { assert(is_bisectable()); assert(ratio>0 && ratio<1); Interval left,right; if (lb()==NEG_INFINITY) { if (ub()==POS_INFINITY) { left = Interval(NEG_INFINITY,0); right = Interval(0,POS_INFINITY); } else { left = Interval(NEG_INFINITY,-DBL_MAX); right = Interval(-DBL_MAX,ub()); } } else if (ub()==POS_INFINITY) { left = Interval(lb(),DBL_MAX); right = Interval(DBL_MAX,POS_INFINITY); } else { double point; if (ratio==0.5) point = mid(); else { point = lb()+ratio*diam(); // watch dog. note that since *this is // bisectable, we have next_float(left.lb()) < ub() if (point >= ub()) point=next_float(lb()); assert(point<ub()); } left = Interval(lb(), point); right = Interval(point, ub()); } return std::pair<Interval,Interval>(left,right); }
void setup_table() { for( int i = 0; i < 4096; i++ ) { seeded[i] = next_float(); } seeded[4096] = seeded[0]; }
IntervalVector Set::inflate_one_float(const IntervalVector& box) { IntervalVector inflated=box; for (int i=0;i<box.size();i++) { double lb=box[i].lb(); double ub=box[i].ub(); inflated[i]=Interval(lb==NEG_INFINITY? lb : previous_float(lb), ub==POS_INFINITY? ub : next_float(ub)); } return inflated; }