void NosuchGraphics::ellipse(double x0, double y0, double w, double h) { DEBUGPRINT2(("Drawing ellipse xy0=%.3f,%.3f wh=%.3f,%.3f",x0,y0,w,h)); if ( m_filled ) { NosuchColor c = m_fill_color; glColor4d(c.r()/255.0f, c.g()/255.0f, c.b()/255.0f, m_fill_alpha); DEBUGPRINT2((" fill_color=%d %d %d alpha=%.3f",c.r(),c.g(),c.b(),m_fill_alpha)); glBegin(GL_TRIANGLE_FAN); double radius = w; glVertex2d(x0, y0); for ( double degree=0.0f; degree <= 360.0f; degree+=5.0f ) { glVertex2d(x0 + sin(degree2radian(degree)) * radius, y0 + cos(degree2radian(degree)) * radius); } glEnd(); } if ( m_stroked ) { NosuchColor c = m_stroke_color; glColor4d(c.r()/255.0f, c.g()/255.0f, c.b()/255.0f, m_stroke_alpha); DEBUGPRINT2((" stroke_color=%d %d %d alpha=%.3f",c.r(),c.g(),c.b(),m_stroke_alpha)); glBegin(GL_LINE_LOOP); double radius = w; for ( double degree=0.0f; degree <= 360.0f; degree+=5.0f ) { glVertex2d(x0 + sin(degree2radian(degree)) * radius, y0 + cos(degree2radian(degree)) * radius); } glEnd(); } if ( ! m_filled && ! m_stroked ) { DEBUGPRINT(("Hey, ellipse() called when both m_filled and m_stroked are off!?")); } }
void Flamethrower::onFire(b2Vec2 direction, bool constantFire, bool isPlayer) { direction.Normalize(); b2Mat22 matrix1 = b2Mat22(degree2radian(float(rand() % 600) / 100.0f)); b2Mat22 matrix2 = b2Mat22(degree2radian(float(rand() % 600) / 100.0f)); b2Mat22 matrix3 = b2Mat22(degree2radian(float(rand() % 600 - 300) / 100.0f)); direction = b2Mul(matrix1, direction); b2Vec2 direction2 = b2Mul(matrix2, direction); b2Vec2 direction3 = b2Mul(matrix3, direction); EntityFactory *entityFactory = new FlamethrowerBulletFactory(); EntityProperties& properties = entityFactory->getDefaultProperties(); properties.x = meter2pixel(this->getBody(0)->GetPosition().x); properties.y = meter2pixel(this->getBody(0)->GetPosition().y); properties.special = true; float speed = 0.7f; FlamethrowerBullet *flamethrowerBullet = (FlamethrowerBullet*)entityFactory->create(properties); flamethrowerBullet->getBody(0)->ApplyForce(speed * 0.75f * direction, this->getBody(0)->GetPosition()); flamethrowerBullet = (FlamethrowerBullet*)entityFactory->create(properties); flamethrowerBullet->getBody(0)->ApplyForce(speed * 0.75f * direction2, this->getBody(0)->GetPosition()); flamethrowerBullet = (FlamethrowerBullet*)entityFactory->create(properties); flamethrowerBullet->getBody(0)->ApplyForce(speed * 0.82f * direction3, this->getBody(0)->GetPosition()); }