当前位置: 首页>>代码示例>>C++>>正文


C++ Tileset::getTileHeight方法代码示例

本文整理汇总了C++中Tileset::getTileHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ Tileset::getTileHeight方法的具体用法?C++ Tileset::getTileHeight怎么用?C++ Tileset::getTileHeight使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tileset的用法示例。


在下文中一共展示了Tileset::getTileHeight方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: runtime_error

void Flared_NS::Layer::set(size_t n, size_t index, ITileInfo* i_interface)
{
    if(!index)
        return;
    
    Tileset* curtile = nullptr;
    for( auto i : d_list)
    {
        if( i->getCount() >= index)
        {
            curtile = i;
            break;
        }
        index -= i->getCount();
    }
    
    if(!curtile)
        throw std::runtime_error("Tilesets don't contain index");
    
    d_layer.at(n).info().path =  curtile->getName();
    d_layer.at(n).info().w = curtile->getTileWidth();
    d_layer.at(n).info().h = curtile->getTileHeight();
    d_layer.at(n).info().x = curtile->getPositionX(index);
    d_layer.at(n).info().y = curtile->getPositionY(index);
    d_layer.at(n).info().setTileInfoInterface(i_interface);
}
开发者ID:Nordsoft91,项目名称:MagicWars,代码行数:26,代码来源:FlaredLayer.cpp

示例2: drawTile

void Map::drawTile(int id,int x, int y)
{
	for(int k=0; k < tilesets.getSize(); k++)
	{
		Tileset* tileset = tilesets.get(k);
		if(id <= tileset->getLasttId() && id >= tileset->getFirstId())
		{
			id -= tileset->getFirstId();
			int tw = tileset->getTileWidth();
			int th = tileset->getTileHeight();
			int imw = al_get_bitmap_width(tileset->getImage());

			//tile
			int sx = id*tw % imw;
			int sy = id/(imw/tw)*th;

			al_draw_bitmap_region(tileset->getImage(),sx,sy,tileWidth,tileHeight,(x*tileWidth) - (xOffs%tileWidth),(y*tileHeight) - (yOffs%tileHeight),0);
		}
	}
}
开发者ID:hudovisk,项目名称:Allegro,代码行数:20,代码来源:Map.cpp

示例3: draw

void MapperTilesetBox::draw(gcn::Graphics* graphics){
    // draw components
    InfraellyWindow::draw(graphics);

    //draw selection overlay
    if( !tilesetList->empty() ){
        Tileset *selectedTs = tilesetList->at( tilesetDropDown->getSelected() );
        if( selectedTs != NULL ){
            if( selectedTs->getImage() != NULL ){
                //tile width and height
                int tileWidth = selectedTs->getTileWidth();
                int tileHeight = selectedTs->getTileHeight();

                //calculate amount of px off the screen
                int offsetX = tilesetImage->getX();
                int offsetY = tilesetImage->getY();

                // convert pixel values to row, width
                int offCol = offsetX/tileWidth;
                int offRow = offsetY/tileHeight;



                //get the row and col of the selected tile
                int trueCol = selectedTile.getCol();
                int trueRow = selectedTile.getRow();


                //to find out the reletive row/col to draw to
                //  we must minus the offscreen tiles from the true tiles co-ords
                int drawCol = trueCol + offCol;
                int drawRow = trueRow + offRow;


                //calculate where to draw in pxs
                int drawX = (drawCol * tileWidth) + (tilesetImageScroller->getX() + getFrameSize());
                int drawY = (drawRow * tileHeight) + (tilesetImageScroller->getY() + getTitleBarHeight());


                //add offsets according to scroller
                drawX += offsetX%tileWidth;
                drawY += offsetY%tileHeight;


                //dimensions of the frame
                gcn::Rectangle d( drawX+selectedTs->getXOffset(),
                                  drawY+selectedTs->getYOffset(),
                                  tileWidth, tileHeight );

                //only draw if within region
                if(  ( d.x < tilesetImageScroller->getX()+tilesetImageScroller->getWidth() ) &&
                     ( d.x+d.width > tilesetImageScroller->getX() ) &&
                     ( d.y < tilesetImageScroller->getY()+tilesetImageScroller->getHeight()+getTitleBarHeight() ) &&
                     ( d.y+d.height > tilesetImageScroller->getY()+getTitleBarHeight() )
                ){
                    //setcolour to blue
                    graphics->setColor( gcn::Color( 0, 0, 255) );
                    //draw a frame
                    graphics->drawRectangle( d );
                    //decrease the dimensions by one pixel
                    ++d.x;
                    ++d.y;
                    d.width -= 2;
                    d.height -= 2;
                    //draw another frame (inside prev one)
                    graphics->drawRectangle( d );
                } else {
                    //not in region, draw a bob
                    //off the left
                    if( (d.x+d.width) < tilesetImageScroller->getX() ){
                        d.x = tilesetImageScroller->getX();
                        d.y += (tileHeight/2)-5;
                    };
                    //off the right
                    if( d.x > (tilesetImageScroller->getWidth()+tilesetImageScroller->getX()) ){
                        d.x = tilesetImageScroller->getWidth()-10;
                        d.y += (tileHeight/2)-5;

                    };
                    //off the top
                    if( (d.y+d.height) < tilesetImageScroller->getY() ){
                        d.y = tilesetImageScroller->getY()+getTitleBarHeight();
                        d.x += (tileWidth/2)-5;
                    };
                    //off the bottom
                    if( d.y > (tilesetImageScroller->getHeight()+tilesetImageScroller->getY()+getTitleBarHeight())  ){
                        d.y = tilesetImageScroller->getY()+tilesetImageScroller->getHeight()+getTitleBarHeight() - 10;
                        d.x += (tileWidth/2)-5;
                    };
                    //draw the bob (5x5px box)
                    d.width = 10;
                    d.height = 10;
                    //setcolour to red
                    graphics->setColor( gcn::Color( 255, 0, 0) );
                    graphics->fillRectangle( d );
                }
            }
        }
    }
}
开发者ID:hoodwolf,项目名称:Infraelly,代码行数:100,代码来源:MapperTilesetBox.cpp

示例4: mouseClicked

void MapperTilesetBox::mouseClicked(gcn::MouseEvent& mouseEvent){
    InfraellyWindow::mouseClicked(mouseEvent);

    if( mouseEvent.isConsumed() ){ return; };

    //if click was from closeTilesetButton
    if( mouseEvent.getSource() == closeTilesetButton ){
        //consume mouse event
        mouseEvent.consume();
        //get the pointer to the tileset to remove
        Tileset *toRemove = tilesetList->at( tilesetDropDown->getSelected() );

        //check if the user is trying to dlete teh nullTS
        if( toRemove != tilesetList->at(0) ){
            //store number to remove
            int removeIndex = tilesetDropDown->getSelected();
            //change the selected ts to the nullTS
            tilesetDropDown->setSelected(0);
            //delete the entry from teh list
            tilesetList->removeElementAt( removeIndex );


            //if there is a map activley associated
            if( world != NULL ){
                //stip dependency from map working on
                //if there IS dependency
                if( !world->empty() ){
                    //cycle through layers
                    for( size_t i = 0; i < world->size(); ++i ){
                        //cycle thru tiles
                        for( size_t j = 0; j < world->getLayer(i).getHeight() * world->getLayer(i).getWidth(); ++j){
                            if( world->getLayer(i).index(j).getTileset() == toRemove ){
                                world->getLayer(i).index(j).setTileset(NULL);
                            }
                        }
                    }
                }
            }
            //dependency of tileset stripped
            //delete the tileset
            cache::tilesets.erase(toRemove);

            //remove from selected tile
            selectedTile.setSource(NULL,0,0);
        }
    }


    //click from the tilesetImage
    if( mouseEvent.getSource() == tilesetImage ){
        //consume mouse event
        mouseEvent.consume();
        if( !tilesetList->empty() ){
            Tileset *selectedTs = selectedTile.getTileset();
            if( selectedTs != NULL ){
                // tileset select
                int tileWidth = selectedTs->getTileWidth();
                int tileHeight = selectedTs->getTileHeight();

                // get the x-y co-ords reletive to the tileset region
                int col = mouseEvent.getX() - (tilesetImage->getX()+selectedTs->getXOffset());
                int row = mouseEvent.getY() - (tilesetImage->getY()+selectedTs->getYOffset());

                // if its a multiple of tilewidth/height (ie in the barrier between)
                if( col % tileWidth == 0){ ++col; };
                if( row % tileHeight == 0){ ++row; };

                // turn co-ords into row/col
                col = col/tileWidth;
                row = row/tileHeight;


                // calculate the amount of tiles off the screen
                int trueCol = tilesetImage->getX();
                int trueRow = tilesetImage->getY();

                //  if its a multiple of tilewidth/height (ie in the barrier between)
                if( trueCol % tileWidth == 0){ ++col; };
                if( trueRow % tileHeight == 0){ ++row; };
                // turn co-ords into row/col
                trueCol = trueCol/tileWidth;
                trueRow = trueRow/tileHeight;
                //add the on screen offset to the offsecreen tiles
                trueCol += col-1;
                trueRow += row-1;

                //store the tile's new row-col
                selectedTile.setSource( selectedTs, trueCol, trueRow);
                //store attribute if on atrib ts
                if( selectedTile.getTileset() == attribTs ){
                    selectedTile.setAttribute(attribGrid[trueCol][trueRow]);
                }
            }// end if null
        }//end if empty list
    }//end if event from drop down*/
}
开发者ID:hoodwolf,项目名称:Infraelly,代码行数:96,代码来源:MapperTilesetBox.cpp


注:本文中的Tileset::getTileHeight方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。