本文整理汇总了C++中SRect类的典型用法代码示例。如果您正苦于以下问题:C++ SRect类的具体用法?C++ SRect怎么用?C++ SRect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SRect类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: intersect
//重なっていたらtrueを返す
bool SRect::intersect(const SRect& rc) const
{
if(rc.l()>m_r) return false;
if(rc.r()<m_l) return false;
if(rc.t()>m_b) return false;
if(rc.b()<m_t) return false;
return true;
}
开发者ID:hermixy,项目名称:Qt-BSch3V-Modified,代码行数:9,代码来源:coord.cpp
示例2: InitPrimitiveElement
bool GraphicsElementManager::InitPrimitiveElement( shared_ptr<PrimitiveElement> pElement,
const SRect& non_scaled_rect,
const SFloatRGBAColor& color,
int layer_index )
{
bool res = InitElement( pElement, layer_index );
if( !res )
return false;
pElement->SetColor( 0, color );
AABB2 non_scaled_aabb;
non_scaled_aabb.vMin.x = (float)non_scaled_rect.left;
non_scaled_aabb.vMin.y = (float)non_scaled_rect.top;
non_scaled_aabb.vMax.x = (float)non_scaled_rect.right;
non_scaled_aabb.vMax.y = (float)non_scaled_rect.bottom;
// set as local coord
// the element is owned by a group: local coord
// the element is not owned by any group: global coord
pElement->SetLocalTopLeftPos( non_scaled_rect.GetTopLeftCorner() );
pElement->SetSizeLTRB( non_scaled_aabb.vMin, non_scaled_aabb.vMax );
return true;
}
开发者ID:HermanHGF,项目名称:amorphous,代码行数:26,代码来源:GraphicsElementManager.cpp
示例3: pTextElement
shared_ptr<TextElement> GraphicsElementManager::CreateText( int font_id, const std::string& text,
const SRect& textbox, int align_h, int align_v,
const SFloatRGBAColor& color, int font_w, int font_h, int layer )
{
/* int index = GetVacantSlotIndex();
if( !RegisterToLayer( index, layer ) )
return shared_ptr<TextElement>();
*/
AABB2 aabb;
aabb.vMin = Vector2( (float)textbox.left, (float)textbox.top );
aabb.vMax = Vector2( (float)textbox.right, (float)textbox.bottom );
shared_ptr<TextElement> pTextElement( new TextElement( font_id, text, aabb, align_h, align_v, color ) );
pTextElement->SetFontSize( font_w, font_h );
bool res = InitElement( pTextElement, layer );
if( !res )
return shared_ptr<TextElement>();
// manager must be set to the element before calling SetLocalTopLeftPos()
// because it calls UpdateTextAlignment(), which calls GraphicsElementManager::GetFont()
pTextElement->SetLocalTopLeftPos( textbox.GetTopLeftCorner() );
pTextElement->UpdateTextAlignment();
// need to scale text element?
return pTextElement;
}
开发者ID:HermanHGF,项目名称:amorphous,代码行数:29,代码来源:GraphicsElementManager.cpp
示例4: testSelectionForDrag
//範囲を選択してドラッグ選択を行う
unsigned SXBSchTag::testSelectionForDrag(const SRect& rc)
{
if( rc.intersect(area()) ) {
return SELECT_ALL;
} else {
return 0;
}
}
开发者ID:hermixy,项目名称:Qt-BSch3V-Modified,代码行数:9,代码来源:xbschtag.cpp
示例5: testSelection
//範囲を指定して選択を行う
unsigned SXBSchLabel::testSelection(const SRect& rc)
{
if( rc.intersect(area()) ){
return SELECT_ALL;
}else{
return 0;
}
}
开发者ID:hermixy,项目名称:Qt-BSch3V-Modified,代码行数:9,代码来源:xbschlabel.cpp
示例6: testSelectionForDrag
//範囲を選択してドラッグ選択を行う
unsigned SXBSchComponent::testSelectionForDrag(const SRect& rc)
{
if( rc.intersect(bodyArea()) ){
return SELECT_ALL;
}else{
return 0;
}
}
开发者ID:hermixy,项目名称:Qt-BSch3V-Modified,代码行数:9,代码来源:xbschcomponent.cpp
示例7: RectThis
void CWindowOSXQT::PaintToBuffer(tuchar* puchBuffer, tuint32 uiInterleave, const SRect& rUpdate)
{
int iBytesNeeded = (mSize.iCX + 1) * (mSize.iCY + 1) * 4;
if (iBytesNeeded > miDrawBufferSize) {
if (mpcDrawBuffer) {
delete[] mpcDrawBuffer;
}
miDrawBufferSize = iBytesNeeded;
mpcDrawBuffer = new tuchar[miDrawBufferSize];
}
if (mpInvalidater->IsRectInvalidated() == true) {
// We need to update the buffer
SRect RectUpdate;
mpInvalidater->GetInvalidatedRect(RectUpdate);
mpInvalidater->Reset();
// Limit update rect to our actual size
SRect RectThis(SPos(0, 0), mSize);
RectUpdate.FitInside(RectThis);
// Limit update rect to, well, the update rect...
RectUpdate.FitInside(rUpdate);
GetPane()->OnDraw(RectUpdate);
if (mpControlOnTop) {
mpControlOnTop->OnDraw(RectUpdate);
}
}
// Copy to buffer delivered
tuint uiY;
for (uiY = rUpdate.iY; uiY < mSize.iCY && uiY < (rUpdate.iY + rUpdate.iCY); uiY++) {
tuchar* puchDest = puchBuffer + (uiInterleave * uiY);
tuchar* puchSource = mpcDrawBuffer + (4 * mSize.iCX * uiY);
tuint uiX;
for (uiX = rUpdate.iX; uiX < mSize.iCX && uiX < (rUpdate.iX + rUpdate.iCX); uiX++) {
((tuint32*)puchDest)[uiX] = ((tuint32*)puchSource)[uiX];
}
}
}
开发者ID:eriser,项目名称:koblo_software-1,代码行数:41,代码来源:CWindowOSXQT.cpp
示例8: push
void ScissorClipStack::push( Vec2i const& pos , Vec2i const& size , bool bOverlapPrev )
{
SRect rect;
rect.min = pos;
rect.max = pos + size;
if ( mStack.empty() )
{
mPrevEnable = glIsEnabled( GL_SCISSOR_TEST );
if ( !mPrevEnable )
glEnable( GL_SCISSOR_TEST );
}
else if ( bOverlapPrev )
{
if ( !rect.overlap( mStack.back() ) )
rect.max = rect.min;
}
Vec2i sizeRect = rect.getSize();
glScissor( rect.min.x , rect.min.y , sizeRect.x , sizeRect.y );
mStack.push_back( rect );
}
开发者ID:ADFLin,项目名称:QuadAssault,代码行数:21,代码来源:GUISystem.cpp
示例9: testIntersect
//範囲を指定して選択チェックを行う
bool SPtnObjCircle::testIntersect(const SRect& rc)
{
if(!rc.intersect(m_p0)) return false;
if(!rc.intersect(m_p1)) return false;
return true;
}
开发者ID:hermixy,项目名称:Qt-BSch3V-Modified,代码行数:7,代码来源:sptnobjcircle.cpp
示例10: qRedraw
//描画が必要かどうかを返す
bool SXBSchTag::qRedraw(const SRect& rc)
{
return rc.intersect(area());
}
开发者ID:hermixy,项目名称:Qt-BSch3V-Modified,代码行数:5,代码来源:xbschtag.cpp
示例11: testSelection
//範囲を指定して選択を行う
unsigned SXBSchLine::testSelection(const SRect& rc)
{
unsigned nOutcode1 = SetOutCode(m_p1,rc);
unsigned nOutcode2 = SetOutCode(m_p2,rc);
if(nOutcode1 & nOutcode2) return 0;
if((nOutcode1 == 0 )||(nOutcode2 == 0 )) return SELECT_ALL;
unsigned nOutcode = nOutcode1 | nOutcode2;
if(nOutcode == (OUTCODE_LEFT | OUTCODE_RIGHT)) return SELECT_ALL;
if(nOutcode == (OUTCODE_UPPER | OUTCODE_LOWER)) return SELECT_ALL;
int x,y;
int x1 = m_p1.x();
int y1 = m_p1.y();
int x2 = m_p2.x();
int y2 = m_p2.y();
if(nOutcode & OUTCODE_LEFT){ //片方が左に出ている
x=rc.l();
y=y1+((x-x1)*(y2-y1))/(x2-x1);
if(y >= rc.t() && y <= rc.b()) return SELECT_ALL;
}
if(nOutcode & OUTCODE_RIGHT){ //片方が右に出ている
x=rc.r();
y=y1+((x-x1)*(y2-y1))/(x2-x1);
if(y >= rc.t() && y <= rc.b()) return SELECT_ALL;
}
if(nOutcode & OUTCODE_UPPER){ //片方が上に出ている
y=rc.t();
x=x1+((y-y1)*(x2-x1))/(y2-y1);
if(x >= rc.l() && x <= rc.r()) return SELECT_ALL;
}
if(nOutcode & OUTCODE_LOWER){ //片方が下に出ている
y=rc.b();
x=x1+((y-y1)*(x2-x1))/(y2-y1);
if(x >= rc.l() && x <= rc.r()) return SELECT_ALL;
}
return 0;
}
开发者ID:hermixy,项目名称:Qt-BSch3V-Modified,代码行数:39,代码来源:xbschline.cpp
示例12: if
void Character::Update(float deltaTime, const Map& map)
{
const float kSpeed = 500.0f;
//Check horizontal movement
if (Input_IsKeyDown(Keys::RIGHT))
{
mVelocity.x = kSpeed * deltaTime;
}
else if (Input_IsKeyDown(Keys::LEFT))
{
mVelocity.x = -kSpeed * deltaTime;
}
else
{
mVelocity.x = 0.0f;
}
// Check collision
SRect bb = GetBoundingBox();
SRect newbb = bb + SVector2(mVelocity.x, 0.0f);
SRect rightbb = map.GetBoundingBoxFromSegment(newbb.GetRightSegment());
SRect leftbb = map.GetBoundingBoxFromSegment(newbb.GetLeftSegment());
// Right collision
if (mVelocity.x > 0.0f && rightbb.IsValid())
{
mPosition.x += (int)(rightbb.min.x - bb.max.x) - 1.0f;
}
// Left collision
else if (mVelocity.x < 0.0f && leftbb.IsValid())
{
mPosition.x += (int)(leftbb.max.x - bb.min.x) + 1.0f;
}
else
{
mPosition.x += (int)mVelocity.x;
}
//Check vertical movement
//if (Input_IsKeyDown(Keys::DOWN))
//{
// mVelocity.y = kSpeed * deltaTime;
//}
//else if (Input_IsKeyDown(Keys::UP))
//{
// mVelocity.y = -kSpeed * deltaTime;
//}
//else
//{
// mVelocity.y = 0.0f;
//}
if(!mJumping && Input_IsKeyPressed(Keys::UP))
{
mVelocity.y = -30.0f;
mJumping = true;
}
else
{
mVelocity.y += 100.0f * deltaTime;
}
mVelocity.y = Min(mVelocity.y, 30.0f);
// Check collision
newbb = bb + SVector2(0.0f, mVelocity.y);
SRect bottombb = map.GetBoundingBoxFromSegment(newbb.GetBottomSegment());
SRect topbb = map.GetBoundingBoxFromSegment(newbb.GetTopSegment());
// Bottom collision
if(mVelocity.y > 0.0f && bottombb.IsValid())
{
mPosition.y += (int)(bottombb.min.y - bb.max.y) - 1.0f;
mVelocity.y = 0.0f;
mJumping = false;
}
// Top collision
else if(mVelocity.y < 0.0f && topbb.IsValid())
{
mPosition.y += (int)(topbb.max.y - bb.min.y) + 1.0f;
mVelocity.y = 0.0f;
}
else
{
mPosition.y += (int)mVelocity.y;
}
}
开发者ID:bretthuff22,项目名称:Breaker,代码行数:92,代码来源:Character.cpp
示例13: rcDraw
//描画が必要かどうかを返す
bool SXBSchLine::qRedraw(const SRect& rc)
{
SRect rcDraw(rc.l()-1,rc.t()-1,rc.r()+1,rc.b()+1);
if(testSelection(rcDraw)) return true;
else return false;
}
开发者ID:hermixy,项目名称:Qt-BSch3V-Modified,代码行数:7,代码来源:xbschline.cpp
示例14: switch
tbool CScrollBar::OnMouse(EMouseMsg MouseMsg, const SPos& Pos)
{
if (!IsVisible()) {
return false;
}
if (CPane::OnMouse(MouseMsg, Pos)) {
return true;
}
if (mbScrolling) {
// We're currently scrolling
switch(MouseMsg) {
case MouseMove:
{
switch(mType) {
case TypeHorizontal:
{
// Calculate the mouse delta
tint iMouseDelta = Pos.iX - mMousePosOrg.iX;
// Calculate where we want the handle to be
tint iHandlePosX = mScrollBarRectOrg.iX + iMouseDelta;
// Calculate movememt from mouse delta
std::list<IControl*>::iterator it = mControls.begin();
if (mControls.size() > 2) {
it++;
}
IControl* pControl = *it++;
SRect RctArrowLeft;
pControl->GetRect(RctArrowLeft);
// Left-most possible handle position
SPos PosLeftMost(RctArrowLeft.iX + RctArrowLeft.iCX, RctArrowLeft.iY);
pControl = *it;
SPos PosRightArrow;
pControl->GetPos(PosRightArrow);
tint iMaxWidth = PosRightArrow.iX - PosLeftMost.iX;
// Calculate the relative width we occupy
tfloat64 fWidthRelative = mScrollPos.VisibleRect.iCX / (double)mScrollPos.AreaSize.iCX;
// Calculate the ralative position to be
tfloat64 fPositionRelative = (iHandlePosX - PosLeftMost.iX) / (iMaxWidth - (fWidthRelative * iMaxWidth));
// Update scrolling position
mScrollPos = mScrollPosOrg;
mScrollPos.VisibleRect.iX = (int)((fPositionRelative * (mScrollPos.AreaSize.iCX - mScrollPos.VisibleRect.iCX)) + 0.5f);
// Limit scrolling position
if (mScrollPos.VisibleRect.iX < 0) {
mScrollPos.VisibleRect.iX = 0;
}
if (mScrollPos.VisibleRect.iX > mScrollPos.AreaSize.iCX - mScrollPos.VisibleRect.iCX) {
mScrollPos.VisibleRect.iX = mScrollPos.AreaSize.iCX - mScrollPos.VisibleRect.iCX;
}
// Redraw and set scroll pos (which will cause scroll pane to redraw)
CControl::Redraw();
mpScrollPane->SetScrollPos(mScrollPos);
SetValue(0);
}
break;
case TypeVertical:
{
// Calculate the mouse delta
tint iMouseDelta = Pos.iY - mMousePosOrg.iY;
// Calculate where we want the handle to be
tint iHandlePosY = mScrollBarRectOrg.iY + iMouseDelta;
// Calculate movememt from mouse delta
std::list<IControl*>::iterator it = mControls.begin();
if (mControls.size() > 2) {
it++;
}
IControl* pControl = *it++;
SRect RctArrowTop;
pControl->GetRect(RctArrowTop);
// Top-most possible handle position
SPos PosTopMost(RctArrowTop.iX, RctArrowTop.iY + RctArrowTop.iCY);
pControl = *it;
SPos PosBottomArrow;
pControl->GetPos(PosBottomArrow);
tint iMaxHeight = PosBottomArrow.iY - PosTopMost.iY;
// Calculate the relative height we occupy
tfloat64 fHeightRelative = mScrollPos.VisibleRect.iCY / (double)mScrollPos.AreaSize.iCY;
// Calculate the ralative position to be
tfloat64 fPositionRelative = (iHandlePosY - PosTopMost.iY) / (iMaxHeight - (fHeightRelative * iMaxHeight));
// Update scrolling position
mScrollPos = mScrollPosOrg;
mScrollPos.VisibleRect.iY = (int)((fPositionRelative * (mScrollPos.AreaSize.iCY - mScrollPos.VisibleRect.iCY)) + 0.5f);
//.........这里部分代码省略.........
开发者ID:eriser,项目名称:koblo_software-1,代码行数:101,代码来源:CScrollBar.cpp
示例15: GetButtonRect
SRect CGM_Slider::GetLocalButtonRectInOwnerDialogCoord()
{
SRect rect = GetButtonRect();
rect.Offset( -GetOwnerDialog()->GetBoundingBox().GetTopLeftCorner() );
return rect;
}
开发者ID:HermanHGF,项目名称:amorphous,代码行数:6,代码来源:GM_Slider.cpp
示例16: if
void Character::Update(float deltaTime, const Map& map, const SVector2& renderOffset)
{
const float kSpeed = 256.0f;
// Check horizontal movement
if(Input_IsKeyDown(Keys::RIGHT))
{
mVelocity.x = kSpeed * deltaTime;
mSprite.SetRotation(1.575f);
}
else if(Input_IsKeyDown(Keys::LEFT))
{
mVelocity.x = -kSpeed * deltaTime;
mSprite.SetRotation(-1.575f);
}
else
{
mVelocity.x = 0.0f;
}
// Check collision
SRect bb = GetBoundingBox(renderOffset);
SRect newbb = bb + SVector2(mVelocity.x, 0.0f);
SLineSegment tempRightLS(newbb.GetRightSegment().from.x - renderOffset.x,
newbb.GetRightSegment().from.y - renderOffset.y,
newbb.GetRightSegment().to.x - renderOffset.x,
newbb.GetRightSegment().to.y - renderOffset.y);
SLineSegment tempLeftLS(newbb.GetLeftSegment().from.x - renderOffset.x,
newbb.GetLeftSegment().from.y - renderOffset.y,
newbb.GetLeftSegment().to.x - renderOffset.x,
newbb.GetLeftSegment().to.y - renderOffset.y);
SRect rightbb = map.GetBoudingBoxFromSegment(tempRightLS);
SRect leftbb = map.GetBoudingBoxFromSegment(tempLeftLS);
Graphics_DebugRect(bb, 0xF04BC3);
Graphics_DebugRect(newbb, 0x004BC3);
Graphics_DebugRect(rightbb, 0xF04B00);
Graphics_DebugRect(leftbb, 0xF000C3);
// Right Collision
if(mVelocity.x > 0.0f && rightbb.IsValid())
{
mPosition.x += static_cast<int>(rightbb.min.x - bb.max.x) - 1.0f;
}
// Left Collision
else if(mVelocity.x < 0.0f && leftbb.IsValid())
{
mPosition.x += static_cast<int>(leftbb.max.x - bb.min.x) + 1.0f;
}
else
{
mPosition.x += static_cast<int>(mVelocity.x);
}
// Check vertical movement
if(Input_IsKeyDown(Keys::DOWN))
{
mVelocity.y = kSpeed * deltaTime;
mSprite.SetRotation(3.15f);
}
else if(Input_IsKeyDown(Keys::UP))
{
mVelocity.y = -kSpeed * deltaTime;
mSprite.SetRotation(0.0f);
}
else
{
mVelocity.y = 0.0f;
}
// Check collision
newbb = bb + SVector2(0.0f, mVelocity.y);
SRect topbb = map.GetBoudingBoxFromSegment(newbb.GetTopSegment());
SRect bottombb = map.GetBoudingBoxFromSegment(newbb.GetBottomSegment());
// Top Collision
if(mVelocity.y < 0.0f && topbb.IsValid())
{
mPosition.y += static_cast<int>(topbb.max.y - bb.min.y) + 1.0f;
}
// Bottom Collision
else if(mVelocity.y > 0.0f && bottombb.IsValid())
{
mPosition.y += static_cast<int>(bottombb.min.y - bb.max.y) - 1.0f;
}
else
{
mPosition.y += static_cast<int>(mVelocity.y);
}
mPosition += mVelocity;
}
开发者ID:Khillasaurus,项目名称:School,代码行数:94,代码来源:Character.cpp
示例17: SFloatRGBAColor
void CGM_StdSliderRenderer::Init( CGM_Slider& slider )
{
// CGM_StdStaticRenderer::Init( CGM_Static *pStatic );
// slider frame
const SFloatRGBAColor& normal_color = m_aColor[CGM_Control::STATE_NORMAL];
const SFloatRGBAColor& bg_color = SFloatRGBAColor(0.0f,0.0f,0.0f,0.6f);
m_pRect = m_pGraphicsElementManager->CreateRect( slider.GetLocalRect(), bg_color, normal_color, 2 );
// m_pFrameRect = m_pGraphicsElementManager->CreateFrameRect( slider.GetLocalRect(), normal_color, 2 );
// slider button
SRect btn_rect = slider.GetButtonRect();
SRect local_btn_rect = RectLTWH( 0, 0, btn_rect.GetWidth(), btn_rect.GetHeight() );
m_pSliderButtonRect = m_pGraphicsElementManager->CreateRect( local_btn_rect, bg_color, normal_color, 2 );
// m_pSliderButtonFrameRect = m_pGraphicsElementManager->CreateFrameRect( local_btn_rect, normal_color, 2 );
SRect dot_rect = local_btn_rect;
dot_rect.Inflate( -dot_rect.GetWidth() / 4, -dot_rect.GetHeight() / 4 );
m_pSliderButtonDot = m_pGraphicsElementManager->CreateFillRect( dot_rect, normal_color, 2 );
const SRect slider_rect = slider.GetBoundingBox();
const SPoint slider_topleft = slider_rect.GetTopLeftCorner(); // global
const SPoint btn_local_topleft = slider.GetLocalButtonRectInOwnerDialogCoord().GetTopLeftCorner(); // local coord of owner dialog
// subgroup for slider button
vector<boost::shared_ptr<GraphicsElement> > vecpButtonElement;
vecpButtonElement.push_back( m_pSliderButtonRect );
// vecpButtonElement.push_back( m_pSliderButtonFrameRect );
vecpButtonElement.push_back( m_pSliderButtonDot );
m_pSliderButtonRect->SetLocalTopLeftPos( Vector2(0,0) );
// m_pSliderButtonFrameRect->SetLocalTopLeftPos( SPoint(0,0) );
m_pSliderButtonDot->SetLocalTopLeftPos( SPoint(0,0) + dot_rect.GetTopLeftCorner() );
m_pSliderButton = m_pGraphicsElementManager->CreateGroup( vecpButtonElement, btn_local_topleft );
// For slider button elements, the following 2 things need to be done separately
// 1. register to parent dialog renderer
// - register the subgroup of slider button elements
// 2. set local layer offsets
// - set for each element
// register the subgroup to the parent dialog renderer
RegisterGraphicsElementToParentDialog( m_pSliderButton );
// set different local layer offset for each grouped element
SetLocalLayerOffset( 0, m_pSliderButtonDot );
// SetLocalLayerOffset( 0, m_pSliderButtonFrameRect );
SetLocalLayerOffset( 1, m_pSliderButtonRect );
// register elements and set local layer offset to determine rendering order
// - these guys don't belong to any subgroup of the renderer so each of them can be
// registered with a single call of RegisterGraphicsElement()
// RegisterGraphicsElement( 2, m_pFrameRect );
RegisterGraphicsElement( 3, m_pRect );
// register elements that chages colors depending on states
// RegisterColoredElement( m_pFrameRect );
// RegisterColoredElement( m_pSliderButtonFrameRect );
RegisterColoredElement( m_pRect->FrameElement() );
RegisterColoredElement( m_pSliderButtonRect->FrameElement() );
}
开发者ID:HermanHGF,项目名称:amorphous,代码行数:62,代码来源:GM_StdControlRenderer.cpp
示例18: GetBoundingBox
void NPC::CheckCollision(float fSeconds, Map& map, Character& character) {
// Check collision
SRect bb = GetBoundingBox();
SRect newbb = bb + SVector2(mVelocity.x, 0.0f);
SRect rightbb = map.GetBoundingBoxFromSegment(newbb.GetRightSegment(),
*this, character);
SRect leftbb = map.GetBoundingBoxFromSegment(newbb.GetLeftSegment(), *this,
character);
// Right collision
if (mVelocity.x > 0.0f && rightbb.IsValid()) {
mNPCData.mPosition.x += static_cast<int>(rightbb.min.x - bb.max.x)
- 1.0f;
}
// Left collision
else if (mVelocity.x < 0.0f && leftbb.IsValid()) {
mNPCData.mPosition.x += static_cast<int>(leftbb.max.x - bb.min.x)
+ 1.0f;
} else {
mNPCData.mPosition.x += static_cast<int>(mVelocity.x);
}
// Check collision
newbb = bb + SVector2(0.0f, mVelocity.y);
SRect bottombb = map.GetBoundingBoxFromSegment(newbb.GetBottomSegment(),
*this, character);
SRect topbb = map.GetBoundingBoxFromSegment(newbb.GetTopSegment(), *this,
character);
// Bottom collision
if (mVelocity.y > 0.0f && bottombb.IsValid()) {
mNPCData.mPosition.y += static_cast<int>(bottombb.min.y - bb.max.y)
- 1.0f;
mVelocity.y = 0.0f;
Graphics_DebugRect(newbb + sOffset, 0xff00ff);
Graphics_DebugRect(bottombb + sOffset, 0xff0000);
}
// Top collision
else if (mVelocity.y < 0.0f && topbb.IsValid()) {
mNPCData.mPosition.y += static_cast<int>(topbb.max.y - bb.min.y) + 1.0f;
mVelocity.y = 0.0f;
Graphics_DebugRect(newbb + sOffset, 0xff00ff);
Graphics_DebugRect(topbb + sOffset, 0xff0000);
} else {
mNPCData.mPosition.y += static_cast<int>(mVelocity.y);
}
}
开发者ID:pandaforks,项目名称:Mirage--,代码行数:48,代码来源:NPC.cpp
示例19: run
inline void CImageClipper::run()
{
if( !m_pBitmapImage )
return;
// TODO: Add CBitmapImage::GetBPP()
int bits_per_pixel = FreeImage_GetBPP( m_pBitmapImage->GetFBITMAP() );
const int dest_w = m_DestRegion.GetWidth();
const int dest_h = m_DestRegion.GetHeight();
CBitmapImage img( dest_w, dest_h, bits_per_pixel );
int src_height = m_pBitmapImage->GetHeight();
int x, y;
int sx = m_DestRegion.left;
int sy = m_DestRegion.top;
U8 r, g, b, a;
a = 0xFF;
RGBQUAD quad;
for( x=0; x<dest_w; x++)
{
for( y=0; y<dest_h; y++)
{
// Error - fix this
// m_pBitmapImage->GetPixel( sx + x, sy + y, r, g, b, a );
FreeImage_GetPixelColor( m_pBitmapImage->GetFBITMAP(),
sx + x,
src_height - ( sy + y ) - 1,
&quad );
r = quad.rgbRed;
g = quad.rgbGreen;
b = quad.rgbBlue;
// Error - fix this
// img.SetPixel( x, y, r, g, b, a );
FreeImage_SetPixelColor( img.GetFBITMAP(), x, dest_h - y - 1, &quad );
}
}
img.SaveToFile( m_DestFilepath );
}
开发者ID:HermanHGF,项目名称:amorphous,代码行数:44,代码来源:ImageClipper.hpp
注:本文中的SRect类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论