예제 #1
0
void byoSnake::DrawBorder(wxDC* DC)
{
    for ( int i=0; i<m_FieldHoriz+2; i++ )
    {
        DrawBrick(DC,i,2,GetColour(m_BorderColour));
        DrawBrick(DC,i,3+m_FieldVert,GetColour(m_BorderColour));
    }
    for ( int i=0; i<m_FieldVert; i++ )
    {
        DrawBrick(DC,0,i+3,GetColour(m_BorderColour));
        DrawBrick(DC,m_FieldHoriz+1,i+3,GetColour(m_BorderColour));
    }
}
예제 #2
0
파일: tetris.c 프로젝트: xjiajiahao/tetris
void CreateBrick()
{
    int number;

    currentBrick = nextBrick;
    number = (int)(7*rand()/(RAND_MAX+1.0));
    switch (number)
    {
    case 0:
        nextBrick = 0;
        break;
    case 1:
        nextBrick = (int)(2*rand()/(RAND_MAX+1.0)) + 1;
        break;
    case 2:
        nextBrick = (int)(2*rand()/(RAND_MAX+1.0)) + 3;
        break;
    case 3:
        nextBrick = (int)(2*rand()/(RAND_MAX+1.0)) + 5;
        break;
    case 4:
        nextBrick = (int)(4*rand()/(RAND_MAX+1.0)) + 7;
        break;
    case 5:
        nextBrick = (int)(4*rand()/(RAND_MAX+1.0)) + 11;
        break;
    case 6:
        nextBrick = (int)(4*rand()/(RAND_MAX+1.0)) + 15;
        break;
    }
    locate.x = _LeftEdge + BrickSIZE*3;
    locate.y = 0;
    DrawBrick();
}
예제 #3
0
void byoSnake::DrawApple(wxDC* DC)
{
    if ( m_AppleX >= 0 && m_AppleY >= 0 )
    {
        DrawBrick(DC,m_AppleX+1,m_AppleY+3,GetColour(m_AppleColour));
    }
}
예제 #4
0
void byoSnake::DrawSnake(wxDC* DC)
{
    for ( int i=0; i<m_SnakeLen; i++ )
    {
        DrawBrick(DC,m_SnakeX[i]+1,m_SnakeY[i]+3,GetColour(m_SnakeColour));
    }
}
예제 #5
0
파일: tetris.c 프로젝트: xjiajiahao/tetris
void RotateBrick(void)
{
    int tmpBrick, success = 1;
    tmpBrick = currentBrick;
    currentBrick = type[currentBrick].next;
    success = DrawBrick();
    if (!success)
    {
        currentBrick = tmpBrick;
    }
}
예제 #6
0
파일: tetris.c 프로젝트: xjiajiahao/tetris
int FallBrick(void)
{
    short tmpy;
    int i, j, success;
    int shape[4][4];
    int x, y;
    int tmpBrick;
    tmpy = locate.y;
    locate.y += STEP;
    tmpBrick = type[currentBrick].Brick;
    success = DrawBrick();
    if (!success)
    {
        for (i=0; i<4 ; i++ )
        {
            for (j=0; j<4 ; j++ )
            {
                shape[3-i][3-j] = tmpBrick % 2;
                tmpBrick = tmpBrick / 2;
            }
        }
        locate.y = tmpy;
        x = (locate.x-_LeftEdge)/BrickSIZE + 4;
        y = locate.y/BrickSIZE;
        for (i=0; i<4 ; i++ )
        {
            for (j=0; j<4 ; j++ )
            {
                if (1 == shape[i][j])
                {
                    occupation[y+i][x+j] = 1;
                    occupationColor[y+i][x+j] = type[currentBrick].color;
                }
            }
        }
    }
    return success;
}
예제 #7
0
파일: tetris.c 프로젝트: xjiajiahao/tetris
void MoveBrick(int key)
{
    short tmpx, tmpy;
    int success;
    tmpx = locate.x;
    tmpy = locate.y;
    switch (key)
    {
    case DOWN:
        locate.y += STEP;
        break;
    case LEFT:
        locate.x -= STEP;
        break;
    case RIGHT:
        locate.x += STEP;
        break;
    }
    if (locate.x < _LeftEdge - BrickSIZE*4)
    {
        locate.x = _LeftEdge - BrickSIZE*4;
    }
    if (locate.x > _RightEdge)
    {
        locate.x = _RightEdge;
    }
    if (locate.y > _Bottom)
    {
        locate.y = _Bottom;
    }
    success = DrawBrick();
    if (!success)
    {
        locate.x = tmpx;
        locate.y = tmpy;
    }
}