本文整理汇总了C++中Quad::Draw方法的典型用法代码示例。如果您正苦于以下问题:C++ Quad::Draw方法的具体用法?C++ Quad::Draw怎么用?C++ Quad::Draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Quad
的用法示例。
在下文中一共展示了Quad::Draw方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawMask
void DrawMask( float fPercent )
{
RectI rect;
int iChamber;
float fChamberOverflowPercent;
GetChamberIndexAndOverslow( fPercent, iChamber, fChamberOverflowPercent );
float fRightPercent = GetRightEdgePercent( iChamber, fChamberOverflowPercent );
float fHeightPercent = GetHeightPercent( iChamber, fChamberOverflowPercent );
float fChamberLeftPercent = GetChamberLeftPercent( iChamber );
float fChamberRightPercent = GetChamberRightPercent( iChamber );
// draw mask for vertical chambers
rect.left = int(-METER_WIDTH/2 + fChamberLeftPercent*METER_WIDTH-1);
rect.top = int(-METER_HEIGHT/2);
rect.right = int(-METER_WIDTH/2 + fChamberRightPercent*METER_WIDTH+1);
rect.bottom = int(-METER_HEIGHT/2 + fHeightPercent*METER_HEIGHT);
rect.left = MIN( rect.left, + METER_WIDTH/2 );
rect.right = MIN( rect.right, + METER_WIDTH/2 );
m_quadMask.StretchTo( rect );
m_quadMask.Draw();
// draw mask for horizontal chambers
rect.left = (int)(-METER_WIDTH/2 + fRightPercent*METER_WIDTH);
rect.top = -METER_HEIGHT/2;
rect.right = +METER_WIDTH/2;
rect.bottom = +METER_HEIGHT/2;
rect.left = MIN( rect.left, + METER_WIDTH/2 );
rect.right = MIN( rect.right, + METER_WIDTH/2 );
m_quadMask.StretchTo( rect );
m_quadMask.Draw();
}
示例2: Display
void Display() {
glClear(GL_COLOR_BUFFER_BIT);
quad.Draw();
}
示例3: main
int main(int argc, char **argv) {
// Create the game window and initalise the VIDEO subsystem
GameWindow gwd;
gwd.InitVideo();
gwd.SetBackground((GXColor){ 0, 30, 0, 255 });
// Initialise Wiimote
WPAD_Init();
// Enable SD card stuff
fatInitDefault();
// Create a rectangle representing the net and set its properties
Quad net;
net.SetPosition(320-2, 0);
net.SetWidth(4);
net.SetHeight(480);
net.SetFillColor((GXColor){ 0, 255, 0, 255 });
// Create the two score boxes (x position, y position, width)
ScoreBox firstScoreBox(35, 10, 250);
ScoreBox secondScoreBox(355, 10, 250);
// Create and spawn the first player
Player firstPlayer;
firstPlayer.spawn(0, 100);
// Create and spawn the second player
Player secondPlayer;
secondPlayer.spawn(510, 610);
// Create and spawn the ball (-3 seems like a good initial speed!)
Ball theBall;
theBall.spawn(-3);
// Player 2 A.I. is turned on by default
bool AImode = true;
// This is the game's run loop. It is executed several times per second.
while(1) {
// Look for new Wii controllers
WPAD_ScanPads();
// Handle controller events
// Quit the game (break out of the runloop) if HOME is pressed
if(WPAD_ButtonsDown(WPAD_CHAN_0)&WPAD_BUTTON_HOME)
break;
// Player 1 Controls
if(WPAD_ButtonsHeld(WPAD_CHAN_0)&WPAD_BUTTON_DOWN)
firstPlayer.pushDown();
if(WPAD_ButtonsHeld(WPAD_CHAN_0)&WPAD_BUTTON_UP)
firstPlayer.pushUp();
if(WPAD_ButtonsHeld(WPAD_CHAN_0)&WPAD_BUTTON_LEFT)
firstPlayer.pushLeft();
if(WPAD_ButtonsHeld(WPAD_CHAN_0)&WPAD_BUTTON_RIGHT)
firstPlayer.pushRight();
// Player 2 Controls
if(WPAD_ButtonsDown(WPAD_CHAN_1)&WPAD_BUTTON_PLUS)
AImode = !AImode;
// If AI is enabled, control Player 2 using the following code.
if ( AImode ) {
// Player 2 AI
if (theBall.getYcoord()+10 < secondPlayer.getYcoord()+32)
secondPlayer.pushUp();
else if (theBall.getYcoord()+10 > secondPlayer.getYcoord()+32)
secondPlayer.pushDown();
}
// If AI is disabled, let the Wii remote control Player 2.
else {
if(WPAD_ButtonsHeld(WPAD_CHAN_1)&WPAD_BUTTON_DOWN)
secondPlayer.pushDown();
if(WPAD_ButtonsHeld(WPAD_CHAN_1)&WPAD_BUTTON_UP)
secondPlayer.pushUp();
if(WPAD_ButtonsHeld(WPAD_CHAN_1)&WPAD_BUTTON_LEFT)
secondPlayer.pushLeft();
if(WPAD_ButtonsHeld(WPAD_CHAN_1)&WPAD_BUTTON_RIGHT)
secondPlayer.pushRight();
}
// Handle all the game objects
net.Draw(); // Draw the net
firstScoreBox.Draw(); // Draw the first score box
secondScoreBox.Draw(); // Draw the second score box
// Draw the ball, then react if it bounced off the side of the screen.
switch (theBall.Draw()) {
// If the ball hit the left side of the screen...
case -1:
// Player 1 has failed
if (secondScoreBox.incrementScore() == false) return 0;
theBall.spawn(-3); // Reset ball going left
firstPlayer.spawn(0, 100);
//.........这里部分代码省略.........