void ShakyTiles3D::update(float time)
{
    CC_UNUSED_PARAM(time);
    int i, j;

    for (i = 0; i < _gridSize.width; ++i)
    {
        for (j = 0; j < _gridSize.height; ++j)
        {
            Quad3 coords = getOriginalTile(Point(i, j));

            // X
            coords.bl.x += ( rand() % (_randrange*2) ) - _randrange;
            coords.br.x += ( rand() % (_randrange*2) ) - _randrange;
            coords.tl.x += ( rand() % (_randrange*2) ) - _randrange;
            coords.tr.x += ( rand() % (_randrange*2) ) - _randrange;

            // Y
            coords.bl.y += ( rand() % (_randrange*2) ) - _randrange;
            coords.br.y += ( rand() % (_randrange*2) ) - _randrange;
            coords.tl.y += ( rand() % (_randrange*2) ) - _randrange;
            coords.tr.y += ( rand() % (_randrange*2) ) - _randrange;

            if (_shakeZ)
            {
                coords.bl.z += ( rand() % (_randrange*2) ) - _randrange;
                coords.br.z += ( rand() % (_randrange*2) ) - _randrange;
                coords.tl.z += ( rand() % (_randrange*2) ) - _randrange;
                coords.tr.z += ( rand() % (_randrange*2) ) - _randrange;
            }
                        
            setTile(Point(i, j), coords);
        }
    }
}
void JumpTiles3D::update(float time)
{
    int i, j;

    float sinz =  (sinf((float)M_PI * time * _jumps * 2) * _amplitude * _amplitudeRate );
    float sinz2 = (sinf((float)M_PI * (time * _jumps * 2 + 1)) * _amplitude * _amplitudeRate );

    for( i = 0; i < _gridSize.width; i++ )
    {
        for( j = 0; j < _gridSize.height; j++ )
        {
            Quad3 coords = getOriginalTile(Point(i, j));

            if ( ((i+j) % 2) == 0 )
            {
                coords.bl.z += sinz;
                coords.br.z += sinz;
                coords.tl.z += sinz;
                coords.tr.z += sinz;
            }
            else
            {
                coords.bl.z += sinz2;
                coords.br.z += sinz2;
                coords.tl.z += sinz2;
                coords.tr.z += sinz2;
            }

            setTile(Point(i, j), coords);
        }
    }
}
예제 #3
0
void wyLeftLineShrinkOut::transformTile(wyDimension pos, float distance) {
	wyQuad3D coords = getOriginalTile(pos);
	wyPoint step = wyp(m_target->getGrid()->getStepWidth(), m_target->getGrid()->getStepHeight());

	coords.bl_x += (step.x / 2) * (1.0f - distance);
	coords.br_x -= (step.x / 2) * (1.0f - distance);
	coords.tl_x += (step.x / 2) * (1.0f - distance);
	coords.tr_x -= (step.x / 2) * (1.0f - distance);

	setTile(pos, coords);
}
void FadeOutUpTiles::transformTile(const Point& pos, float distance)
{
    Quad3 coords = getOriginalTile(pos);
    Point step = _target->getGrid()->getStep();

    coords.bl.y += (step.y / 2) * (1.0f - distance);
    coords.br.y += (step.y / 2) * (1.0f - distance);
    coords.tl.y -= (step.y / 2) * (1.0f - distance);
    coords.tr.y -= (step.y / 2) * (1.0f - distance);

    setTile(pos, coords);
}
void WavesTiles3D::update(float time)
{
    for (int i = 0; i < _gridSize.width; i++ )
    {
        for (int j = 0; j < _gridSize.height; j++ )
        {
            Quad3 coords = getOriginalTile(Vec2(i, j));

            coords.bl.z = (sinf(time * (float)M_PI  *_waves * 2 + 
                (coords.bl.y+coords.bl.x) * .01f) * _amplitude * _amplitudeRate );
            coords.br.z    = coords.bl.z;
            coords.tl.z = coords.bl.z;
            coords.tr.z = coords.bl.z;

            setTile(Vec2(i, j), coords);
        }
    }
}
void ShuffleTiles::placeTile(const Point& pos, Tile *t)
{
    Quad3 coords = getOriginalTile(pos);

    Point step = _target->getGrid()->getStep();
    coords.bl.x += (int)(t->position.x * step.x);
    coords.bl.y += (int)(t->position.y * step.y);

    coords.br.x += (int)(t->position.x * step.x);
    coords.br.y += (int)(t->position.y * step.y);

    coords.tl.x += (int)(t->position.x * step.x);
    coords.tl.y += (int)(t->position.y * step.y);

    coords.tr.x += (int)(t->position.x * step.x);
    coords.tr.y += (int)(t->position.y * step.y);

    setTile(pos, coords);
}
void FadeOutTRTiles::transformTile(const Vec2& pos, float distance)
{
    Quad3 coords = getOriginalTile(pos);
    Vec2 step = _gridNodeTarget->getGrid()->getStep();

    coords.bl.x += (step.x / 2) * (1.0f - distance);
    coords.bl.y += (step.y / 2) * (1.0f - distance);

    coords.br.x -= (step.x / 2) * (1.0f - distance);
    coords.br.y += (step.y / 2) * (1.0f - distance);

    coords.tl.x += (step.x / 2) * (1.0f - distance);
    coords.tl.y -= (step.y / 2) * (1.0f - distance);

    coords.tr.x -= (step.x / 2) * (1.0f - distance);
    coords.tr.y -= (step.y / 2) * (1.0f - distance);

    setTile(pos, coords);
}
void SplitCols::update(float time)
{
    for (unsigned int i = 0; i < _gridSize.width; ++i)
    {
        Quad3 coords = getOriginalTile(Vec2(i, 0));
        float    direction = 1;

        if ( (i % 2 ) == 0 )
        {
            direction = -1;
        }

        coords.bl.y += direction * _winSize.height * time;
        coords.br.y += direction * _winSize.height * time;
        coords.tl.y += direction * _winSize.height * time;
        coords.tr.y += direction * _winSize.height * time;

        setTile(Vec2(i, 0), coords);
    }
}
void SplitRows::update(float time)
{
    for (unsigned int j = 0; j < _gridSize.height; ++j)
    {
        Quad3 coords = getOriginalTile(Vec2(0, j));
        float    direction = 1;

        if ( (j % 2 ) == 0 )
        {
            direction = -1;
        }

        coords.bl.x += direction * _winSize.width * time;
        coords.br.x += direction * _winSize.width * time;
        coords.tl.x += direction * _winSize.width * time;
        coords.tr.x += direction * _winSize.width * time;

        setTile(Vec2(0, j), coords);
    }
}
예제 #10
0
void wyWavesTiles3D::update(float t) {
	wyDimension gridPos = wydZero;
	for(int i = 0; i < m_gridX; i++) {
		for(int j = 0; j < m_gridY; j++) {
			gridPos.x = i;
			gridPos.y = j;
			wyQuad3D coords = getOriginalTile(gridPos);

			// set z of four corners to same
			coords.bl_z = wyMath::sin(t * M_PI * m_waves * 2 + (coords.bl_y + coords.bl_x) * .01f) * m_amplitude * m_amplitudeRate;
			coords.br_z = coords.bl_z;
			coords.tl_z = coords.bl_z;
			coords.tr_z = coords.bl_z;

			setTile(gridPos, coords);
		}
	}

	// super only call callback
	wyTiledGrid3DAction::update(t);
}
void ShatteredTiles3D::update(float /*time*/)
{
    int i, j;

    if (_once == false)
    {
        for (i = 0; i < _gridSize.width; ++i)
        {
            for (j = 0; j < _gridSize.height; ++j)
            {
                Quad3 coords = getOriginalTile(Vec2(i ,j));
                
                // X
                coords.bl.x += ( rand() % (_randrange*2) ) - _randrange;
                coords.br.x += ( rand() % (_randrange*2) ) - _randrange;
                coords.tl.x += ( rand() % (_randrange*2) ) - _randrange;
                coords.tr.x += ( rand() % (_randrange*2) ) - _randrange;
                
                // Y
                coords.bl.y += ( rand() % (_randrange*2) ) - _randrange;
                coords.br.y += ( rand() % (_randrange*2) ) - _randrange;
                coords.tl.y += ( rand() % (_randrange*2) ) - _randrange;
                coords.tr.y += ( rand() % (_randrange*2) ) - _randrange;

                if (_shatterZ) 
                {
                    coords.bl.z += ( rand() % (_randrange*2) ) - _randrange;
                    coords.br.z += ( rand() % (_randrange*2) ) - _randrange;                
                    coords.tl.z += ( rand() % (_randrange*2) ) - _randrange;
                    coords.tr.z += ( rand() % (_randrange*2) ) - _randrange;
                }
                
                setTile(Vec2(i, j), coords);
            }
        }
        
        _once = true;
    }
}
void TurnOffTiles::turnOnTile(const Point& pos)
{
    setTile(pos, getOriginalTile(pos));
}
void FadeOutTRTiles::turnOnTile(const Point& pos)
{
    setTile(pos, getOriginalTile(pos));
}
예제 #14
0
void wyLeftLineShrinkOut::turnOnTile(wyDimension pos) {
	setTile(pos, getOriginalTile(pos));
}
예제 #15
0
void wyRightTopTilesShrinkOut::turnOnTile(wyDimension pos) {
	setTile(pos, getOriginalTile(pos));
}