Example #1
0
void BemGame::AddSpaceTiles()
{
	// This functions adds the background bitmaps. (Pictures
	// of Space.) The Space picture is a tile that is rotated
	// for variaton.

	KrResource* resource = engine->Vault()->GetResource(	KYRATAG_TILE,
															BEM_SPACE );
	GLASSERT( resource );

	KrTileResource* spaceTileRes = resource->ToTileResource();
	GLASSERT( spaceTileRes );

	int i, j;
	KrRect bounds = engine->FullScreenBounds();

	for( i=0; i<(bounds.Width() / spaceTileRes->Size() + 1); i++ )
	{
		for( j=0; j<(bounds.Height() / spaceTileRes->Size() + 1); j++ )
		{
			KrTile* spaceTile = new KrTile( spaceTileRes );
			GLASSERT( spaceTile );

			spaceTile->SetPos( i * spaceTile->Size(), j * spaceTile->Size() );
			spaceTile->SetRotation( (i+j) & 7 );

			engine->Tree()->AddNode( backgroundTree, spaceTile );
		}
	}
}
Example #2
0
void
Puzzle::setBackgroundTile(KrTile* tile)
{
	// Delete old tree if existing
	if( m_background_tree )
		Brainblast::instance()->engine()->Tree()->DeleteNode(m_background_tree);
	// Create new tree and insert in the global tree
	if( !m_background_tree ) {
		m_background_tree = new KrImNode;
		Brainblast::instance()->engine()->Tree()->AddNode(0, m_background_tree);
		m_background_tree->SetZDepth(BACZ);
	}
	
	// Create and position all bg tiles
	for(uint x=0;x<m_width;x++)
	{
		int xspace = m_rect.w/m_width;
		
		for(uint y=0;y<m_height;y++)
		{
			int yspace = m_rect.h/m_height;
			
			KrTile* ctile = tile->Clone()->ToTile();
			Brainblast::instance()->engine()->Tree()->AddNode(m_background_tree, ctile);
			ctile->SetPos(m_rect.x + x*xspace+xspace/2-ctile->Size()/2,
						  m_rect.y + y*yspace+yspace/2-ctile->Size()/2);
			m_back[y*m_width+x] = ctile;
		}
	}
}
Example #3
0
PyObject *
_wrap_tile_size (PyObject *self, PyObject *args)
{
	   PyObject *py_r;

	   if (!PyArg_ParseTuple (args, "O:size", &py_r)) return NULL;

	   KrTile *t = AS_PTR (KrTile, py_r);
	   GLASSERT (t);

	   int size = t->Size();

	   return PyInt_FromLong (size);
}
Example #4
0
PyObject *
_wrap_tile_set_rotation (PyObject *self, PyObject *args)
{
	   PyObject *py_r;
	   int       angle;
	   
	   if (!PyArg_ParseTuple (args, "Oi:set_rotation", &py_r, &angle)) return NULL;

	   KrTile *t = AS_PTR (KrTile, py_r);
	   GLASSERT (t);

	   t->SetRotation(angle);

	   RETURN_NONE;
}
Example #5
0
PyObject *
_wrap_tile_new (PyObject *self, PyObject *args)
{
        PyObject *py_r;

	   if (!PyArg_ParseTuple (args, "O:new", &py_r)) return NULL;
	   GLASSERT (py_r && py_r != Py_None);

	   KrTileResource *r = AS_PTR (KrTileResource, py_r);
	   GLASSERT (r);

	   KrTile *t = new KrTile (r);
	   GLASSERT (t);

	   t->SetUserData (KrTile_TYPE);

	   return PyCObject_FromVoidPtr (t, NULL);	   
}
Example #6
0
PyObject *
_wrap_tile_del (PyObject *self, PyObject *args)
{
	   PyObject *py_r;

	   if (!PyArg_ParseTuple (args, "O:del", &py_r)) return NULL;

	   KrTile *t = AS_PTR (KrTile, py_r);
	   GLASSERT (t);

	   if (t->GetUserData() != KrTile_TYPE) {
			 RETURN_NONE;
	   }

	   delete t;
	   
	   RETURN_1;
}
Example #7
0
KrImNode* KrTile::Clone()
{
	KrTile* tile = new KrTile( resource );
	tile->SetRotation( rotation );
	return tile;
}