Пример #1
0
HRESULT CALLBACK CTexture::Draw2D(int iX, int iY, uint uiWidth, uint uiHeight, float fAngle, uint uiFrameIndex)
{
	if (_uiFrameWidth + _uiFrameHeight + uiFrameIndex == 0)
	{
		_pRender2D->DrawTexture((ITexture*)this, TPoint2((float)iX, (float)iY), TPoint2((float)uiWidth, (float)uiHeight), TRectF(0.f, 0.f, (float)_uiWidth, (float)_uiHeight), fAngle, EF_BLEND);
		return S_OK;
	}
	else
		return _pRender2D->DrawSpriteA((ITexture*)this, TPoint2((float)iX, (float)iY), TPoint2((float)uiWidth, (float)uiHeight), uiFrameIndex, fAngle, EF_BLEND);
}
Пример #2
0
void Item::Draw() const
{
	switch (objType)
	{
		case GOT_SCORE:
		case GOT_EXIT:
			pRender2D->DrawCircle(TPoint2(x, y), r, 32, Color, PF_FILL);
			break;

		case GOT_BLACK_SCORE:
			pRender2D->DrawCircle(TPoint2(x, y), r, 6, Color, PF_FILL);
			break;

		case GOT_BIG_SCORE:
		case GOT_HELP_SCORE:
			pRender2D->DrawCircle(TPoint2(x, y), r, 4, Color, PF_FILL);
	}
}
Пример #3
0
void Ghost::Draw() const
{
	int sign[4];
	double a = Angle;
	const double R = r / cos(a);

	if (DirX)
	{
		if (DirInc)
		{
			sign[0] = 1; sign[1] = -1;
			sign[2] = 1; sign[3] = 1;
		}
		else
		{
			sign[0] = -1; sign[1] = 1;
			sign[2] = -1; sign[3] = -1;
		}
	}
	else
	{
		a = M_PI / 2. - a;
		if (DirInc)
		{
			sign[0] = 1; sign[1] = 1;
			sign[2] = -1; sign[3] = 1;
		}
		else
		{
			sign[0] = -1; sign[1] = -1;
			sign[2] = 1; sign[3] = -1;
		}
	}

	const float cos_a = R * cos(a),
		sin_a = R * sin(a);

	glEnable(GL_STENCIL_TEST);
	glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
	pCoreRenderer->Clear(false, false, true);
	glStencilFunc(GL_ALWAYS, 1, ~0);
	glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);

	const TVertex2 triangle[] = { TVertex2(x, y, 0.f, 0.f, 1.f, 1.f, 1.f, 1.f),
		TVertex2(x + sign[0] * cos_a, y + sign[1] * sin_a, 0.f, 0.f, 1.f, 1.f, 1.f, 1.f),
		TVertex2(x + sign[2] * cos_a, y + sign[3] * sin_a, 0.f, 0.f, 1.f, 1.f, 1.f, 1.f) };

	pRender2D->DrawTriangles(NULL, triangle, 3, PF_FILL);

	glStencilFunc(GL_EQUAL, 0, ~0);
	glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
	glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);

	pRender2D->DrawCircle(TPoint2(x, y), r, 32, Color, PF_FILL);
	glDisable(GL_STENCIL_TEST);
}
Пример #4
0
//-------------------------
void CInputManager::updateMouse( SDL_Event & e ) {
  if( e.type == SDL_MOUSEBUTTONDOWN || e.type == SDL_MOUSEBUTTONUP ) {
    m_cur_mouse_state[ e.button.button ] = ( e.type == SDL_MOUSEBUTTONDOWN );
  } else if( e.type == SDL_MOUSEMOTION ) {
    m_mouse_pos = TPoint2( e.motion.x, e.motion.y );

    if( e.motion.xrel < 0 ) {
      m_mouse_mov_dir = MMD_LEFT;
    } else if( e.motion.xrel > 0 ) {
      m_mouse_mov_dir = MMD_RIGHT;
    } else if( e.motion.yrel < 0 ) {
      m_mouse_mov_dir = MMD_UP;
    } else if( e.motion.yrel > 0 ) {
      m_mouse_mov_dir = MMD_DOWN;
    } else {
      m_mouse_mov_dir = MMD_NONE;
    }
  }
}