Beispiel #1
0
void GameLayerMapBorder::addBorderLine(const GameBorderLine& line)
{
    if (line._borderList.empty()) return ;
    float h = 0;
    auto start = *line._borderList.begin();
    auto  pre = _borderMap.find(start.getPreMapCell());
    if(pre != _borderMap.end())
    {
        h = pre->second._quadStartHeight+BORDER_HEIGHT;
        BorderCell cell;
        if(isBorderCell(pre->first._x, pre->first._y, GridType::None, cell))
        {
            pre->second._maskType=cell._maskDir;
            
            updateQuad(pre->first, pre->second);
        }
        
    }
    auto rstart = *line._borderList.rbegin();
    auto  endNext = _borderMap.find(rstart.getNextMapCell());
    if(endNext != _borderMap.end())
    {
        BorderCell cell;
        if(isBorderCell(endNext->first._x, endNext->first._y, GridType::None, cell))
        {
            endNext->second._maskType=cell._maskDir;
            
            updateQuad(endNext->first, endNext->second);
        }
    }
    Size size =_quads->getTexture()->getContentSize();
    if(h>size.height)
    {
        int n = h/size.height;
        h = h - size.height* n;
    }
    for (auto i : line._borderList) {
        V3F_C4B_T2F_Quad quad = createQuadByBorderCell(i._cell, i._maskDir, h);
        int index = createOneQuad();
        BorderContext context(i._maskDir,h,index);
        _borderMap.insert(std::make_pair(i._cell, context));
        updateQuad(i._cell, context);
        h += 8.0f;
    }
}
Beispiel #2
0
void  GameLayerMapBorder::moveDown(float y)
{
    auto ip = _borderMap.begin();
    auto end = _borderMap.end();
    while (ip!=end) {
        BorderContext context = ip->second;
        GridCell cell = ip->first;
        updateQuad(cell, context);
        ip->second = context;
        ip++;
    }
    for (auto& i : _bodies) {
        auto pt =  i->GetPosition();
        i->SetTransform(b2Vec2(pt.x,pt.y-y/PTM_RATIO), 0);
    }
}
Beispiel #3
0
//HGE* Cursor::m_hge = 0;
Cursor::Cursor(void) 
: HGEObject(), GameObserver(), m_texture(0), m_posx(0.f), m_posy(0.f), m_texHeight(0), m_texWidth(0)
{
	//m_hge = hgeCreate( HGE_VERSION ); // done in HGEObject class

	// TODO:: Implement using resource manager!!!!
	// or changing TileMap class
	m_texture = m_hge->Texture_Load( "res/images/cursor.png" );
	if( m_texture == 0 ) {
		MessageBox( NULL, "Can't load cursor texture!", 
					"Error", MB_ICONERROR | MB_OK| MB_APPLMODAL 
					);
		exit( -1 );
	}

	m_quad = new hgeQuad;

	m_quad->tex = m_texture;

	m_quad->blend = BLEND_DEFAULT_Z;

	m_quad->v[0].tx = 0.0f;		 m_quad->v[1].tx = 1.0f;
	m_quad->v[0].ty = 0.0f;		 m_quad->v[1].ty = 0.0f;
	m_quad->v[3].tx = 0.0f;		 m_quad->v[2].tx = 1.0f;
	m_quad->v[3].ty = 1.0f;		 m_quad->v[2].ty = 1.0f;

	for( int ind=0;ind<4;++ind ) {
		m_quad->v[ind].col = 0xffffffff;
		m_quad->v[ind].z = 0.01f;
	}

	m_texHeight = m_hge->Texture_GetHeight( m_texture );
	m_texWidth = m_hge->Texture_GetWidth( m_texture );

    updateQuad();
}
void QuadPrimitive::setSize(float width, float height)
{
	m_width = width;
	m_height = height;
	updateQuad(m_center, osg::Vec2{ m_width, m_height }, m_localX, m_localY);
}
void QuadPrimitive::setWidth(float width)
{
	m_width = width;
	updateQuad(m_center, osg::Vec2{ m_width, m_height }, m_localX, m_localY);
}
Beispiel #6
0
// IRenderable overloads
bool Cursor::update( float delta ) {
	updateQuad( );
	return false;
}