コード例 #1
0
void TetrisGameAreaLayer::onKeyDown(EventKeyboard::KeyCode keyCode, Event* unused_event)
{
	if (mActiveBlock == nullptr || mAcc)
		return;
	if (keyCode == EventKeyboard::KeyCode::KEY_SPACE) {
		mActiveBlock->rotate();
		drawBlock(mActiveBlock, mActiveSprites);
		while (checkIsBottom(true)) {
			mActiveBlock->moveUp();
			drawBlock(mActiveBlock, mActiveSprites);
		
		}
		mShadowBlock->rotate();
		drawShadowBlock();
	}
	else if (keyCode == EventKeyboard::KeyCode::KEY_LEFT_ARROW) {
		mActiveBlock->moveInX(true);
		drawAllBlocks();
	}
	else if (keyCode == EventKeyboard::KeyCode::KEY_RIGHT_ARROW) {
		mActiveBlock->moveInX(false);
		drawAllBlocks();
	}
	else if (keyCode == EventKeyboard::KeyCode::KEY_DOWN_ARROW) {
		onBlockAcc();
	}

}
コード例 #2
0
ファイル: tetrisview.cpp プロジェクト: xprozent/zentetris
void TetrisView::paintEvent( QPaintEvent* ) {
    QPainter painter( this );
    painter.fillRect( 0, 0, m_width, m_height, BACKGROUND_COLOR );

    if( DEBUG ) {
        painter.setPen( DEBUG_GRID_COLOR );
        for( int x = BLOCK_SIZE_PIXELS; x < m_width; x += BLOCK_SIZE_PIXELS ) {
            painter.drawLine( x, 0, x, m_height );
        }
        for( int y = BLOCK_SIZE_PIXELS; y < m_height; y += BLOCK_SIZE_PIXELS ) {
            painter.drawLine( 0, y, m_width, y );
        }
    }

    for( int x = 0; x < m_model.getWidthBlocks(); ++x ) {
        for( int y = 0; y < m_model.getHeightBlocks(); ++y ) {
            drawBlock( blocksToPoints( x ) + HALF_BLOCK_SIZE, blocksToPoints( y ) + HALF_BLOCK_SIZE, m_model.getBlockType( x, y ), &painter );
        }
    }

    const TetrisItem& item = m_model.getItem();
    for( int x = 0; x < item.getSizeBlocks(); ++x ) {
        for( int y = 0; y < item.getSizeBlocks(); ++y ) {
            drawBlock( item.getBlockXPoints( x ), item.getBlockYPoints( y ), item.getBlockType( x, y ), &painter );
        }
    }
}
コード例 #3
0
void TetrisGameAreaLayer::onBlockAccDone()
{
	bool foundOnce = false;
	for (auto unit : mActiveSprites) {
		if (unit->ptrSp->getNumberOfRunningActions() > 0) {
			if (foundOnce)
				return;
			foundOnce = true;
		}
	}
	mActiveBlock->moveDown();
	if (mShadowBlock->getPosInGrid() == mActiveBlock->getPosInGrid()) {
		mAcc = false;
		mActiveBlock->setPosInGrid(mShadowBlock->getPosInGrid());
		drawBlock(mActiveBlock, mActiveSprites);
		onBlockReachBottom();
		dropNewBlock();
		return;
	}
	for (auto unit : mActiveSprites) {
		drawBlock(mActiveBlock, mActiveSprites);
		auto cb = CallFunc::create(std::bind(&TetrisGameAreaLayer::onBlockAccDone, this));
		auto move = MoveBy::create(0.001, Vec2(0, -1 * mGridSize));
		auto sq = Sequence::create(move, cb, NULL);
		unit->ptrSp->runAction(sq);
	}

}
コード例 #4
0
//--------------------------------------------------------------
void testApp::draw(){
    
    // draw valid grids
    for (int i = 0; i < gridHeight; i++) {
        for (int j = 0; j < gridWidth; j++) {
            if(validGrid[i][j]) {
                drawBlock(gridSize * j, gridSize * i, gridSize, gridSize, ofColor(255), ofColor(0));
            }
        }
    }
    
    
    
    // draw falling block
    if (block) {
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                if(block->valid[i][j]) {
                    drawBlock(gridSize * (j + block->originX), gridSize * (i + block->originY), gridSize, gridSize, ofColor(255), ofColor(0));
                }
            }
        }
    }

    // outer frame
    drawBlock(0, 0, gridSize * gridWidth, gridSize * gridHeight, ofColor(0, 0), ofColor(0));
}
コード例 #5
0
ファイル: bullet.c プロジェクト: cupen/Console-Tank
void clean_Bullets(BULLET_MANAGER *b_m)
{
    if( NULL == b_m){
		printf("Bullet_Manager is null;");
		return;
	}
	int i=0,lengh = b_m->bullet_Count;
	for(i=0 ; i<lengh; i++)
	{
		if( b_m->bullets[i].button )  // true, mean the bullet be FaShe
		{
			switch(b_m->bullets[i].dir)
			{
			    case UP:
                    drawBlock( b_m->bullets[i].x, b_m->bullets[i].y+1, BLACK, 0);
                    break;

                case DOWN:
                    drawBlock( b_m->bullets[i].x, b_m->bullets[i].y-1, BLACK, 0);
                    break;

                case LEFT:
                    drawBlock( b_m->bullets[i].x+1, b_m->bullets[i].y, BLACK, 0);
                    break;

                case RIGHT:
                    drawBlock( b_m->bullets[i].x-1, b_m->bullets[i].y, BLACK, 0);
                    break;

                default: printf("void clean_Bullets(BULLET_MANAGER *b_m)");
			}
		}
	}
}
コード例 #6
0
ファイル: snake2.cpp プロジェクト: ShipuW/snake-C-MySql
void drawBar(void)                                                   //画障碍物函数
{int i=0, j=0, a=0 ,k=0;

do
{
      myBar[0].x = rand() % MAP_WIDTH;
      myBar[0].y = rand() % MAP_HEIGHT;
   if(((myBar[0].x ==myFood.x)&&(myBar[0].y ==myFood.y))
    ||((myBar[0].x ==myReward.x)&&(myBar[0].y ==myReward.y))
    ||(isInSnake(myBar[0].x, myBar[0].y,z)))
    return;
    drawBlock(myBar[0].x, myBar[0].y, BS_BAR);
   for(i=1;i<BARS;i++)                                              //分BARS次画出障碍物的方格
   {
    a=rand()%4;                                            
    switch(a)                                                    //在以下四种情况中随机产生一种
    {
       
    case 0: myBar[i].x=myBar[i-1].x+1;                           //在原方格的上侧产生新方格
                  myBar[i].y=myBar[i-1].y;
      break;
    
    case 1:    myBar[i].x=myBar[i-1].x;                             //在原方格的上侧产生新方格
                 myBar[i].y=myBar[i-1].y+1;
      break;
    
    case 2:    myBar[i].x=myBar[i-1].x-1;                           //在原方格的上侧产生新方格
                 myBar[i].y=myBar[i-1].y;
      break;
    
    case 3:    myBar[i].x=myBar[i-1].x;                            //在原方格的上侧产生新方格
                 myBar[i].y=myBar[i-1].y-1;
         break;
    default:
                     break;
    }
    
    for(j=0;j<i;j++)
    {
           if(((myBar[j].x ==myBar[i].x )&&(myBar[j].y ==myBar[i].y )) 
      ||((myBar[i].x ==myFood.x)&&(myBar[i].y ==myFood.y))
      ||((myBar[i].x ==myReward.x)&&(myBar[i].y ==myReward.y))
      ||(isInSnake(myBar[i].x, myBar[i].y,z))
      ||(myBar[i].x<0)||myBar[i].x>=MAP_WIDTH || myBar[i].y<0||myBar[i].y>=MAP_HEIGHT)
     {i--;
     
     break;}
    }
    
   
    drawBlock(myBar[i].x, myBar[i].y, BS_BAR);
   }
   
   break;
} while (1);
   
   q=1;
}
コード例 #7
0
ファイル: lab4B.c プロジェクト: apleaf/Lab4ECE382
void main() {

	unsigned char	x, y, xdir, ydir;

	unsigned int i;

	// === Initialize system ================================================
	IFG1=0; /* clear interrupt flag1 */
	WDTCTL=WDTPW+WDTHOLD; /* stop WD */



	init();
	initNokia();
	clearDisplay();

	x=4;		y=4;

ydir=1;     xdir=1;


	drawBlock(y,x);

	while(1) {

		if (ydir ==1){
			y++;
			if(y>=8) ydir=0;
		}

		if (ydir==0){
			y--;
			if(y<=0) ydir=1;
		}

		if (xdir ==1){
			x++;
			if (x>=11) xdir = 0;
		}

		if(xdir==0){
			x--;
			if(x<=0) xdir =1;
		}


				clearDisplay();
				drawBlock(y,x);
				for(i=0; i<10; i++){
					moveDelay();
				}

		}
}
コード例 #8
0
void main() {

	unsigned char	x, y, color, button_press;

	// === Initialize system ================================================
	IFG1=0; /* clear interrupt flag1 */
	WDTCTL=WDTPW+WDTHOLD; /* stop WD */
	button_press = FALSE;


	init();
	initNokia();
	clearDisplay();
	color = WHITE;
	x=4;		y=4;
	drawBlock(y,x,color);

	while(1) {

			if (UP_BUTTON == 0) {
				while(UP_BUTTON == 0);
				if (y>=1) y=y-1;
				button_press = TRUE;
			} else if (DOWN_BUTTON == 0) {
				while(DOWN_BUTTON == 0);
				if (y<=6) y=y+1;
				button_press = TRUE;
			} else if (LEFT_BUTTON == 0) {
				while(LEFT_BUTTON == 0);
				if (x>=1) x=x-1;
				button_press = TRUE;
			} else if (RIGHT_BUTTON == 0) {
				while(RIGHT_BUTTON == 0);
				if (x<=10) x=x+1;
				button_press = TRUE;
			} else if (AUX_BUTTON == 0) {
				while(AUX_BUTTON == 0);
				if (color == BLACK) color = WHITE;
				else if (color == WHITE) color = BLACK;
				button_press = TRUE;
			}

			if (button_press) {
				button_press = FALSE;
				//clearDisplay();
				drawBlock(y,x,color);
			}
		}
}
コード例 #9
0
ファイル: lab4.c プロジェクト: SeanGavan/382-Lab-4
void main() {

	unsigned char	x, y, button_press, color;			// Define new variable color

	// === Initialize system ================================================
	IFG1=0; /* clear interrupt flag1 */
	WDTCTL=WDTPW+WDTHOLD; /* stop WD */
	button_press = FALSE;


	init();
	initNokia();
	clearDisplay();
	x=4;		y=4;	color=2;			// Initialized new variable color to 2 (BLACK)
	drawBlock(y,x,color);			// New call with color variable

	while(1) {

			if (UP_BUTTON == 0) {
				while(UP_BUTTON == 0);
				if (y>=1) y=y-1;
				button_press = TRUE;
			} else if (DOWN_BUTTON == 0) {
				while(DOWN_BUTTON == 0);
				if (y<=6) y=y+1;
				button_press = TRUE;
			} else if (LEFT_BUTTON == 0) {
				while(LEFT_BUTTON == 0);
				if (x>=1) x=x-1;
				button_press = TRUE;
			} else if (RIGHT_BUTTON == 0) {
				while(RIGHT_BUTTON == 0);
				if (x<=10) x=x+1;
				button_press = TRUE;
			} else if (AUX_BUTTON == 0) {				// Syntax similar to other buttons
				while(AUX_BUTTON == 0);
				if (color == BLACK) color = WHITE;		// If BLACK, change to WHITE
				else if (color == WHITE) color = BLACK;	// Else if WHITE, change to BLACK
				button_press = TRUE;
			}

			if (button_press) {
				button_press = FALSE;
				//clearDisplay();			// Commented out to leave block drawings behind
				drawBlock(y,x,color);		// New call again
			}
		}
}
コード例 #10
0
ファイル: gfx.c プロジェクト: bcherry/bcherry
// drawLevel - draws one of the maze levels
void drawLevel(short int level) {
	short int yLoop,xLoop;
	long int area, mask;

	// clear the screen first
	ClrScr();

	for (yLoop = 0; yLoop < YTILES; yLoop++) {
		area = levels[level][yLoop];
		mask = 0x100000;

		// start the x loop
		for (xLoop = 0; xLoop < XTILES; xLoop++) {
			// shift the mask index
			mask >>= 1;

			// if the level data says to put a block here, then do it
			if (area & mask) {
				drawBlock(xLoop * WIDTH, yLoop * HEIGHT, block, SPRT_OR);
			}
		}
	}

	// share the bottom line of the maze
	clearDisplayLine();
}
コード例 #11
0
BlockGraphicsItem::BlockGraphicsItem(Block * block,QGraphicsItem *parent) :
    QGraphicsItem(parent)
{
    _block = block;
    _rect = 0;
    drawBlock();
}
コード例 #12
0
ファイル: maze.cpp プロジェクト: gregf/Maze-background
void Maze::drawValues(Draw * xwin,int ra,int ga, int ba,int rb, int gb, int bb)
{
for (int h=1;h<wall.height;h++)
{
for (int w=1;w<=wall.width;w++)
{

//    std::cout<<values[w][h]<<std::endl;

double ratio = (float)values[w][h]/(float)(totalblocks+1);


ratio+=0.0000000001;

int rc,gc,bc;

rc=(ra*ratio)+(rb*(1.0-ratio));
gc=(ga*ratio)+(gb*(1.0-ratio));
bc=(ba*ratio)+(bb*(1.0-ratio));


std::string tmp=stringColor(rc,gc,bc);


char *color = new char[6];
    
color=strcpy(color,tmp.c_str());

drawBlock(w,h,xwin,this,color);
}

}

}
コード例 #13
0
ファイル: maze.cpp プロジェクト: berock212/Maze-background
void Maze::drawValues(Draw * xwin,int ra,int ga, int ba,int rb, int gb, int bb,int colormult) {

    for (int h=1;h<wall.height;h++) {
	for (int w=1;w<=wall.width;w++) {

	    double ratio = (float)values[w][h]*colormult/(float)(totalblocks+1);

	    if (ratio > 1.0)
		ratio -= (float)((int) ratio);

	    ratio+=0.0000000001;

	    int rc,gc,bc;

	    rc=(ra*ratio)+(rb*(1.0-ratio));
	    gc=(ga*ratio)+(gb*(1.0-ratio));
	    bc=(ba*ratio)+(bb*(1.0-ratio));

	    drawBlock(w,h,xwin,this,rc,gc,bc);
    
	}

    }

}
コード例 #14
0
ファイル: Block.cpp プロジェクト: sbimbra/tetris
bool Block::rotateRight()
{
	rotationIndex++;
	rotationIndex = rotationIndex % shapes.size();
	drawBlock();
	return true;
}
コード例 #15
0
ファイル: mainwindow.cpp プロジェクト: SgLy/hexakis
void MainWindow::redraw()
{
	if(state != STATE_RUNNING) return;
	drawBoard (game->brd);
	drawBlock (game->now);
	if (dropPreview) drawPreview (game->now.FakeDropToBottom(game->brd));
}
コード例 #16
0
ファイル: Snake.c プロジェクト: ShipuW/snake-C-MySql
///////////////////////以下是功能函数
void drawMap(void)
{

	int i, j;
	for (i=-1,        j=-1;        j<MAP_WIDTH ;j++) if (i!=j){drawBlock(j, i, BS_DOWN);}else{drawBlock(j, i, BS_SPACE);}
	for (i=-1,        j=-1;        i<MAP_HEIGHT;i++) if (i!=j){drawBlock(j, i, BS_RIGHT);}
	for (i=MAP_HEIGHT,j= 0;        j<MAP_WIDTH ;j++) drawBlock(j, i, BS_UP);
	for (i=0,         j=MAP_WIDTH; i<MAP_HEIGHT;i++) drawBlock(j, i, BS_LEFT);
	for (i = 0; i < MAP_HEIGHT; i++)
	{	
		for (j = 0; j < MAP_WIDTH; j++)
		{
			drawBlock(j, i, BS_SPACE);
		}
	}
}
コード例 #17
0
void initSnake(Snake * snake){
    snake->head.X = snake->blocks[0].X = GAME_FIELD_WIDTH/2;
    snake->head.Y = snake->blocks[0].Y = GAME_FIELD_HEIGHT/2;
    snake->blocks[1].X = GAME_FIELD_WIDTH/2 - 1;
    snake->blocks[1].Y = GAME_FIELD_HEIGHT/2;
    snake->tail.X = snake->blocks[2].X = GAME_FIELD_WIDTH/2 - 2;
    snake->tail.Y = snake->blocks[2].Y = GAME_FIELD_HEIGHT/2;
    snake->tailPosInArr = 2;
    snake->headPosInArr = 0;

    drawBlock(snake->head.X + fieldX, snake->head.Y + fieldY, BACKGROUND_BLUE);

    int i;
    for(i = 1; i < INIT_BLOCKS_NUM; i++){
        drawBlock(snake->blocks[i].X + fieldX, snake->blocks[i].Y + fieldY, BACKGROUND_BLUE | BACKGROUND_GREEN);
    }
}
コード例 #18
0
ファイル: gfx.c プロジェクト: bcherry/bcherry
// drawSnake - draws the snake on the LCD
void drawSnake(SNAKE *snake) {
	POSITION pos;
	short int loop;

	// draw the snake segments
	for (loop = 0; loop < snake->length; loop++) {
		pos = snake->location[loop];
		drawBlock(pos.x * WIDTH, pos.y * HEIGHT, block, SPRT_OR);
	}

	// remove the last segment to create the illusion of movement
	pos = snake->location[snake->length];

	if (pos.x != 0 && pos.y != 0) {
		drawBlock(pos.x * WIDTH, pos.y * HEIGHT, empty, SPRT_AND);
	}
}
コード例 #19
0
ファイル: akis_tetris.c プロジェクト: koutras/tetrix
void drawPiece(Piece *thisPiece)
{
	int i,j;
		for(i=0;i<3;i++)
			for(j=0;j<3;j++)
				if(thisPiece->table[i][j])
					drawBlock(thisPiece->blockTable[i][j]);
}
コード例 #20
0
ファイル: lab4B.c プロジェクト: KyleJonas/ECE382
void main() {

	unsigned char	x, y, xVel, yVel;

	// === Initialize system ================================================
		IFG1=0; /* clear interrupt flag1 */
		WDTCTL=WDTPW+WDTHOLD; /* stop WD */


		init();
		initNokia();
		clearDisplay();
		x=4;	y=4;	xVel=1;		yVel=1;
		drawBlock(y,x);

		while(1) {

					// Vel = 1 going right/down
					// Vel = 0 going left/up

					if (xVel == 1) {
						x++;
						if (x>=11) xVel=0;
					}

					if (xVel == 0) {
						x--;
						if (x<=0) xVel=1;
					}

					if (yVel == 1) {
						y++;
						if (y>=7) yVel=0;
					}

					if (yVel == 0) {
						y--;
						if (y<=0) yVel=1;
					}

						clearDisplay();
						drawBlock(y,x);
						delayDraw();
				}
		}
コード例 #21
0
void interface_render()
{
	drawBlock(&_interface.mainBlock);

	if (_interface.sidePanelVisible)
	{
		drawSidePanel(_interface.sidePanel);
	}
}
コード例 #22
0
ファイル: bullet.c プロジェクト: cupen/Console-Tank
void destroyBullet(BULLET* bullet)
{
    bullet->button = 0;
    drawBlock(bullet->x, bullet->y, BLACK, 0);
    cleanBullet(bullet);
    bullet->host->bullet_count++;
    bullet->host = NULL;
    return;
}
コード例 #23
0
ファイル: DrawEngine.cpp プロジェクト: Roger8/tetris-win32
void DrawEngine::drawNextPiece(Piece &piece, int x, int y)
{
    TCHAR szBuffer[] = TEXT("Next:");
    TextOut(hdc, x, y + 5, szBuffer, lstrlen(szBuffer));
    COLORREF color = piece.getColor();

    // Draw the piece in a 4x4 square area
    for (int i = 0; i < 4; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            if (piece.isPointExists(i, j))
                drawBlock(i + x, j + y, color);
            else
                drawBlock(i + x, j + y, RGB(0,0,0));
        }
    }
}
コード例 #24
0
ファイル: boom.c プロジェクト: cupen/Console-Tank
void drawBoom(BOOM* boom)
{
    int i = 0;
    for(; i<25; i++)
    {
        if( boom->body & (0x01000000>>i) ){
            drawBlock( boom->x + body[i<<1],
                      boom->y + body[(i<<1)+1],
                      boom->color,
                      9);
        } else {
            drawBlock( boom->x + body[i<<1],
                      boom->y + body[(i<<1)+1],
                      BLACK,
                      0);

        }
    }
コード例 #25
0
ファイル: GLScenePane.cpp プロジェクト: Kyate/CoSLAM
void GLScenePane::drawCameraGroups() {
	int topleft_x = 0;
	int topleft_y = 0;
	int bottomright_x = GetSize().x;
	int bottomright_y = GetSize().y;

	glViewport(topleft_x, topleft_y, bottomright_x - topleft_x,
			bottomright_y - topleft_y);
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	gluOrtho2D(topleft_x, bottomright_x, bottomright_y, topleft_y);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	int base_top = -70;
	if (m_pSLAM) {
		char buf[256];
		glColor4f(0.5f, 0.5f, 0.5f, 0.5f);
		sprintf(buf, "frame: %d", m_pSLAM->curFrame);
		glutPrint2D(15, 15, buf, 0.0f, 0.0f, 1.0f, 0.5f, false);
		for (int i = 0; i < m_groupNum; i++) {
			float groupColor[3] = { CAMERA_COLORS[3 * i], CAMERA_COLORS[3 * i
					+ 1], CAMERA_COLORS[3 * i + 2] };

			drawBlock(23, base_top + 90 + 30 * i, 50, 19, groupColor);
			sprintf(buf, "group %d:", i);
			glutPrint2D(25, base_top + 102 + 30 * i, buf, 1.0f, 1.0f, 1.0f,
					1.0f, false);

			int idNum = m_groups[i].num;
			for (int j = 0; j < idNum; j++) {
				int camId = m_groups[i].camIds[j];

				drawBlock(85 + 20 * j, base_top + 92 + 30 * i, 15, 15,
						CAMERA_COLORS + 3 * camId);

				sprintf(buf, "%02d", camId);
				glutPrint2D(86 + 20 * j, base_top + 103 + 30 * i, buf, 1.0f,
						1.0f, 1.0f, 1.0f, false);
			}
		}
	}
}
コード例 #26
0
ファイル: Block.cpp プロジェクト: sbimbra/tetris
bool Block::rotateLeft()
{
	rotationIndex--;
	if(rotationIndex < 0)
	{
		rotationIndex = shapes.size() - 1;
	}
	drawBlock();
	return true;
}
コード例 #27
0
ファイル: game.c プロジェクト: dong-brian/2048Plus
Result game(int seed) {
    Result result = {LOSE, 0};
    srand(seed);
    Block blocks[size*size];
    int blocksLeft = 0;
    resetGame(blocks, &blocksLeft, &result);
    int index = 0;
    int spawn = FALSE;
    int quit = FALSE;
    while (!quit) {
        if (KEY_DOWN_NOW(BUTTON_UP)) {
            if (moveBlocks(blocks, UP, &result.score, &blocksLeft, &result.outcome) && blocksLeft) {
                spawn = TRUE;
            }
            while (KEY_DOWN_NOW(BUTTON_UP));
        }
        if (KEY_DOWN_NOW(BUTTON_DOWN)) {
            if (moveBlocks(blocks, DOWN, &result.score, &blocksLeft, &result.outcome) && blocksLeft) {
                spawn = TRUE;
            }
            while (KEY_DOWN_NOW(BUTTON_DOWN));
        }
        if (KEY_DOWN_NOW(BUTTON_LEFT)) {
            if (moveBlocks(blocks, LEFT, &result.score, &blocksLeft, &result.outcome) && blocksLeft) {
                spawn = TRUE;
            }
            while (KEY_DOWN_NOW(BUTTON_LEFT));
        }
        if (KEY_DOWN_NOW(BUTTON_RIGHT)) {
            if (moveBlocks(blocks, RIGHT, &result.score, &blocksLeft, &result.outcome) && blocksLeft) {
                spawn = TRUE;
            }
            while (KEY_DOWN_NOW(BUTTON_RIGHT));
        }
        if (spawn) {
            index = spawnBlock(blocks, blocksLeft--);
            result.score += 1<<blocks[index].num;
            waitForVblank();
            drawBlock(blocks, index);
            updateScoreDisplay(result.score);
            quit = !hasMoves(blocks);
            spawn = FALSE;
        }
        if (KEY_DOWN_NOW(BUTTON_B)) {
            quit = TRUE;
            while (KEY_DOWN_NOW(BUTTON_B));
        }
        if (KEY_DOWN_NOW(BUTTON_SELECT)) {
            resetGame(blocks, &blocksLeft, &result);
            while (KEY_DOWN_NOW(BUTTON_SELECT));
        }
    }
    //put a while loop here to check if game ends properly
    return result;
}
コード例 #28
0
ファイル: primitive.cpp プロジェクト: zzzzlzzzz/Tetris
void Primitive::doDrawAt(sf::RenderWindow& render, int positionX, int positionY)
{
    for (size_t y = 0; y < scheme.size(); y++)
    {
        for (size_t x = 0; x < scheme[y].size(); x++)
        {
            if (scheme[y][x] != BlockColor::EMPTY)
                drawBlock(render, positionX + x, positionY + y, scheme[y][x]);
        }
    }
}
コード例 #29
0
void GLwidget::paintGL()
{
    glPointSize(15);
    qglClearColor(Qt::gray);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    qglColor(Qt::red);
    //glTranslatef(0.0, 0.0, -1.0);

        glColor3f(1.0, 0.0, 0.0);
        glLoadName(7); /* Overwrite the first name in the buffer */
        drawBlock(-0.7, 0, -2);

        glColor3f(0.0, 1.0, 0.0);
        glLoadName(14); /* Overwrite the first name in the buffer */
        drawBlock(0, 0, -4);

        glColor3f(0.0, 0.0, 1.0);
        glLoadName(21); /* Overwrite the first name in the buffer */
        drawBlock(0.7, 0, -6);
}
コード例 #30
0
ファイル: snake2.cpp プロジェクト: ShipuW/snake-C-MySql
void clearBar(void)
{ 
int j=0;

for(j=0;j<BARS;j++)                    //擦去障碍物并清零
{
   drawBlock(myBar[j].x, myBar[j].y, BS_SPACE);
   myBar[j].x=-1; myBar[j].y=-1;
}

}