1 BOOL PhysicalObject::Draw(cpVect PlayerLoc, sf::Color GlowColor) 2 { 3 cpFloat Angle = cpBodyGetAngle(mpBody); 4 cpFloat Itemx = (cpFloat)mpApp->GetWidth()/2; 5 cpFloat Itemy = (cpFloat)mpApp->GetHeight()/2; 6 BOOL bDraw = TRUE; 7 mpSprite->SetRotation(Angle*(180.0f/PI)); 8 9 if (!cpveql(PlayerLoc, cpvzero)) 10 { 11 // Locate the sprite based off player's location 12 Itemx = (cpFloat)(mpApp->GetWidth()/2) + (mpBody->p.x - PlayerLoc.x); 13 Itemy = (cpFloat)(mpApp->GetHeight()/2) + (mpBody->p.y - PlayerLoc.y); 14 15 if (!((Itemx > -(cpFloat)mpImage->GetWidth()) && 16 (Itemx < (cpFloat)mpApp->GetWidth() + (cpFloat)mpImage->GetWidth()) && 17 (Itemy > -(cpFloat)mpImage->GetHeight()) && 18 (Itemy < (cpFloat)mpApp->GetHeight() + (cpFloat)mpImage->GetHeight()))) 19 { 20 bDraw = FALSE; 21 } 22 } 23 24 if (bDraw) 25 { 26 mpSprite->SetPosition(Itemx, Itemy); 27 28 // Draw shadow 1st if depth 29 if (mDepth > 0.001f) 30 { 31 cpFloat Radius = cpCircleShapeGetRadius(mpShape); 32 33 sf::Shape oCircle = sf::Shape::Circle(Itemx+5.0, Itemy+5.0, mDepth*Radius*0.80f, 34 sf::Color(0, 0, 0, 150)); 35 36 mpApp->Draw(oCircle); 37 } 38 39 mpApp->Draw(*mpSprite); 40 41 // If we get glow alpha and we have glow image 42 if (GlowColor.a && mpGlowSprite) 43 { 44 if (!cpveql(PlayerLoc, cpvzero)) 45 { 46 mpGlowSprite->SetPosition(Itemx, Itemy); 47 } 48 else 49 { 50 mpGlowSprite->SetPosition(mpApp->GetWidth()/2, mpApp->GetHeight()/2); 51 } 52 53 mpGlowSprite->SetRotation(Angle*(180.0f/PI)); 54 mpGlowSprite->SetColor(GlowColor); 55 56 mpApp->Draw(*mpGlowSprite); 57 } 58 } 59 return TRUE; 60 }