1 /*---------------------------------------------------------------------------* 2 Project: NintendoWare 3 File: SmRectCollision.h 4 5 Copyright (C)2009-2010 Nintendo Co., Ltd./HAL Laboratory, Inc. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Revision: 1 $ 14 *---------------------------------------------------------------------------*/ 15 #ifndef SM_RECT_COLLISION_H_ 16 #define SM_RECT_COLLISION_H_ 17 18 #include <nw/ut.h> 19 20 //------------------------------------------------------------------------------ 21 // ��`�R���W���� 22 class SmRectCollision 23 { 24 public: 25 // �R���X�g���N�^ SmRectCollision()26 SmRectCollision() 27 { 28 SetRect( 0.f, 0.f, 0.f, 0.f ); 29 } 30 31 // �f�X�g���N�^ ~SmRectCollision()32 ~SmRectCollision(){} 33 34 // ��`��ݒ� SetRect(f32 x,f32 y,f32 w,f32 h)35 void SetRect( f32 x, f32 y, f32 w, f32 h ) 36 { 37 m_Collision.SetOriginAndSize( x, y, w, h ); 38 } SetRect(nw::ut::Rect & rect)39 void SetRect( nw::ut::Rect& rect ) 40 { 41 m_Collision = rect; 42 } 43 44 // �R���W�����͈͓��`�F�b�N CheckInner(u16 x,u16 y)45 bool CheckInner( u16 x, u16 y ) 46 { 47 f32 posx = static_cast<f32>(x); 48 f32 posy = static_cast<f32>(y); 49 50 f32 colx = m_Collision.GetX(); 51 f32 coly = m_Collision.GetY(); 52 53 f32 colw = m_Collision.GetWidth(); 54 f32 colh = m_Collision.GetHeight(); 55 56 57 if ( colx < posx ) 58 { 59 if ( posx < colx + colw ) 60 { 61 if ( coly < posy ) 62 { 63 if ( posy < coly + colh ) 64 { 65 return true; 66 } 67 } 68 } 69 } 70 return false; 71 } 72 73 // �ʒu��ݒ� SetXY(f32 x,f32 y)74 void SetXY( f32 x, f32 y ) 75 { 76 m_Collision.MoveTo( x, y ); 77 } 78 79 // �ʒu�����Z AddXY(f32 x,f32 y)80 void AddXY( f32 x, f32 y ) 81 { 82 m_Collision.left += x; 83 m_Collision.top += x; 84 m_Collision.right += y; 85 m_Collision.bottom += y; 86 } 87 88 // �ʒu���擾���܂��B GetX()89 f32 GetX() const { return m_Collision.GetX(); } GetY()90 f32 GetY() const { return m_Collision.GetY(); } 91 92 93 // �c/�����擾���܂��B GetWidth()94 f32 GetWidth() const { return m_Collision.GetWidth(); } GetHeight()95 f32 GetHeight() const { return m_Collision.GetHeight(); } 96 97 98 // ���C�A�E�g�̋�`��ݒ� SetLytRect(nw::ut::Rect & rect)99 void SetLytRect( nw::ut::Rect& rect ) 100 { 101 m_Collision.left = rect.left; 102 m_Collision.top = -rect.top; 103 m_Collision.right = rect.right; 104 m_Collision.bottom = -rect.bottom; 105 } 106 107 nw::ut::Rect m_Collision; 108 }; 109 110 #endif // SM_RECT_COLLISION_H_ 111