本文整理汇总了C++中Vector2::GetY方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector2::GetY方法的具体用法?C++ Vector2::GetY怎么用?C++ Vector2::GetY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector2
的用法示例。
在下文中一共展示了Vector2::GetY方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawString
void CFontMaterial::DrawString( CDrawContext * pDrawContext, std::string text, float x, float y, float r, float g, float b, float a, int type ) {
float xtrans = 0.0f, ytrans = 0.0f;
float xoffset = 0.0f, yoffset = 0.0f;
pDrawContext->SetTexture( m_FontSheet.GetTexture() );
pDrawContext->SetDrawColor( r, g, b, a );
if( type & ( DRAW_TEXT_HORIZ_CENTER | DRAW_TEXT_VERT_CENTER ) ) {
Vector2< int > size = GetStringSize( text );
if( type & DRAW_TEXT_HORIZ_CENTER ) {
xoffset = ( float )-size.GetX() * .5f;
}
if( type & DRAW_TEXT_VERT_CENTER ) {
yoffset = ( float )-size.GetY() * .5f;
}
}
for( int i = 0; i < text.length(); i++ ) {
bool newline = false;
if( text[i] == '\n' )
newline = true;
if( !newline ) {
int c = text[i];
CFontCharacter fchar = m_Characters[c];
Vector2< float > size = fchar.m_Size;
Vector2< float > v1 = fchar.m_UpperLeftST;
Vector2< float > v2 = fchar.m_LowerRightST;
pDrawContext->StartDraw();
pDrawContext->SetPos( x + xoffset + xtrans + fchar.m_Left, y + yoffset + ytrans - fchar.m_Down + m_LargestBearingY );
pDrawContext->SetScale( size.GetX() , size.GetY() );
pDrawContext->SetTexCoord( v1.GetX(), v1.GetY(), v2.GetX(), v1.GetY(), v2.GetX(), v2.GetY(), v1.GetX(), v2.GetY() );
pDrawContext->EndDraw();
xtrans += fchar.m_Trans;
} else {
xtrans = 0;
ytrans += m_FontSize;
}
}
}
示例2:
Rectangle::Rectangle(float height, float width, Vector2 center)
{
a.Set(center.GetX() - width / 2, center.GetY() - height / 2);
b.Set(center.GetX() + width / 2, center.GetY() - height / 2);
c.Set(center.GetX() + width / 2, center.GetY() + height / 2);
d.Set(center.GetX() - width / 2, center.GetY() + height / 2);
}
示例3: GetOverlap
Vector2 AABB::GetOverlap(AABB other, bool makeIntegral) const
{
Vector2 overlap;
const AABB *left = _x < other._x ? this : &other;
const AABB *right = left == this ? &other : this;
overlap.SetX(left->_x + left->_width - right->_x);
if (left == this) overlap.SetX(overlap.GetX() * -1);
const AABB *top = _y < other._y ? this : &other;
const AABB *bottom = top == this ? &other : this;
overlap.SetY(top->_y + top->_height - bottom->_y);
if (top == this) overlap.SetY(overlap.GetY() * -1);
if (makeIntegral)
{
float x = overlap.GetX();
float y = overlap.GetY();
x = x < 0 ? ::floorf(x) : ::ceilf(x);
y = y < 0 ? ::floorf(y) : ::ceilf(y);
overlap.SetX(x);
overlap.SetY(y);
}
return overlap;
}
示例4: CollisionCheck
bool CircleCollider::CollisionCheck(Vector2& a_vPointOne,Vector2& a_vPointTwo)
{
Vector2 newCenter(m_vCenter.GetX() - a_vPointOne.GetX() ,m_vCenter.GetY() - a_vPointOne.GetY() );
Vector2 newPointTwo(a_vPointTwo.GetX() - a_vPointOne.GetX() ,a_vPointTwo.GetY() - a_vPointOne.GetY() );
float projection = newCenter.Norm().Dot(newPointTwo.Norm());
float sinofAngle = sqrt(1 - (projection * projection));
float lhs, rhs;
lhs = m_fRadius *m_fRadius;
rhs = newCenter.SqMagnatude() * sinofAngle;
return lhs >= rhs;
}
示例5: PosGrid
Vector2 Grid::PosGrid(Vector2 point)
{
int x = (int)((point.GetX() / CELL_SIZE));
int y = (int)((point.GetY() / CELL_SIZE));
return Vector2(x, y);
}
示例6:
bool Vector2::operator==(const Vector2& v)
{
if(x != v.GetX()) return false;
if(y != v.GetY()) return false;
return true;
}
示例7: GetStringHeight
int CFontMaterial::GetStringHeight( std::string text ) {
Vector2< int > v = GetStringSize( text );
return v.GetY();
}
示例8:
Matrix3 Matrix3::Scale(const Vector2& scale)
{
Matrix3 m;
m.m_[0] = scale.GetX();
m.m_[1] = scale.GetY();
return m;
}
示例9: Matrix
Ivy::Math::Matrix Ivy::Math::Matrix::Scale(Vector2 scale)
{
glm::mat4 scaled = glm::scale(values, Vector3(scale.GetX(), scale.GetY(),
0.0f).GetRawData());
return Matrix(scaled[0][0], scaled[0][1], scaled[0][2], scaled[0][3],
scaled[1][0], scaled[1][1], scaled[1][2], scaled[1][3],
scaled[2][0], scaled[2][1], scaled[2][2], scaled[2][3],
scaled[3][0], scaled[3][1], scaled[3][2], scaled[3][3]);
}
示例10: UpdateDirection
void FieldCharacter::UpdateDirection(Vector2 directionVector)
{
directionVector = directionVector.Normalize();
// We'll snap the player's direction vector according to
// the nearest direction for which we have an animation.
double angleToHorizontal = acos(directionVector.GetX());
// acos() only returns values from 0 to pi,
// so to get the full circle we need to check
// whether we're in the bottom two quandrants,
// and change the angle to account for this if so.
if (directionVector.GetY() > 0)
{
angleToHorizontal = 2 * M_PI - angleToHorizontal;
}
if (angleToHorizontal <= M_PI / 8 || angleToHorizontal > M_PI * 15 / 8)
{
SetSpriteDirection(FieldCharacterDirectionSide);
SetDirection(CharacterDirectionRight);
}
else if (angleToHorizontal > M_PI / 8 && angleToHorizontal <= M_PI * 3 / 8)
{
SetSpriteDirection(FieldCharacterDirectionDiagonalUp);
SetDirection(CharacterDirectionRight);
}
else if (angleToHorizontal > 3 * M_PI / 8 && angleToHorizontal <= M_PI * 5 / 8)
{
SetSpriteDirection(FieldCharacterDirectionUp);
}
else if (angleToHorizontal > 5 * M_PI / 8 && angleToHorizontal <= M_PI * 7 / 8)
{
SetSpriteDirection(FieldCharacterDirectionDiagonalUp);
SetDirection(CharacterDirectionLeft);
}
else if (angleToHorizontal > 7 * M_PI / 8 && angleToHorizontal <= M_PI * 9 / 8)
{
SetSpriteDirection(FieldCharacterDirectionSide);
SetDirection(CharacterDirectionLeft);
}
else if (angleToHorizontal > 9 * M_PI / 8 && angleToHorizontal <= M_PI * 11 / 8)
{
SetSpriteDirection(FieldCharacterDirectionDiagonalDown);
SetDirection(CharacterDirectionLeft);
}
else if (angleToHorizontal > 11 * M_PI / 8 && angleToHorizontal <= M_PI * 13 / 8)
{
SetSpriteDirection(FieldCharacterDirectionDown);
}
else if (angleToHorizontal > 13 * M_PI / 8 && angleToHorizontal <= M_PI * 15 / 8)
{
SetSpriteDirection(FieldCharacterDirectionDiagonalDown);
SetDirection(CharacterDirectionRight);
}
}
示例11: glGetUniformLocation
bool Shader::SetShaderVec2Parameter(const char* name, Vector2 vec2)
{
int locID = glGetUniformLocation(m_programID, name);
if (locID >= 0)
{
glUniform2f(locID, vec2.GetX(), vec2.GetY());
}
return true;
}
示例12: if
void MouseHelper::MouseOverText::Draw(Vector2 cursorPosition)
{
MLIFont *pMouseOverFont = CommonCaseResources::GetInstance()->GetFontManager()->GetFontFromId("MouseOverFont");
Vector2 cursorSize = GetCursorSize();
Vector2 mouseOverTextPosition = cursorPosition + Vector2(cursorSize.GetX() / 2, cursorSize.GetY()) - Vector2(pMouseOverFont->GetWidth(text) / 2, 0);
if (mouseOverTextPosition.GetX() < MouseOverTextMarginPx)
{
mouseOverTextPosition.SetX(MouseOverTextMarginPx);
}
else if (mouseOverTextPosition.GetX() + pMouseOverFont->GetWidth(text) > gScreenWidth - MouseOverTextMarginPx)
{
mouseOverTextPosition.SetX(gScreenWidth - MouseOverTextMarginPx - pMouseOverFont->GetWidth(text));
}
if (mouseOverTextPosition.GetY() + pMouseOverFont->GetHeight(text) > gScreenHeight - TabHeight - MouseOverTextMarginPx)
{
mouseOverTextPosition.SetY(mouseOverTextPosition.GetY() - cursorSize.GetY() - pMouseOverFont->GetHeight(text));
}
if (mouseOverTextPosition.GetY() + pMouseOverFont->GetHeight(text) > gScreenHeight - TabHeight - MouseOverTextMarginPx)
{
mouseOverTextPosition.SetY(gScreenHeight - TabHeight - MouseOverTextMarginPx - pMouseOverFont->GetHeight(text));
}
// We don't want the mouse over text to continue to follow the mouse cursor in the y-direction
// after it starts fading out, so we'll set the current mouse over text position such that
// we can retrieve the last y-position prior to fading out as its permanent y-position
// until the fade-out has completed.
if (!isFadingOut)
{
fadeOutMousePosition = mouseOverTextPosition;
}
else
{
mouseOverTextPosition.SetY(fadeOutMousePosition.GetY());
}
mouseOverTextPosition += Vector2(0, currentOffset);
pMouseOverFont->Draw(text, mouseOverTextPosition, Color(currentOpacity, 1.0, 1.0, 1.0));
}
示例13: Draw
void EvidenceDescription::Draw(Vector2 position)
{
EnsureEvidenceInformation();
pBackgroundImage->Draw(position);
if (pEvidenceSprite != NULL)
{
pEvidenceSprite->Draw(Vector2(position.GetX() + 3, position.GetY() + 3));
pNameFont->Draw(evidenceName, Vector2(position.GetX() + 128 + 10, position.GetY() + 3 + 5));
int totalDescriptionHeight = (int)(evidenceDescriptionLines.size() * pDescriptionFont->GetLineHeight() + (evidenceDescriptionLines.size() - 1) * descriptionLineSeparationHeight);
int currentY = (int)(position.GetY() + (5 + pNameFont->GetLineHeight() + 130 - totalDescriptionHeight) / 2);
for (unsigned int i = 0; i < evidenceDescriptionLines.size(); i++)
{
pDescriptionFont->Draw(evidenceDescriptionLines[i], Vector2(position.GetX() + 128 + 20, currentY));
currentY += pDescriptionFont->GetLineHeight() + descriptionLineSeparationHeight;
}
}
}
示例14: GetBoundingBox
RectangleWH HitBox::GetBoundingBox() const
{
double left = numeric_limits<double>::infinity();
double top = numeric_limits<double>::infinity();
double right = -numeric_limits<double>::infinity();
double bottom = -numeric_limits<double>::infinity();
for (unsigned int i = 0; i < collidableObjectList.size(); i++)
{
vector<Vector2> *pVertices = collidableObjectList[i]->GetVertices();
for (unsigned int j = 0; j < pVertices->size(); j++)
{
Vector2 vertex = (*pVertices)[j];
if (vertex.GetX() < left)
{
left = vertex.GetX();
}
if (vertex.GetX() > right)
{
right = vertex.GetX();
}
if (vertex.GetY() < top)
{
top = vertex.GetY();
}
if (vertex.GetY() > bottom)
{
bottom = vertex.GetY();
}
}
}
return RectangleWH(left, top, right - left, bottom - top);
}
示例15: ProjectileHit
void PlayerActor::ProjectileHit(Actor *prj)
{
if (_shieldActive)
{
if (((ProjectileActor*)prj)->IsReflectable())
{
Vector2 vel = prj->GetSpeed();
vel.SetX(vel.GetX() * -1);
vel.SetY(vel.GetY() * -1);
prj->SetSpeed(vel);
}
}
else
{
SetHealth(0);
}
}