bool Vision::isEntityInVision(Entity e) { Coord point(e.getCenter()->x, e.getCenter()->y); VECTOR2 v1(getHeight() / 2, -(getWidth() / 4)); rotate2Dvector(&v1, getRadians() - 1.5707f); c1 = Coord(getCenter()->x + v1.x, getCenter()->y + v1.y); VECTOR2 v2(getHeight() / 2.0f, getWidth() / 4.0f); rotate2Dvector(&v2, getRadians() - 1.5707); c2 = Coord(getCenter()->x + v2.x, getCenter()->y + v2.y); c3 = Coord(getCenter()->x, getCenter()->y); /*stringstream ss; string s1, s2, s3, s4, s5, s6, s7, s8; ss.clear(); ss << point.x << ' ' << point.y << ' '; ss << c1.x << ' ' << c1.y << ' '; ss << c2.x << ' ' << c2.y << ' '; ss << c3.x << ' ' << c3.y << ' '; ss >> s1 >> s2 >> s3 >> s4 >> s5 >> s6 >> s7 >> s8;*/ /*text->print("testing if point (" + s1 + ", " + s2 + ") is within this triangle: \n" + "(" + s3 + ", " + s4 + ")\n" + "(" + s5 + ", " + s6 + ")\n" + "(" + s7 + ", " + s8 + ")\n", 300, 30);*/ if (coordInsideTriangle(point, c1, c2, c3)) { fire(e.getX(), e.getY()); return true; } return false; }
void addBullet(Ship* ship) { int i = newBullet(); if (i <0) { puts("No bullets left!"); return; } bullets[i].xPos=ship->xPos; bullets[i].yPos=ship->yPos; bullets[i].yVel=ship->yVel-sin(getRadians(ship->angle))*6; bullets[i].xVel=ship->xVel-cos(getRadians(ship->angle))*6; bullets[i].active = true; }
void Power::update(float frameTime) { Entity::update(frameTime); spriteData.x += frameTime * velocity.x; spriteData.y += frameTime * velocity.y; setRadians(getRadians()+POWERUP_ROTATION_SPEED); if (spriteData.x > GAME_WIDTH+powerNS::WIDTH*getScale()) { setActive(false); } else if (spriteData.x < 0) { setActive(false); } if (spriteData.y > GAME_HEIGHT+powerNS::HEIGHT*getScale()) { setActive(false); } else if (spriteData.y < 0) { setActive(false); } }
void Shuriken::update(float frameTime){ Entity::update(frameTime); setRadians(getRadians()+0.05); //update position based on velocity changes incPosition(D3DXVECTOR2(velocity*frameTime)); //apply new position spriteData.x = getPositionX(); spriteData.y = getPositionY(); }
void Boat::update(float frameTime){ Entity::update(frameTime); // arrow keys to move boat if (input->isKeyDown(VK_LEFT)) velocity.x = -boatNS::SPEED; else if (input->isKeyDown(VK_RIGHT)) velocity.x = boatNS::SPEED; else velocity.x = 0; spriteData.x += velocity.x * frameTime; // don't let the boat go off the screen if (spriteData.x < 0) spriteData.x = 0; if (spriteData.x + spriteData.width * BOAT_IMAGE_SCALE > GAME_WIDTH) spriteData.x = GAME_WIDTH - spriteData.width * BOAT_IMAGE_SCALE; if (getRadians() > PI / 64) rotationDir = false; if (getRadians() < -PI / 64) rotationDir = true; if (rotationDir) setRadians(getRadians() + (PI / 64 * frameTime)); else setRadians(getRadians() - (PI / 64 * frameTime)); }
void Boss::vectorTrack()//We're going to want to change this so that it takes an argument that is what we want to track { VECTOR2 vel = getCenterPoint()-targetEntity.getCenterPoint(); if(vel.x == 0 && vel.y==0) return; VECTOR2* foo = D3DXVec2Normalize(&vel, &vel); setVelocity(-vel); setRadians((atan((targetEntity.getCenterY()-getCenterY())/(targetEntity.getCenterX()-getCenterX())))-PI/2); if(targetEntity.getCenterX()>getCenterX()) setRadians(getRadians()+PI); }
void Gun::recoil(float frameTime) { if(mag != 0) { frameTime = 1; int recoil = mag->recoil - recoilReduction; if(recoil > 0) { setRadians(getRadians() + frameTime*((rand()%recoil)-(510*recoil/1000))*PI/180); } } }
void updateShips() { for (int i=0; i<MAX_CLIENTS; i++) { if (ships[i].acceleration) { ships[i].yVel-=sin(getRadians(ships[i].angle))*0.1; ships[i].xVel-=cos(getRadians(ships[i].angle))*0.1; } if (ships[i].shooting) { if (ships[i].bulletCooldown ==0) { addBullet(&ships[i]); ships[i].bulletCooldown = ships[i].bulletIntervall; } } ships[i].xPos += ships[i].xVel; ships[i].yPos += ships[i].yVel; if (ships[i].xPos > STAGE_WIDTH) ships[i].xPos=0; if (ships[i].xPos <0) ships[i].xPos=STAGE_WIDTH; if (ships[i].yPos > STAGE_HEIGHT) ships[i].yPos=0; if (ships[i].yPos <0) ships[i].yPos=STAGE_HEIGHT; ships[i].angle += ships[i].angleVel; if (ships[i].angle > 360) ships[i].angle-=360; if (ships[i].angle < 0) ships[i].angle+=360; if (ships[i].bulletCooldown>0) ships[i].bulletCooldown--; } }
float Angle::getTangent() const { return tanf(getRadians()); }
float Angle::getSine() const { return sinf(getRadians()); }
float Angle::getCosine() const { return cosf(getRadians()); }
double ossimUnitConversionTool::getValue(ossimUnitType unitType) const { switch(unitType) { case OSSIM_METERS: { return getMeters(); } case OSSIM_RADIANS: { return getRadians(); } case OSSIM_DEGREES: { return getDegrees(); } case OSSIM_US_SURVEY_FEET: { return getUsSurveyFeet(); } case OSSIM_FEET: { return getFeet(); } case OSSIM_SECONDS: { return getSeconds(); } case OSSIM_MINUTES: { return getMinutes(); } case OSSIM_NAUTICAL_MILES: { return getNauticalMiles(); } case OSSIM_MILES: { return getMiles(); } case OSSIM_MICRONS: { return getMicrons(); } case OSSIM_CENTIMETERS: { return getCentimeters(); } case OSSIM_MILLIMETERS: { return getMillimeters(); } case OSSIM_YARDS: { return getYards(); } case OSSIM_INCHES: { return getInches(); } case OSSIM_KILOMETERS: { return getKilometers(); } default: break; } return ossim::nan(); }
double Angle::getRadiansNotBounded() const { return getRadians(false); }
double Angle::getRadiansZeroTo2pi() const { return getRadians(true); }
void Test::test() { // sendHearbeat(false, MAV_STATE_STANDBY); // battery updateUI(); sendSystemStatus(100, 12.4); updateUI(); sendHomePosition( getRadians(59, 57, 11.44), // 59�'11.44"N getRadians(30, 18, 51.69), // 30�'51.69"E 0); updateUI(); sendCurrentPosition( getRadians(59, 57, 11.44), // 59�'11.44"N getRadians(30, 18, 51.69), // 30�'51.69"E 200); updateUI(); sendVfrHud( 10, // ground speed 10 m/s 180, // heading south (180 deg) 70, // 70% throttle 2); // climb rate 2 m/s down updateUI(); sendEkfStatusReport(0.9); updateUI(); // Base parameters sendParameter("WPNAV_SPEED", 500); sendParameter("WPNAV_SPEED_UP", 250); sendParameter("WPNAV_SPEED_DN", 150); sendParameter("RTL_ALT", 1500); sendParameter("RTL_ALT_FINAL", 0); sendParameter("LAND_SPEED", 50); sendParameter("BATT_CAPACITY", 5000); sendParameter("FS_BATT_MAH", 1000); sendParameter("FS_BATT_VOLTAGE", 13); updateUI(); //sendHearbeat(true); /* sendCurrentPosition( getRadians(59, 57, 37.56), // 59�'37.56"N getRadians(30, 18, 47.24), // 30�'47.24"E 10); */ // sendHearbeat(true, MAV_STATE_CRITICAL); sendStatusText(MAV_SEVERITY_CRITICAL, "Some very very very long status text."); updateUI(); sendStatusText(MAV_SEVERITY_CRITICAL, "TEST"); updateUI(); sendChannels(1100, 1500); updateUI(); sendHearbeat(true, MAV_STATE_ACTIVE); }
void GameObject::applyForcePolar(float heading, float magnitude) { float X = magnitude * cos(getRadians(heading)); float Y = magnitude * sin(getRadians(heading)); applyForceRect(X, Y); }
double Angle::getDegrees(bool zeroTo360) const { static const double degreesPerRadian = 360.0 / M_TWOPI; return degreesPerRadian * getRadians(zeroTo360); }
float Vector2::getAngle() const { return getRadians()*180.0/PI; }