Beispiel #1
0
void Field::draw( Painter &p ) const
{
    for ( int y = 0; y < Field::HEIGHT; ++y ) {
        for ( int x = 0; x < Field::WIDTH; ++x ) {
            switch ( m_m[y][x] ) {
                case Field::EMPTY:
                    break;
                case Field::SNAKE_BLOCK:
                    p.bar( x * Field::BLOCK_WIDTH,
                           y * Field::BLOCK_HEIGHT,
                           ( x + 1 ) * Field::BLOCK_WIDTH - 1,
                           ( y + 1 ) * Field::BLOCK_HEIGHT - 1 );
                    break;
                case Field::FRUIT:
                    p.circle( x * Field::BLOCK_WIDTH + Field::BLOCK_WIDTH / 2,
                              y * Field::BLOCK_HEIGHT + Field::BLOCK_HEIGHT / 2,
                              Field::BLOCK_WIDTH / 2 - 1 );
            }
        }
    }
}
Beispiel #2
0
void Pedal::draw(Painter &p) const
{
  p.setColor(Painter::ORANGE);
  p.bar(x_ - WIDTH / 2, Wall::HEIGHT - 2, 
	 x_ + WIDTH - WIDTH / 2, Wall::HEIGHT);
}