Exemplo n.º 1
0
Arquivo: Area.cpp Projeto: dcbishop/tx
/**
 * For debugging, makes a square room on the map.
 * @param x1
 * @param y1
 * @param x2
 * @param y2
 */
void Area::boxRoom(const int x1, const int y1, const int x2, const int y2) {
    // Floor
    fill(x1+1, y1+1, x2-1, y2-1, TILE_FLOOR);

    // Top side
    fill(x1+1, y1, x2-1, y1, TILE_WALL, true, -90.0f);

    // Left side
    fill(x1, y1+1, x1, y2-1, TILE_WALL, true);

    // Right side
    fill(x2, y1+1, x2, y2-1, TILE_WALL, true, 180.0f);

    // Bottom side
    fill(x1+1, y2, x2-1, y2, TILE_WALL, true, 90.0f);

    // TL
    setTile(x1, y1, new Tile(TILE_INNERCORNER));
    setRotation(x1, y1, -90.0f);
    setSolid(x1, y1);

    // BL
    setTile(x1, y2, new Tile(TILE_INNERCORNER));
    setSolid(x1, y2);

    // TR
    setTile(x2, y1, new Tile(TILE_INNERCORNER));
    setRotation(x2, y1, -180.0f);
    setSolid(x2, y1);

    // BR
    setTile(x2, y2, new Tile(TILE_INNERCORNER));
    setRotation(x2, y2, 90.0f);
    setSolid(x2, y2);
}
Exemplo n.º 2
0
void PanelButton::configure()
{
    QString name = tileName();
    if( name.isEmpty() )
        return;

    if (!KickerSettings::enableTileBackground())
    {
        setTile(QString::null);
        return;
    }

    KConfigGroup tilesGroup( KGlobal::config(), "button_tiles" );
    if( !tilesGroup.readBoolEntry( "Enable" + name + "Tiles", true ) ) {
            setTile( QString::null );
        return;
    }

    QString tile = tilesGroup.readEntry( name + "Tile" );
    QColor color = QColor();

    if (tile == "Colorize")
    {
        color = tilesGroup.readColorEntry( name + "TileColor" );
        tile = QString::null;
    }

    setTile( tile, color );
}
Exemplo n.º 3
0
void Level::processPlayerMove(Player &player, int x, int y)
{
	int playerX;
	int playerY;
	player.getLocation(playerX, playerY);
	char moveTile;
	moveTile = getTile(x, y);
	switch (moveTile) {
	case '.':
		player.setLocation(x,y);
		setTile(playerX,playerY, '.');
		setTile(x,y, '@');
	}
}
Exemplo n.º 4
0
void Map::make_rectangle(int x, int y, int width, int height) {
    for(int i = x; i < x + width; i++) {
        for(int j = y; j < y + height; j++) {
            if(i == x || i == x + width - 1 || j == y || j == y + height - 1) {
                // We're on the border. Set a border tile if there's not ile set already
                if(!map.count(std::make_pair(i, j))) {
                    setTile(i, j, Tile('#', false));
                }
            } else {
                // We need to carve out a passable place
                setTile(i, j, Tile('.', true));
            }
        }
    }
}
Exemplo n.º 5
0
	void CCShakyTiles3D::update(cocos2d::ccTime time)
	{
		int i, j;
	
		for (i = 0; i < m_sGridSize.x; ++i)
		{
			for (j = 0; j < m_sGridSize.y; ++j)
			{
				ccQuad3 coords = originalTile(ccg(i, j));

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

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

				if (m_bShakeZ)
				{
					coords.bl.z += ( rand() % (m_nRandrange*2) ) - m_nRandrange;
					coords.br.z += ( rand() % (m_nRandrange*2) ) - m_nRandrange;
					coords.tl.z += ( rand() % (m_nRandrange*2) ) - m_nRandrange;
					coords.tr.z += ( rand() % (m_nRandrange*2) ) - m_nRandrange;
				}
							
				setTile(ccg(i, j), coords);
			}
		}
	}
Exemplo n.º 6
0
	void CCTurnOffTiles::turnOffTile(cocos2d::ccGridSize pos)
	{
		ccQuad3 coords;

		memset(&coords, 0, sizeof(ccQuad3));
		setTile(pos, coords);
	}
Exemplo n.º 7
0
void CCShakyTiles3D::update(float time)
{
    CC_UNUSED_PARAM(time);
    int i, j;

    for (i = 0; i < m_sGridSize.width; ++i)
    {
        for (j = 0; j < m_sGridSize.height; ++j)
        {
            ccQuad3 coords = originalTile(ccp(i, j));

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

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

            if (m_bShakeZ)
            {
                coords.bl.z += ( rand() % (m_nRandrange*2) ) - m_nRandrange;
                coords.br.z += ( rand() % (m_nRandrange*2) ) - m_nRandrange;
                coords.tl.z += ( rand() % (m_nRandrange*2) ) - m_nRandrange;
                coords.tr.z += ( rand() % (m_nRandrange*2) ) - m_nRandrange;
            }
                        
            setTile(ccp(i, j), coords);
        }
    }
}
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 TurnOffTiles::turnOffTile(const Point& pos)
{
    Quad3 coords;

    memset(&coords, 0, sizeof(Quad3));
    setTile(pos, 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);
        }
    }
}
Exemplo n.º 11
0
void Map::createEmptyTiles()
{
    // Create tiles and set coordinates.
    for (unsigned int j = 0; j < rows(); j++)
    {
        for (unsigned int i = 0; i < cols(); i++)
        {
            if (!getTile(i, j))
            {
                TrackTileBase * newTile = new TrackTile(
                    static_cast<TrackData &>(trackData()),
                    QPointF(TrackTile::TILE_W / 2 + i * TrackTile::TILE_W,
                    TrackTile::TILE_H / 2 + j * TrackTile::TILE_H),
                    QPoint(i, j));
                setTile(i, j, TrackTilePtr(newTile));
            }
            else
            {
                getTile(i, j)->setLocation(
                    QPointF(
                        TrackTile::TILE_W / 2 + i * TrackTile::TILE_W,
                        TrackTile::TILE_H / 2 + j * TrackTile::TILE_H));
                getTile(i, j)->setMatrixLocation(QPoint(i, j));
            }
        }
    }
}
Exemplo n.º 12
0
void CCTurnOffTiles::turnOffTile(const CCPoint& pos)
{
    ccQuad3 coords;

    memset(&coords, 0, sizeof(ccQuad3));
    setTile(pos, coords);
}
Exemplo n.º 13
0
//t is for type
bool TavernExpansion::makeExpansion(String tileMat, int t)
{
    int rowChange = row / 2;
    int colChange = col / 2;
    
    String tMat = "GridMaterial";
    
    getBorders();
    
    if (this->viableExpansion() == true)
    {
        TavernResources::getInstance()->removeGold(row * col * TavernResources::getInstance()->getTilePrice());
        TavernResources::getInstance()->incrementTilePrice();
        TavernResources::getInstance()->addBuildRep(row * col * 20);
       TavernResources::getInstance()->calcRep();
       
        for (int dRow = -rowChange; dRow <= rowChange; dRow++)
        {
            for (int dCol = -colChange; dCol <= colChange; dCol++)
            {
                if (centerPos.x + dRow > 0 && centerPos.x + dRow < DIM - 1 && centerPos.y + dCol > 0 && centerPos.y + dCol < DIM - 1)
                {
                    setTile(dRow, dCol, tMat, TILE, true);
                    setTE(dRow, dCol, true);
                }
            }
        }
        
        configureTiles(tMat);
        //redoBotWalls();
       return true;
    }
   return false;
}
Exemplo n.º 14
0
void CCJumpTiles3D::update(float time)
{
    int i, j;

    float sinz =  (sinf((float)M_PI * time * m_nJumps * 2) * m_fAmplitude * m_fAmplitudeRate );
    float sinz2 = (sinf((float)M_PI * (time * m_nJumps * 2 + 1)) * m_fAmplitude * m_fAmplitudeRate );

    for( i = 0; i < m_sGridSize.width; i++ )
    {
        for( j = 0; j < m_sGridSize.height; j++ )
        {
            ccQuad3 coords = originalTile(ccp(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(ccp(i, j), coords);
        }
    }
}
Exemplo n.º 15
0
void TileInfoView::onActiveUnitChanged(Unit* unit)
{
    if (unit)
    {
        setTile(unit->tile());
    }
}
Exemplo n.º 16
0
void TileMapEditTestNew::updateMap(float dt)
{
    // IMPORTANT
    //   The only limitation is that you cannot change an empty, or assign an empty tile to a tile
    //   The value 0 not rendered so don't assign or change a tile with value 0

    auto tilemap = (TileMapAtlas*) getChildByTag(kTagTileMap);
    
    //
    // For example you can iterate over all the tiles
    // using this code, but try to avoid the iteration
    // over all your tiles in every frame. It's very expensive
    //    for(int x=0; x < tilemap.tgaInfo->width; x++) {
    //        for(int y=0; y < tilemap.tgaInfo->height; y++) {
    //            Color3B c =[tilemap tileAt:Size(x,y));
    //            if( c.r != 0 ) {
    //                ////----CCLOG("%d,%d = %d", x,y,c.r);
    //            }
    //        }
    //    }
    
    // NEW since v0.7
    Color3B c = tilemap->getTileAt(Vec2(13,21));        
    c.r++;
    c.r %= 50;
    if( c.r==0)
        c.r=1;
    
    // NEW since v0.7
    tilemap->setTile(c, Vec2(13,21) );             
}
Exemplo n.º 17
0
    void TileMap::tick()
    {
        std::vector<glm::uvec2> toSet;
        std::vector<TileId> ids;

        for(auto animated = mAnimatedTiles.begin(); animated != mAnimatedTiles.end();)
        {
            if(animated->second.mTimeLeft == 0)
            {
                uint32_t x = animated->first.x;
                uint32_t y = animated->first.y;
                TileId id = animated->second.mNext;
                animated = mAnimatedTiles.erase(animated);
                
                toSet.push_back(glm::uvec2(x, y));
                ids.push_back(id);
                continue;
            }
            else
            {
                animated->second.mTimeLeft--;
                animated++;
            }
        }
        for(uint32_t i = 0; i < toSet.size(); i++)
        {
            setTile(toSet[i], ids[i], PRESERVE);
        }
    }
Exemplo n.º 18
0
void FoW::reset(FogStatus value) {
    for (int i = 0; i < height; i++) {
        for (int j = 0; j < width; j++) {
            status[i][j] = value;
            setTile(j, i, (value == HIDDEN)? ALL : NONE);
        }
    }
}
Exemplo n.º 19
0
/* move player (and box) from one position to another on the board */
int moveTo(int fromX, int fromY, int toX, int toY) {
	int box = 0;
	setTile(fromX, fromY, getGridTile(fromX, fromY));
	char next = getTile(toX, toY);
	if (next == TARGET) setTile(toX, toY, PLAYER_ON_TARGET);
	else if (next == BOX || next == BOX_ON_TARGET) {
		box = 1;
		next = getGridTile(toX, toY);
		if (next == BLANK) setTile(toX, toY, PLAYER);
		else if (next == TARGET) {
			setTile(toX, toY, PLAYER_ON_TARGET);
			increaseRemaining();
		}
		int newMovableY = toY+(toY-fromY);
		int newMovableX = toX+(toX-fromX);
		char newMovablePos = getTile(newMovableX, newMovableY);
		if (newMovablePos == BLANK) setTile(newMovableX, newMovableY, BOX);
		else if (newMovablePos == TARGET) {
			setTile(newMovableX, newMovableY, BOX_ON_TARGET);
			decreaseRemaining();
		}
	}
	else if (next == BLANK) setTile(toX, toY, PLAYER);
	return box;
}
Exemplo n.º 20
0
// Called in level. This function does the same as setTile, but also draws directly to the scrollsurface
// used normally, when items are picked up
bool CMap::changeTile(Uint16 x, Uint16 y, Uint16 t)
{
	if( setTile( x, y, t ) )
	{
		m_Tilemaps.at(1).drawTile(g_pVideoDriver->getScrollSurface(), (x<<4)&511, (y<<4)&511, t);
		return true;
	}
	return false;
}
Exemplo n.º 21
0
 FOR_EACH (Path::const_iterator, i, road)
 {
     const Position &pos = (*i);
     MapItem *const item = getTile(pos.x, pos.y);
     if (!item)
         setTile(pos.x, pos.y, new MapItem(MapItemType::ROAD));
     else
         item->setType(MapItemType::ROAD);
 }
Exemplo n.º 22
0
Arquivo: Area.cpp Projeto: dcbishop/tx
/**
 * Fills an area with tiles.
 * @param x1 Start x coordinate.
 * @param y1 Start y coordinate.
 * @param x2 End x coordinate.
 * @param y2 End y coordinate.
 * @param filename Tile's model filename.
 * @param solidness The tile's solid state.
 * @param rotation Tile's rotation.
 */
void Area::fill(const int x1, const int y1, const int x2, const int y2, const string filename, const bool solidity, const float rotation) {
    for(int y = y1; y <= y2; y++) {
        for(int x = x1; x <= x2; x++) {
            setTile(x, y, new Tile(filename));
            setRotation(x, y, rotation);
            setSolid(x, y, solidity);
        }
    }
}
Exemplo n.º 23
0
	bool createFeature(int x, int y, Direction dir)
	{
		static const int roomChance = 50; // corridorChance = 100 - roomChance

		int dx = 0;
		int dy = 0;

		if (dir == North)
			dy = 1;
		else if (dir == South)
			dy = -1;
		else if (dir == West)
			dx = 1;
		else if (dir == East)
			dx = -1;

		if (getTile(x + dx, y + dy) != Floor && getTile(x + dx, y + dy) != Corridor)
			return false;

		if (randomInt(100) < roomChance)
		{
			if (makeRoom(x, y, dir))
			{
				setTile(x, y, ClosedDoor);

				return true;
			}
		}

		else
		{
			if (makeCorridor(x, y, dir))
			{
				if (getTile(x + dx, y + dy) == Floor)
					setTile(x, y, ClosedDoor);
				else // don't place a door between corridors
					setTile(x, y, Corridor);

				return true;
			}
		}

		return false;
	}
Exemplo n.º 24
0
void editor::listenToMouse()
{
    if (levelLoaded)
    {
        if (pressedL)
        {
            int x = floor((xMouseReal-xCorner)/double(tilesize));
            int y = level.h - floor((yMouseReal-yCorner)/double(tilesize)) - 1;
            switch (mode)
            {
            case 0:
            case 1:
            case 2:
                try {
                    setTile(x, y, mode,
                            mode?selectedColor:(char *)"#ffffff",
                            selectedDurability);
                } catch (...) {}
                updateTile(x, y);
                break;
            case 3:
                if (x>=0 && y>=0 && x<level.w && y<level.h && tileType(x, y))
                {
                    int h=0, s=0, v=0;
                    int c = 0;
                    for (int i=-1; i<2; i++)
                        for (int j=-1; j<2; j++, c++)
                        {
                            try {
                                QColor tmp(tileColor(x+i, y+j));
                                h += tmp.hue();
                                s += tmp.saturation();
                                v += tmp.value();
                            } catch (...) {
                                QColor tmp(tileColor(x+(-1*i), y+(-1*j)));
                                h += tmp.hue();
                                s += tmp.saturation();
                                v += tmp.value();
                            }
                        }
                    h /= c;
                    s /= c;
                    v /= c;
                    QColor q;
                    q.setHsv(h, s, v);
                    char m[8];
                    for (int i=0; i<8; i++)
                        m[i] = (q.name().constData()+i)->toAscii();
                    qstrcpy(tileColor(x, y), m);
                    updateTile(x, y);
                    break;
                }
            }
        }
    }
}
Exemplo n.º 25
0
Tile::Tile(int _x, int _y, int _layer, int texNum, double _direction){
  tile_t temp;
  x=_x;
  y=_y;
  layer=_layer;
  direction=_direction;
  
  temp.texName=texNum;
  temp.on=1;
  t = setTile(x,y,layer,temp);
}
Exemplo n.º 26
0
void GridSystem::processEntity(Entity *entity, const float dt)
{
    auto grid = static_cast<GridComponent*>(entity->getComponent(GridComponent::Type));

	// ###############
	// Do the grid simulation

	if (grid->mID == -1)
    {
		grid->mID = mNextGridID;
		mNextGridID++;
	}

	// Iterate through cached interesting tiles that need to be operated on
	for (unsigned int t = 0; t < mTicks.size(); t++)
    {
		if (mTicks[t].mClock.getElapsedTime().asSeconds() < mTicks[t].mDelay)
			continue;

		mTicks[t].mClock.restart();

        //if (grid->mCTiles[t].size())
        //    std::cout << "Tick!\n";

        //std::cout << grid->mCTiles[t].size() << std::endl;
        if (mTicks[t].mOp.getType() == GridOp::STATIC)
        {
            std::vector<Area> areas;
            for (auto coord : grid->mCTiles[t])
            {
                Area a = grid->getArea(coord.x, coord.y);

                // New tile
                a = mTicks[t].mOp(a);
                if (a.mChanged)
                    areas.push_back(a);
            }

            grid->clearInteresting(t);

            //if (areas.size() > 0)
            //    std::cout << "Areas: " << areas.size() << std::endl;
            for (auto a : areas)
            {
                grid->setTile(a.mX, a.mY, a.mTiles[1][1], t);
            }
        }
        else
        {
            mTicks[t].mOp(grid, t);
            grid->clearInteresting(t);
        }
	}
}
Exemplo n.º 27
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);
}
Exemplo n.º 28
0
// Called in level. This function does the same as setTile, but also draws directly to the scrollsurface
// used normally, when items are picked up
bool CMap::changeTile(Uint16 x, Uint16 y, Uint16 t)
{
    const int drawMask = gVideoDriver.getScrollSurface()->w-1;

	if( setTile( x, y, t ) )
	{
        m_Tilemaps.at(1).drawTile(gVideoDriver.getScrollSurface(), (x<<4)&drawMask, (y<<4)&drawMask, t);
		return true;
	}
	return false;
}
Exemplo n.º 29
0
void CCFadeOutUpTiles::transformTile(const CCPoint& pos, float distance)
{
    ccQuad3 coords = originalTile(pos);
    CCPoint step = m_pTarget->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 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);
}