当前位置: 首页>>代码示例>>C++>>正文


C++ drawRect函数代码示例

本文整理汇总了C++中drawRect函数的典型用法代码示例。如果您正苦于以下问题:C++ drawRect函数的具体用法?C++ drawRect怎么用?C++ drawRect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了drawRect函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: updatePositions

void updatePositions()
{
	oldPaddle = paddle;
	oldBall = ball;

	if (KEY_DOWN_NOW(BUTTON_RIGHT))
	{
		paddle.x = min(paddle.x + PADDLE_SPEED, GAME_WIDTH - PADDLE_WIDTH);

		if (ball.onPaddle)
			ball.x = paddle.x + PADDLE_WIDTH / 2;
	}

	if (KEY_DOWN_NOW(BUTTON_LEFT))
	{
		paddle.x = max(paddle.x - PADDLE_SPEED, 0);

		if (ball.onPaddle)
			ball.x = paddle.x + PADDLE_WIDTH / 2;
	}

	//release ball from paddle
	if (ball.onPaddle && KEY_DOWN_NOW(BUTTON_A))
	{
		ball.onPaddle = FALSE;
		ball.xspeed = 1;
		ball.yspeed = -3;

		ball.y -= 1; //give it one pixel of space so it doesn't "collide" with paddle right away
	}

	//--------------------------CHECK FOR COLLISIONS-------------------------------//

	//check collision with right boundary
	if (collisionRect(ball.x, ball.y, ball.x + BALL_SIZE, ball.y + BALL_SIZE, GAME_WIDTH, 0, GAME_WIDTH + 10, GAME_HEIGHT))
	{
		ball.xspeed = -ball.xspeed;
		ball.x -= 2;
	}

	//check collision with top boundary
	if (collisionRect(ball.x, ball.y, ball.x + BALL_SIZE, ball.y + BALL_SIZE, 0, -10, GAME_WIDTH, 0))
	{
		ball.yspeed = -ball.yspeed;
		ball.y += 2;
	}

	//check collision with left boundary
	if (collisionRect(ball.x, ball.y, ball.x + BALL_SIZE, ball.y + BALL_SIZE, -10, 0, 0, GAME_HEIGHT))
	{
		ball.xspeed = -ball.xspeed;
		ball.x += 2;
	}

	//check collision with bricks
	for (int i = 0; i < NUM_OF_BRICKS; i++)
	{
		if (brickArray[i].health && collisionRect(ball.x, ball.y, ball.x + BALL_SIZE, ball.y + BALL_SIZE, brickArray[i].x, brickArray[i].y,
			brickArray[i].x + BRICK_WIDTH, brickArray[i].y + BRICK_HEIGHT))
		{
			int ballxmid = ball.x + BALL_SIZE/2;
			int ballymid = ball.y + BALL_SIZE/2;
			int brickxmid = brickArray[i].x + BRICK_WIDTH/2;
			int brickymid = brickArray[i].y + BRICK_HEIGHT/2;

			//slope of the vector pointing from the ball to the brick
			int deltax = brickxmid - ballxmid;
			int deltay = brickymid - ballymid;

			//below or above brick
			if (abs(deltax) < 2 * abs(deltay) + 2) // abs(dy/dx) > 1/2 			(visual->)  \_____/
			{
				ball.yspeed = -ball.yspeed;
				ball.y += signOf(ball.yspeed) * 2; //"push it out of brick just a bit"
			}
			//side of brick
			else
			{
				ball.xspeed = -ball.xspeed;
				ball.x += signOf(ball.xspeed) * 2; //"push it out of brick just a bit"
			}



			brickArray[i].health -= 1;

			if (!brickArray[i].health)
			{
				//draw part of the background image that was previously hidden
				drawImageExt3(brickArray[i].x, brickArray[i].y, brickArray[i].x, brickArray[i].y, BRICK_WIDTH, BRICK_HEIGHT, gtech);
				bricksLeft --;
   				sprintf(bricksString, "%d", bricksLeft);  		//store lives as a string

   				waitForVblank();
   				drawRect(215, 85, 12, 8, RGB(6, 0, 6));
    			drawString(215, 85, bricksString, WHITE);
			}
		}
	}

//.........这里部分代码省略.........
开发者ID:ClysmiC,项目名称:breakout_gba,代码行数:101,代码来源:main.c

示例2: drawRect

void WPainter::drawRect(const WRectF& rectangle)
{
    drawRect(rectangle.x(), rectangle.y(), rectangle.width(), rectangle.height());
}
开发者ID:nkabir,项目名称:wt,代码行数:4,代码来源:WPainter.C

示例3: rect

void AxisBase::drawAxisData(QPainter &p)
{
    PlotterBase *plotter = (PlotterBase*)parent();
    QRect rect(plotter->contentsRect());

    double start = m_min;
    double end = m_max;

    int p_start, p_end;
    calculatePoints(p_start, p_end);

    switch (m_orient)
    {
        case Qt::Vertical:
        {
            p.setPen(m_pen);
            p.drawLine(m_offset+2, p_start, m_offset+2, p_end);

            if (m_minor > 1e-100)
            {
                int prevTick = INT_MAX/2;

                for (double i = start; i <= end; i += m_minor)
                {
                    int p_d = toView(i);

                    if (p_d < prevTick-1)
                    {
                        prevTick = p_d;
                        p.setPen(m_minorPen);
                        p.drawLine(m_offset+1, p_d, m_offset+3, p_d);

                        if (m_minorGridPen != Qt::NoPen)
                        {
                            p.setPen(m_minorGridPen);
                            p.drawLine(m_offset+2, p_d, rect.right(), p_d);
                        }
                    }
                }
            }

            if (m_major > 1e-100)
            {
                QRect prevRect;
                int prevTick = INT_MAX/2;

                for (double i = start; i <= end; i += m_major)
                {
                    int p_d = toView(i);

                    if (p_d < prevTick-1)
                    {
                        prevTick = p_d;
                        p.setPen(m_majorPen);
                        p.drawLine(m_offset+0, p_d, m_offset+4, p_d);

                        if (m_majorGridPen != Qt::NoPen)
                        {
                            p.setPen(m_majorGridPen);
                            p.drawLine(m_offset+2, p_d, rect.right(), p_d);
                        }
                    }

                    QString text(QString::number(i));
                    QFontMetrics fm(m_font);
                    QRect textRect(fm.boundingRect(text));

                    int h = textRect.height();
                    QRect drawRect(0, p_d - h/2, m_offset, h);

                    // skip paining the text
                    if (prevRect.isValid() && prevRect.intersects(drawRect))
                        continue;
                    prevRect = drawRect;

                    p.setPen(QPen(m_textColor));
                    p.drawText(drawRect, Qt::AlignRight | Qt::AlignVCenter, text);
                }
            }

            break;
        }

        case Qt::Horizontal:
        {
            p.setPen(m_pen);
            p.drawLine(p_start, rect.height()-m_offset, p_end, rect.height()-m_offset);

            if (m_minor > 1e-100)
            {
                int prevTick = -INT_MAX;

                for (double i = start; i <= end; i += m_minor)
                {
                    int p_d = toView(i);

                    if (p_d > prevTick+1)
                    {
                        prevTick = p_d;
                        p.setPen(m_minorPen);
//.........这里部分代码省略.........
开发者ID:houzhenggang,项目名称:qsint,代码行数:101,代码来源:axisbase.cpp

示例4: ASSERT

// ---------------------------------------------------------------------------
// CMMACameraWindow::DrawViewFinderError()
// Draws the error message to specified area.
// Used in cases when viewfinder is unable to start.
// ---------------------------------------------------------------------------
//
void CMMACameraWindow::DrawViewFinderErrorL(
    const TInt /*aError*/,
    const TRect& aDrawRect)
{

    ASSERT(iDirectAccess);
    TInt dcError = KErrNone;
    if (!iDirectAccess->IsActive())
    {
        TRAP(dcError, iDirectAccess->StartL());
    }

    TRect drawRect(aDrawRect);

    if (dcError == KErrNone)
    {
        drawRect.Intersection(iClientRect);
        drawRect.Move(-iWindow->AbsPosition());

        CFbsBitGc* directGc = iDirectAccess->Gc();
        directGc->SetClippingRect(drawRect);
        directGc->SetBrushColor(TRgb(128,128,128));
        directGc->SetPenColor(TRgb(128,0,0));
        directGc->SetBrushStyle(CGraphicsContext::ESolidBrush);
        directGc->SetPenStyle(CGraphicsContext::ESolidPen);
        directGc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);
        directGc->DrawRect(drawRect);

        if (!iErrorIconBitmap || !iErrorIconMaskBitmap)
        {
            if (iErrorIconBitmap)
            {
                delete iErrorIconBitmap;
                iErrorIconBitmap = NULL;
            }

            if (iErrorIconMaskBitmap)
            {
                delete iErrorIconMaskBitmap;
                iErrorIconMaskBitmap = NULL;
            }
            /*
                        AknsUtils::CreateIconL(
                            AknsUtils::SkinInstance(),
                            KAknsIIDQgnIndiCam4Camera,
                            iErrorIconBitmap,
                            iErrorIconMaskBitmap,
                            KCameraAppBitmapFile,
                            EMbmCameraappQgn_indi_cam4_camera,
                            EMbmCameraappQgn_indi_cam4_camera_mask
                        );
                        */
        }

        //TRect iconRect
        drawRect.iTl.iX += KErrorIconMargin;
        drawRect.iTl.iY += KErrorIconMargin;
        drawRect.iBr.iX -= KErrorIconMargin;
        drawRect.iBr.iY -= KErrorIconMargin;

        if (iErrorIconBitmap->SizeInPixels() != drawRect.Size())
        {
            AknIconUtils::SetSize(iErrorIconBitmap, drawRect.Size());
            AknIconUtils::SetSize(iErrorIconMaskBitmap, drawRect.Size());
        }

        directGc->BitBltMasked(
            drawRect.iTl, iErrorIconBitmap,
            TRect(iErrorIconBitmap->SizeInPixels()),
            iErrorIconMaskBitmap, EFalse);

        iDirectAccess->ScreenDevice()->Update();
    }

}
开发者ID:cdaffara,项目名称:symbiandump-ossapps,代码行数:81,代码来源:cmmacamerawindow.cpp

示例5: shallow_copy

namespace SkRecords {

// FIXME: SkBitmaps are stateful, so we need to copy them to play back in multiple threads.
static SkBitmap shallow_copy(const SkBitmap& bitmap) {
    return bitmap;
}

// NoOps draw nothing.
template <> void Draw::draw(const NoOp&) {}

#define DRAW(T, call) template <> void Draw::draw(const T& r) { fCanvas->call; }
DRAW(Restore, restore());
DRAW(Save, save());
DRAW(SaveLayer, saveLayer(r.bounds, r.paint, r.flags));
DRAW(PopCull, popCull());
DRAW(PushCull, pushCull(r.rect));
DRAW(Clear, clear(r.color));
DRAW(Concat, concat(r.matrix));
DRAW(SetMatrix, setMatrix(SkMatrix::Concat(fInitialCTM, r.matrix)));

DRAW(ClipPath, clipPath(r.path, r.op, r.doAA));
DRAW(ClipRRect, clipRRect(r.rrect, r.op, r.doAA));
DRAW(ClipRect, clipRect(r.rect, r.op, r.doAA));
DRAW(ClipRegion, clipRegion(r.region, r.op));

DRAW(DrawBitmap, drawBitmap(shallow_copy(r.bitmap), r.left, r.top, r.paint));
DRAW(DrawBitmapMatrix, drawBitmapMatrix(shallow_copy(r.bitmap), r.matrix, r.paint));
DRAW(DrawBitmapNine, drawBitmapNine(shallow_copy(r.bitmap), r.center, r.dst, r.paint));
DRAW(DrawBitmapRectToRect,
        drawBitmapRectToRect(shallow_copy(r.bitmap), r.src, r.dst, r.paint, r.flags));
DRAW(DrawDRRect, drawDRRect(r.outer, r.inner, r.paint));
DRAW(DrawOval, drawOval(r.oval, r.paint));
DRAW(DrawPaint, drawPaint(r.paint));
DRAW(DrawPath, drawPath(r.path, r.paint));
DRAW(DrawPatch, drawPatch(r.cubics, r.colors, r.texCoords, r.xmode.get(), r.paint));
DRAW(DrawPicture, drawPicture(r.picture, r.matrix, r.paint));
DRAW(DrawPoints, drawPoints(r.mode, r.count, r.pts, r.paint));
DRAW(DrawPosText, drawPosText(r.text, r.byteLength, r.pos, r.paint));
DRAW(DrawPosTextH, drawPosTextH(r.text, r.byteLength, r.xpos, r.y, r.paint));
DRAW(DrawRRect, drawRRect(r.rrect, r.paint));
DRAW(DrawRect, drawRect(r.rect, r.paint));
DRAW(DrawSprite, drawSprite(shallow_copy(r.bitmap), r.left, r.top, r.paint));
DRAW(DrawText, drawText(r.text, r.byteLength, r.x, r.y, r.paint));
DRAW(DrawTextOnPath, drawTextOnPath(r.text, r.byteLength, r.path, r.matrix, r.paint));
DRAW(DrawVertices, drawVertices(r.vmode, r.vertexCount, r.vertices, r.texs, r.colors,
                                r.xmode.get(), r.indices, r.indexCount, r.paint));
#undef DRAW


// This is an SkRecord visitor that fills an SkBBoxHierarchy.
//
// The interesting part here is how to calculate bounds for ops which don't
// have intrinsic bounds.  What is the bounds of a Save or a Translate?
//
// We answer this by thinking about a particular definition of bounds: if I
// don't execute this op, pixels in this rectangle might draw incorrectly.  So
// the bounds of a Save, a Translate, a Restore, etc. are the union of the
// bounds of Draw* ops that they might have an effect on.  For any given
// Save/Restore block, the bounds of the Save, the Restore, and any other
// non-drawing ("control") ops inside are exactly the union of the bounds of
// the drawing ops inside that block.
//
// To implement this, we keep a stack of active Save blocks.  As we consume ops
// inside the Save/Restore block, drawing ops are unioned with the bounds of
// the block, and control ops are stashed away for later.  When we finish the
// block with a Restore, our bounds are complete, and we go back and fill them
// in for all the control ops we stashed away.
class FillBounds : SkNoncopyable {
public:
    FillBounds(const SkRecord& record, SkBBoxHierarchy* bbh) : fBounds(record.count()) {
        // Calculate bounds for all ops.  This won't go quite in order, so we'll need
        // to store the bounds separately then feed them in to the BBH later in order.
        fCTM.setIdentity();
        for (fCurrentOp = 0; fCurrentOp < record.count(); fCurrentOp++) {
            record.visit<void>(fCurrentOp, *this);
        }

        // If we have any lingering unpaired Saves, simulate restores to make
        // sure all ops in those Save blocks have their bounds calculated.
        while (!fSaveStack.isEmpty()) {
            this->popSaveBlock();
        }

        // Any control ops not part of any Save/Restore block draw everywhere.
        while (!fControlIndices.isEmpty()) {
            this->popControl(SkIRect::MakeLargest());
        }

        // Finally feed all stored bounds into the BBH.  They'll be returned in this order.
        SkASSERT(NULL != bbh);
        for (uintptr_t i = 0; i < record.count(); i++) {
            if (!fBounds[i].isEmpty()) {
                bbh->insert((void*)i, fBounds[i], true/*ok to defer*/);
            }
        }
        bbh->flushDeferredInserts();
    }

    template <typename T> void operator()(const T& r) {
        this->updateCTM(r);
//.........这里部分代码省略.........
开发者ID:elima,项目名称:skia,代码行数:101,代码来源:SkRecordDraw.cpp

示例6: interpolateColor

void MainMenu::render()
{

	if (introMovie)
	{
		introMovie->render();
		return;
	}
	if ( bDrawMechlopedia && (fadeTime > fadeOutTime || !fadeOutTime) )
	{
		mechlopedia->render();
		return;
	}

	
	if ( bOptions )
	{
		optionsScreenWrapper->render();
		return;
	}

	//DO NOT play the splash screen animation in software.
	// WOW does it beat up the framerate!
	float xDelta = 0.f;
	float yDelta = 0.f;  
	long color = 0xff000000;

	if (Environment.Renderer != 3)
	{

		if ( beginAnim.isAnimating() && !beginAnim.isDone() )
		{
			xDelta = beginAnim.getXDelta();
			yDelta = beginAnim.getYDelta();

			float time = beginAnim.getCurrentTime();
			float endTime = beginAnim.getMaxTime();
			if ( endTime )
			{
				color = interpolateColor( 0x00000000, 0x7f000000, time/endTime );

			}
		}

		else if (endAnim.isAnimating() /*&& !endAnim.isDone()*/)
		{
			xDelta = endAnim.getXDelta();
			yDelta = endAnim.getYDelta();

			float time = endAnim.getCurrentTime();
			float endTime = endAnim.getMaxTime();
			if ( endTime && (time <= endTime))
			{
				color = interpolateColor( 0x7f000000, 0x00000000, time/endTime );
			}
		}

		GUI_RECT rect = { 0, 0, Environment.screenWidth, Environment.screenHeight };
		drawRect( rect, color );

		if ( bDrawBackground )
		{
			background.render();
			intro.render();
			if ( !intro.animObjects[0].isDone() && !introOver && !bHostLeftDlg )
				return;


		}
	}
	else
	{
		GUI_RECT rect = { 0, 0, Environment.screenWidth, Environment.screenHeight };
		drawRect( rect, color );
	}

	if ( !xDelta && !yDelta )
	{
		drawShadowText( 0xffc66600, 0xff000000, textObjects[1].font.getTempHandle(), 
			textObjects[1].globalX(), textObjects[1].globalTop(),
			textObjects[1].globalRight(), textObjects[1].globalBottom(),
			true, textObjects[1].text, false, textObjects[1].font.getSize(), 1, 1 );
	}

	textObjects[1].showGUIWindow( false );

	
	if ( (!bSave && !bLoad && !bLoadSingle && !bLoadCampaign) || (!endAnim.isDone() && endResult != RESTART ) )	
		LogisticsScreen::render( xDelta, yDelta );
	else if ( bLoadSingle )
		singleLoadDlg.render();
	else
		LogisticsSaveDialog::instance()->render();
 
	if ( promptToQuit || promptToDisconnect )
	{
		LogisticsOKDialog::instance()->render();
	}
	if ( bLegal )
	{
//.........这里部分代码省略.........
开发者ID:wolfman-x,项目名称:mechcommander2,代码行数:101,代码来源:mainmenu.cpp

示例7: lock

/**
 * Draws the button with the specified arrow shape.
 */
void ArrowButton::draw()
{
	Surface::draw();
	lock();

	// Draw button
	SDL_Rect square;
	int color = _color + 2;

	square.x = 0;
	square.y = 0;
	square.w = getWidth() - 1;
	square.h = getHeight() - 1;

	drawRect(&square, color);

	square.x++;
	square.y++;
	color = _color + 5;

	drawRect(&square, color);

	square.w--;
	square.h--;
	color = _color + 4;

	drawRect(&square, color);

	setPixel(0, 0, _color + 1);
	setPixel(0, getHeight() - 1, _color + 4);
	setPixel(getWidth() - 1, 0, _color + 4);

	color = _color + 1;

	if (_shape == ARROW_BIG_UP)
	{
		// Draw arrow square
		square.x = 5;
		square.y = 8;
		square.w = 3;
		square.h = 3;

		drawRect(&square, color);

		// Draw arrow triangle
		square.x = 2;
		square.y = 7;
		square.w = 9;
		square.h = 1;

		for (; square.w > 1; square.w -= 2)
		{
			drawRect(&square, color);
			square.x++;
			square.y--;
		}
		drawRect(&square, color);
	}
	else if (_shape == ARROW_BIG_DOWN)
	{
		// Draw arrow square
		square.x = 5;
		square.y = 3;
		square.w = 3;
		square.h = 3;

		drawRect(&square, color);

		// Draw arrow triangle
		square.x = 2;
		square.y = 6;
		square.w = 9;
		square.h = 1;

		for (; square.w > 1; square.w -= 2)
		{
			drawRect(&square, color);
			square.x++;
			square.y++;
		}
		drawRect(&square, color);
	}
	else if (_shape == ARROW_SMALL_UP)
	{
		// Draw arrow triangle 1
		square.x = 1;
		square.y = 5;
		square.w = 9;
		square.h = 1;

		for (; square.w > 1; square.w -= 2)
		{
			drawRect(&square, color + 2);
			square.x++;
			square.y--;
		}
		drawRect(&square, color + 2);
//.........这里部分代码省略.........
开发者ID:DiegoVazquezNanini,项目名称:OpenXcom,代码行数:101,代码来源:ArrowButton.cpp

示例8: drawRect

void BSpline::addControlPoint(const Point point)
{
	_controlPoints.push_back(point);
	drawRect(point, 10);
}
开发者ID:3a-arthurkevin,项目名称:Math-Modelisation-2D-3D,代码行数:5,代码来源:BSpline.cpp

示例9: drawRect

void drawRect(rec2vector p1, rec2vector p2, COLORREF c)
{
   drawRect(p1.x, p1.y, p2.x, p2.y, c);
}
开发者ID:tomcdonnell,项目名称:racing_line_analyser_cpp,代码行数:4,代码来源:graphics.cpp

示例10: main

// main function
int main(void) {
	
	REG_DISPCTL = MODE3 | BG2_ENABLE; // REG_DISPCTL = 1027/0x0403
	
	drawRect(0, 0, 240, 160, RGB(31, 31, 31)); //color1: white; drawRect

	while (1) {
		// draw UGLY GOOGLE

		// draw "G"
		drawRect(50, 40, 5, 5, RGB(0, 0, 31)); // color2: blue
		drawRect(45, 35, 5, 5, RGB(0, 0, 31));
		drawRect(40, 20, 15, 5, RGB(0, 0, 31));
		drawRect(45, 15, 5, 5, RGB(0, 0, 31));
		drawRect(50, 10, 5, 5, RGB(0, 0, 31));
		drawRect(55, 5, 5, 30, RGB(0, 0, 31));
		drawRect(85, 10, 5, 5, RGB(0, 0, 31));
		drawRect(90, 15, 5, 5, RGB(0, 0, 31));
		drawRect(95, 20, 15, 5, RGB(0, 0, 31));
		drawRect(90, 35, 5, 5, RGB(0, 0, 31));
		drawRect(80, 40, 5, 15, RGB(0, 0, 31));
		drawRect(75, 30, 20, 5, RGB(0, 0, 31));

		// draw "OO"
		drawHollowRect(65, 55, 30, 35, RGB(31, 0, 0)); // color3: red; drawHollowRect
		drawHollowRect(65, 90, 30, 35, RGB(31, 21, 0)); // color4: orange

		// draw 'g'
		drawHollowRect(65, 125, 20, 20, RGB(0, 0, 31));
		setPixel(64, 145, RGB(0, 0, 31)); // setPixel
		setPixel(64, 146, RGB(0, 0, 31));
		setPixel(64, 147, RGB(0, 0, 31));
		setPixel(63, 148, RGB(0, 0, 31));
		plotLine(145, 85, 150, 100, RGB(0, 0, 31)); // plotLine
		drawHollowRect(90, 125, 26, 15, RGB(0, 0, 31));

		// draw 'l'
		drawRect(40, 160, 5, 60, RGB(0, 31, 0)); // color5: green

		// draw 'e'
		drawRect(80, 180, 25, 5, RGB(31, 0, 0));
		drawRect(75, 200, 5, 5, RGB(31, 0, 0));
		drawRect(70, 195, 5, 5, RGB(31, 0, 0));
		drawRect(65, 190, 5, 5, RGB(31, 0, 0));
		drawRect(70, 185, 5, 5, RGB(31, 0, 0));
		drawRect(75, 180, 5, 5, RGB(31, 0, 0));
		drawRect(85, 180, 5, 15, RGB(31, 0, 0));
		drawRect(95, 185, 20, 5, RGB(31, 0, 0));
	}
}
开发者ID:mchi6,项目名称:Assembly_C_and_stuff,代码行数:51,代码来源:main.c

示例11: getWidth

/**
 * Draws the minimap.
 */
void MiniMapView::draw()
{
	int _startX = _camera->getCenterPosition().x - ((getWidth() / CELL_WIDTH) / 2);
	int _startY = _camera->getCenterPosition().y - ((getHeight() / CELL_HEIGHT) / 2);

	InteractiveSurface::draw();
	if(!_set)
	{
		return;
	}
	SDL_Rect current;
	current.x = current.y = 0;
	current.w = getWidth ();
	current.h = getHeight ();
	drawRect(&current, 0);
	this->lock();
	for (int lvl = 0; lvl <= _camera->getCenterPosition().z; lvl++)
	{
		int py = _startY;
		for (int y = Surface::getY(); y < getHeight () + Surface::getY(); y += CELL_HEIGHT)
		{
			int px = _startX;
			for (int x = Surface::getX(); x < getWidth () + Surface::getX(); x += CELL_WIDTH)
			{
				MapData * data = 0;
				Tile * t = 0;
				Position p (px, py, lvl);
				t = _battleGame->getTile(p);
				if (!t)
				{
					px++;
					continue;
				}
				int tileShade = 16;
				if (t->isDiscovered(2))
				{
					tileShade = t->getShade();
				}
				for(int i = 0; i < 4; i++)
				{
					data = t->getMapData(i);

					Surface * s = 0;
					if(data && data->getMiniMapIndex())
					{
						s = _set->getFrame (data->getMiniMapIndex()+35);
					}
					if(s)
					{
						s->blitNShade(this, x, y, tileShade);
					}
				}
				// alive units
				if (t->getUnit() && t->getUnit()->getVisible())
				{
					int frame = t->getUnit()->getMiniMapSpriteIndex();
					int size = t->getUnit()->getArmor()->getSize();
					frame += (t->getPosition().y - t->getUnit()->getPosition().y) * size;
					frame += t->getPosition().x - t->getUnit()->getPosition().x;
					frame += _frame * size * size;
					Surface * s = _set->getFrame(frame);
					s->blitNShade(this, x, y, 0);
				}
				// perhaps (at least one) item on this tile?
				if (t->isDiscovered(2) && !t->getInventory()->empty())
				{
					int frame = 9 + _frame;
					Surface * s = _set->getFrame(frame);
					s->blitNShade(this, x, y, 0);
				}

				px++;
			}
			py++;
		}
	}
	this->unlock();
	int centerX = getWidth() / 2 - 1;
	int centerY = getHeight() / 2 - 1;
	Uint8 color = 1 + _frame * 3;
	int xOffset = CELL_WIDTH / 2;
	int yOffset = CELL_HEIGHT / 2;
	drawLine(centerX - CELL_WIDTH, centerY - CELL_HEIGHT,
		 centerX - xOffset, centerY - yOffset,
		 color); // top left
	drawLine(centerX + xOffset, centerY - yOffset,
		 centerX + CELL_WIDTH, centerY - CELL_HEIGHT,
		 color); // top right
	drawLine(centerX - CELL_WIDTH, centerY + CELL_HEIGHT,
		 centerX - xOffset, centerY + yOffset,
		 color); // bottom left
	drawLine(centerX + CELL_WIDTH, centerY + CELL_HEIGHT,
		 centerX + xOffset, centerY + yOffset,
		 color); //bottom right
}
开发者ID:2xG,项目名称:OpenXcom,代码行数:98,代码来源:MiniMapView.cpp

示例12: game

int game(int seed)
{
	REG_DISPCTL = MODE3 | BG2_ENABLE;
	int live = 5;
	char buffer[41];
	int speed = 1;

	int num = 100;
	int objx = 70;
	int objy = 50;

	drawPicture(black);
	
	WALL wall0;
	wall0.i = 80;
	wall0.gate = 90;
	wall0.gateSize = 10;
	wall0.color = WHITE;
	
	WALL wall1;
	wall1.i = 100;
	wall1.gate = 90;
	wall1.gateSize = 10;
	wall1.color = MAGENTA;

	WALL wall2;
	wall2.i = 120;
	wall2.gate = 30;
	wall2.gateSize = 30;
	wall2.color = RED;
	
	WALL wall3;
	wall3.i = 140;
	wall3.gate = 150;
	wall3.gateSize = 30;
	wall3.color = BLUE;

	WALL wall4;
	wall4.i = 160;
	wall4.gate = 0;
	wall4.gateSize = 20;
	wall4.color = GREEN;

	WALL wall5;
	wall5.i = 180;
	wall5.gate = 130;
	wall5.gateSize = 20;
	wall5.color = BLUE;
	
	WALL wall6;
	wall6.i = 200;
	wall6.gate = 130;
	wall6.gateSize = 15;
	wall6.color = CYAN;
	

	// Game Loop
	while(1)
	{
		
		int oldx = objx;
		int oldy = objy;
		
		drawRect(oldx,oldy,1,1, BLACK);


		if(KEY_DOWN_NOW(BUTTON_SELECT))
		{	
			
		 	objx = 70;
			objy = 50;
			live = 5;
			drawRect(150,0,60,30,BLACK);
			drawString(150, 0, "Score: 0", YELLOW);

		}
		
				
		if(KEY_DOWN_NOW(BUTTON_UP))
		{
			objx-=speed;
			if(objx < 0)
			{
				objx = 0;
			}
			
		}
		if(KEY_DOWN_NOW(BUTTON_DOWN))
		{
			objx+=speed;
			if(objx > 159)
			{
				objx = 159;
			}
		
		}
		
		if(KEY_DOWN_NOW(BUTTON_A))
		{
			speed = 2;
//.........这里部分代码省略.........
开发者ID:chongwenguo,项目名称:gba-game-DMA-version,代码行数:101,代码来源:main.c

示例13: main

int main(void)
{
    //video mode 3, activate background 2
    *REG_DISPCNT = MODE3 | BG2_ENABLE;

    paddle.x = 113;
    oldPaddle.x = 113;

    //ball starts on top of paddle
    setBallOnPaddle();

    lives = 3;
   	bricksLeft = NUM_OF_BRICKS;

   	sprintf(livesString, "%d", lives);  		//store lives as a string
   	sprintf(bricksString, "%d", bricksLeft);  	//store bricks left as a string

    drawBackground3(startscreen);
    drawString(10, 125, "Press any key", WHITE);
    drawString(10, 135, "to start", WHITE);

    while(!ANY_KEY_DOWN)
    {
    	//press key to advance
    }

    fillScreen(BLACK);

    waitForVblank();
    drawRect(GAME_WIDTH, 0, SCREEN_WIDTH - GAME_WIDTH, SCREEN_HEIGHT, RGB(6, 0, 6));

    instantiateBrickArray();

    drawString(205, 20, "Lives", WHITE);
    drawString(215, 35, livesString, WHITE);

    drawString(202, 60, "Bricks", WHITE);
    drawString(208, 70, "left", WHITE);
    drawString(215, 85, bricksString, WHITE);



    while(lives > 0 && bricksLeft > 0)
    {
    	updatePositions();
    	drawEverything();
    }

    if (bricksLeft <= 0)
    {
    	drawBackground3(win);
    }
    else
    {
    	drawBackground3(lose);
    }

    while(TRUE)
    {
    	//do nothing
    }

}
开发者ID:ClysmiC,项目名称:breakout_gba,代码行数:63,代码来源:main.c

示例14: drawRect

void Light::paint(QPainter *p, const QRectF& boundingRect, const QPointF& mousePos, bool mouseIn, const bool isRotated) {
	if (!mouseIn && !m_animation) {
		return;
	}

	QRectF drawRect(boundingRect);

	// XXX: ugly hack because I don't know the real contents area of the FrameSvg
	drawRect.adjust(-4, -4, +4, +4);
	
	qreal  width  = drawRect.width();
	qreal  height = drawRect.height();
	qreal  size   = 0.5;
	qreal  x;
	qreal  y;
	QColor lightColor(m_item->icon()->highlightColor());

	switch (m_currentAnimation) {
	case StartupAnimation:
	case AttentionAnimation:
		x = drawRect.left() + width  * 0.5;
		y = drawRect.top()  + height * 0.5;
		size = size * 2.0 *
			(m_progress < 0.5 ? (m_progress * 0.5 + 0.5) : (1 - m_progress / 2));
		break;
	case NoAnimation:
		if (isRotated) {
			x = m_item->size().height() - mousePos.y();
			y = mousePos.x();
		}
		else {
			x = mousePos.x();
			y = mousePos.y();
		}
		// y = drawRect.top() + height * 1.10;
		width  *= 2.0;
		height *= 2.0;
		break;
	default:
		return;
	}
	
	QRadialGradient gradient(0.5, 0.5, size);
	gradient.setCoordinateMode(QRadialGradient::ObjectBoundingMode);
	
	lightColor.setAlpha(200);
	gradient.setColorAt(0.0, lightColor);
	
	lightColor.setAlpha(60);
	gradient.setColorAt(0.6, lightColor);
	
	lightColor.setAlpha(0);
	gradient.setColorAt(1.0, lightColor);
	
	p->setClipRect(drawRect);
	p->fillRect(
		x - width  * 0.5,
		y - height * 0.5,
		width, height,
		gradient);
	p->setClipping(false);
}
开发者ID:iananass,项目名称:smooth-task-next,代码行数:62,代码来源:Light.cpp

示例15: alertDraw

void alertDraw(){
	drawRect(alertTexture, 1024/2-256/2, 768/2-128/2,256,128);
	drawRect(alertSelectTexture, 1024/2-256/2, 768/2-128/2,256,128);
}
开发者ID:scetticus,项目名称:electronica-tgc,代码行数:4,代码来源:alert.cpp


注:本文中的drawRect函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。