void wxJigsawInputParameter::GetSize(wxDC & dc, wxCoord * w, wxCoord * h, double scale) { wxCoord shapeWidth(0), shapeHeight(0); if(m_NeedCalcLabelSize) { dc.GetTextExtent(m_Label, &m_LabelSize.x, &m_LabelSize.y, 0, 0, (wxFont *)&dc.GetFont()); m_NeedCalcLabelSize = false; } if(m_Shape) { m_Shape->GetSize(dc, &shapeWidth, &shapeHeight, scale); } else { wxSize defaultSize = wxJigsawInputParameter::GetDefaultParameterSize(); shapeWidth = defaultSize.GetWidth()*scale; shapeHeight = defaultSize.GetHeight()*scale; } if(w) { *w = m_LabelSize.GetWidth() + wxJigsawInputParameter::ParameterSpacing*scale + shapeWidth; } if(h) { *h = wxMax(m_LabelSize.GetHeight(), shapeHeight); } }
void GameObject::draw(WindowModule* wm, float now) { sf::RenderWindow* w = wm->getWindow(); if(body) { /*int width = w->GetWidth(); if (screenWidth != width) { screenWidth = width; sprite = getDrawable(); }*/ if(sprite) { float deltaTime = (now - lastTime) / timeStep; b2Vec2 nextPos = body->GetPosition(); b2Vec2 deltaPos = nextPos - lastPos; deltaPos *= deltaTime; b2Vec2 renderPos = lastPos + deltaPos; float rot = body->GetAngle(); float scaleW = wm->meterToPixel(shapeWidth()) / (float) spriteWidth(); float scaleH = wm->meterToPixel(shapeHeight()) / (float) spriteHeight(); sprite->SetCenter(spriteWidth()/2.0f, spriteHeight()/2.0f); sprite->SetScale(scaleW, scaleH); sprite->SetRotation( -rot * (180/3.14)); sprite->SetPosition(wm->meterToPixel(renderPos.x), wm->meterToPixel(renderPos.y)); w->Draw(*sprite); } } }