void init(){
	// Set display options.
	REG_DISPCNT = DCNT_MODE0 | DCNT_OBJ | DCNT_BG0 | DCNT_BG1 | DCNT_BG2 | DCNT_BG3;
	
	// Set background 0 options.
	REG_BG0CNT = BG_CBB(0) | BG_SBB(30) | BG_8BPP | BG_REG_32x32;
	REG_BG0HOFS = 0;
	REG_BG0VOFS = 0;
	// Set background 1 options.
	REG_BG1CNT = BG_CBB(0) | BG_SBB(29) | BG_8BPP | BG_REG_32x32;
	REG_BG1HOFS = 0;
	REG_BG1VOFS = 0;
	// Set background 2 options.
	REG_BG2CNT = BG_CBB(0) | BG_SBB(28) | BG_8BPP | BG_REG_32x32;
	REG_BG2HOFS = 0;
	REG_BG2VOFS = 0;
	// Set background 3 options.
	REG_BG3CNT = BG_CBB(0) | BG_SBB(27) | BG_8BPP | BG_REG_32x32;
	REG_BG3HOFS = 0;
	REG_BG3VOFS = 0;
	
	LoadTileData(0, 0, backgroundTiles, backgroundTilesLen);
	LoadPaletteBGData(0, menuBGPal, menuBGPalLen);
	
	LoadTileData(4, 0, spritesTiles, spritesTilesLen);
	LoadTileData(4, 64, font_bold, 8192);
	LoadPaletteObjData(0, spritesPal, spritesPalLen);
	
	//Clear backgrounds
	for (int y = 0; y < 32; ++y){
	for (int x = 0; x < 32; ++x){
		SetTile(30, x, y, 0);
		SetTile(29, x, y, 0);
		SetTile(28, x, y, 0);
		SetTile(27, x, y, 0);
	}
	}
	
	//Set-up backgrounds from maps
	for(int i = 0; i < cloudBGMapLen; i++){
		SetTile(27, i%32, i/32, cloudBGMap[i]);
	};
	for(int i = 0; i < buildingBGMapLen; i++){
		SetTile(28, i%32, i/32, buildingBGMap[i]);
	};
	for(int i = 0; i < fenceBGMapLen; i++){
		SetTile(29, i%32, i/32, fenceBGMap[i]);
	};
	for(int i = 0; i < girderMapLen; i++){
		SetTile(30, i%32, i/32, girderMap[i]);
	};
}
bool NFCTileModule::LoadTileData(const NFGUID & self)
{
	const int nSceneID = m_pKernelModule->GetPropertyInt32(self, NFrame::Player::HomeSceneID());
	LoadTileData(self, nSceneID);

	return false;
}
bool CMaNGOS_Map::ShowNeighborTiles(int height, int width)
{
    bool mouseOverMenu = false;
    static int levelScroll = 0;
    unsigned int winHSize = 25 * m_NeighborTiles.size() + 30;
    const unsigned int winWSize = 180;
    if (imguiBeginScrollArea("Choose neighbor tile", width - 10 - 250 - 10 - winWSize, height -10 - winHSize, winWSize, winHSize, &levelScroll))
        mouseOverMenu = true;

    std::set<uint32>::iterator itr = m_NeighborTiles.begin();
    while (itr != m_NeighborTiles.end())
    {
        char buff[10];
        memset(buff, 0, sizeof(buff));
        itoa(*itr, buff, 10);
        unsigned int x, y;
        VMAP::StaticMapTree::unpackTileID(*itr, x, y);
        snprintf(buff, sizeof(buff), "%dx%d", x, y);
        if (imguiItem(buff))
        {
            if (LoadTileData(x, y))
            {
                m_showLevel = SHOW_LEVEL_NONE;
                itr = m_NeighborTiles.erase(itr);
                continue;
            }
        }
        ++itr;
    }

    imguiEndScrollArea();
    return mouseOverMenu;
}
void StartUp::start()
{

	LoadTileData(1, 1, startUpSpriteTiles, sizeof startUpSpriteTiles);

	
}
Exemple #5
0
CMap::CMap( int16_t gridx, int16_t gridy, int16_t gridw, int16_t gridh, std::string path ) :
    mTag        (0),
    mDimensions (),
    mPath       (path),
    mTileData   ()
{
    mDimensions.TileX( gridx );
    mDimensions.TileY( gridy );
    mDimensions.TileW( gridw );
    mDimensions.TileH( gridh );

    LoadTileData();
}
Exemple #6
0
void MenuBackground::Init()
{
    int lvlnumber = (rand() % 8) + 1;

    m_path = ("levels/Level"+aw::conv::ToString(lvlnumber)+"/");

    m_textures.clear();
    m_tiles.clear();

    if(!LoadTextures())
    {
        return;
    }

    LoadTileData(1);

    m_tilesPerRow = 800 / m_tileSize.x;

}
int NFCTileModule::OnObjectClassEvent(const NFGUID & self, const std::string & strClassName, const CLASS_OBJECT_EVENT eClassEvent, const NFDataList & var)
{
	if (CLASS_OBJECT_EVENT::COE_DESTROY == eClassEvent)
	{
		//cannot save tile here, because player maybe offline in other people scene
	}
	else if (CLASS_OBJECT_EVENT::COE_CREATE_BEFORE_EFFECT == eClassEvent)
	{
		//preload at first, then attach
		LoadTileData(self);
	}
	else if (CLASS_OBJECT_EVENT::COE_CREATE_CLIENT_FINISH == eClassEvent)
	{
		//load
		SendTileData(self);

		m_pKernelModule->AddRecordCallBack(self, NFrame::Player::BuildingList::ThisName(), this, &NFCTileModule::OnRecordEvent);
	}

	return 0;
}
int main()
{
	// Set display options.
	// DCNT_MODE0 sets mode 0, which provides four tiled backgrounds.
	// DCNT_OBJ enables objects.
	// DCNT_OBJ_1D make object tiles mapped in 1D (which makes life easier).
	REG_DISPCNT = DCNT_MODE0 | DCNT_BG0 | DCNT_BG1 | DCNT_BG2 | DCNT_OBJ;
	
	REG_BG0CNT = BG_CBB(0) | BG_SBB(30) | BG_8BPP | BG_REG_32x32 | BG_PRIO(0);
	
	REG_BG1CNT = BG_CBB(0) | BG_SBB(29) | BG_8BPP | BG_REG_32x32 | BG_PRIO(1);
	
	REG_BG2CNT = BG_CBB(0) | BG_SBB(25) | BG_8BPP | BG_REG_64x64 | BG_PRIO(2);
	REG_BG2HOFS = 0;
	REG_BG2VOFS = 0;
	
	ClearObjects();
	
	SetPaletteBG(1, RGB(31, 31, 31)); // white
	
	//Load each tile in font_bold into it's corresponding position in charblock 0
	for (int i = 0; i < 128; i++)
	{
		LoadTile8(0, i, font_bold[i]);
	}
	
	DrawText(5, (SCREEN_HEIGHT / 16) - 2, "DECEPTIVE DIMENSIONS");
	DrawText(5, (SCREEN_HEIGHT / 16), "Press start to begin");
	
	Buttons buttons;
	int framecounter = 0;
	
	//Title screen (under construction)
	while (true)
	{
		buttons.Update();
		
		if (buttons.StartJustPressed())
		{
			break;
		}
		
		WaitVSync();	
	}
	
	while (true)
	{
		//Load Custom spritesheet
		LoadPaletteObjData(0, spritesheet4Pal, sizeof spritesheet4Pal);
		LoadPaletteBGData(0, backgroundnewnewPal, sizeof backgroundnewnewPal);
		LoadTileData(4, 0, spritesheet4Tiles, sizeof spritesheet4Tiles);
		LoadTileData(0, 0, backgroundnewnewTiles, sizeof backgroundnewnewTiles);
		
		int levelnumber = 1;
		
		Level level(levelnumber);
		
		for (int screenblock = 21; screenblock < 31; screenblock++)
		{
			level.FillScreenblock(screenblock, 0);
		}
		
		level.DrawBackground(level.curdimension);
		
		bool gamerunning = true;
		
		//Main game loop
		while (gamerunning)
		{
			buttons.Update();
			
			gamerunning = level.CheckIfLevelComplete();
			level.TakeInput(buttons);
			level.MoveObjects();
			level.Draw();
			level.UpdateLevelObjects(framecounter);

			framecounter++;
			
			WaitVSync();
			FlipBuffers();
		}
		
		//Reload each tile in font_bold into it's corresponding position in charblock 0
		for (int i = 0; i < 128; i++)
		{
			LoadTile8(0, i, font_bold[i]);
		}
		
		SetPaletteBG(0, RGB(0, 0, 0)); // black
		SetPaletteBG(1, RGB(31, 31, 31)); // white		
		
		for (int screenblock = 25; screenblock < 31; screenblock++)
		{
			for (int y = 0; y < 32; y++)
			{
				for (int x = 0; x < 32; x++)
				{
					SetTile(screenblock, x, y, 0);
				}
			}
		}
		
		level.player.drawx = SCREEN_WIDTH;
		
		SetObject(level.player.GetObjNum(),
		  ATTR0_SHAPE(2) | ATTR0_8BPP | ATTR0_HIDE,
		  ATTR1_SIZE(2) | ATTR1_X(level.player.drawx),
		  ATTR2_ID8(0) | ATTR2_PRIO(2));
		
		UpdateObjects();
		
		DrawText(6, (SCREEN_HEIGHT / 16) - 2, "That's all folks!!");
		DrawText(3, (SCREEN_HEIGHT / 16), "Press start to try again");
		
		while (true)
		{
			buttons.Update();
			
			if (buttons.StartJustPressed())
			{
				break;
			}
			
			WaitVSync();
		}
	}
}
bool CMaNGOS_Map::ShowTilesLevel(int height, int width)
{
    bool mouseOverMenu = false;
    static int levelScroll = 0;
    unsigned int winHSize = height - 20;
    const unsigned int winWSize = 180;
    if (imguiBeginScrollArea("Choose tile", width - 10 - 250 - 10 - winWSize, height - 10 - winHSize, winWSize, winHSize, &levelScroll))
        mouseOverMenu = true;

    for (std::set<uint32>::const_iterator itr = m_TilesFound.begin(); itr != m_TilesFound.end(); ++itr)
    {
        char buff[10];
        memset(buff, 0, sizeof(buff));
        itoa(*itr, buff, 10);
        unsigned int x, y;
        VMAP::StaticMapTree::unpackTileID(*itr, x, y);
        if (x == y && x == 64)
            snprintf(buff, sizeof(buff), "Full Map");
        else
            snprintf(buff, sizeof(buff), "%dx%d", x, y);
        if (imguiItem(buff))
        {
            // if first chosen tile, add neighbor
            if (m_MapInfos->IsEmpty())
            {
                m_NeighborTiles.clear();
                if (x != y || x != 64)
                {
                    for (int i = 0; i < 3; ++i)
                    {
                        for (int j = 0; j < 3; ++j)
                        {
                            uint32 tx = x - 1 + i;
                            uint32 ty = y - 1 + j;

                            // skip current already loaded tile
                            if (tx == x && ty == y)
                                continue;

                            // add only available tile
                            uint32 pxy = VMAP::StaticMapTree::packTileID(tx, ty);
                            if (m_TilesFound.find(pxy) != m_TilesFound.end())
                                m_NeighborTiles.insert(pxy);
                        }
                    }
                }
            }

            if (LoadTileData(x, y))
                m_showLevel = SHOW_LEVEL_NONE;

            if (m_MapInfos->IsEmpty())
                m_TileButtonStr = "Click to choose a tile";
            else if (!m_NeighborTiles.empty())
                m_TileButtonStr = "Add neighbor tile";
            else
                m_TileButtonStr = "No neighbor tile to add";
        }
    }
    imguiEndScrollArea();
    return mouseOverMenu;
}