예제 #1
0
void CTile::LoadTile(char* file, int id)
{
	ifstream fs;		// Luồng đọc file map
	string line;		// Chuỗi đọc file map
	switch (id)
	{
	case 1:_textureBkg = CTexture("Resources//Resources//Maps//boom_man_stage.bmp", D3DCOLOR_XRGB(255, 255, 255), _graphic->GetDevice()); break;
	case 2:_textureBkg = CTexture("Resources//Resources//Maps//cut_man_stage.bmp", D3DCOLOR_XRGB(255, 255, 255), _graphic->GetDevice());break;
	case 3: _textureBkg = CTexture("Resources//Resources//Maps//guts_man_stage.bmp", D3DCOLOR_XRGB(255, 255, 255), _graphic->GetDevice());break;
	default:
		break;
	}
	
	// Mở file và đọc, nếu không được thì out
	fs.open(file, ios::in);
	if (!fs.is_open())
	{
		OutputDebugString("Can not open map file");
		return;
	}

	istringstream iss;								

#pragma endregion

#pragma region Tiến hành đọc dữ liệu từ file .txt

#pragma region Lấy thông tin ma trận tile

	getline(fs, line);
	if (line.compare("#Tile_Matrix") == 0)
	{
		getline(fs, line);								// Bỏ qua dòng "Total_Row	Total_Column	Total_Tile"
		getline(fs, line);
		iss.clear();
		iss.str(line);
		iss >> _countRow >> _countColumn >> _totalTile;	// Đẩy giá trị tổng số dòng, cột, tổng số tile vào biến
		getline(fs, line);								// Bỏ qua dòng "#Tile_Matrix_Value"

		// Tạo mảng hai chiều lưu ma trận tile
		for (int i = 0; i < _countRow; i++)
		{
			vector<int> row;
			row.resize(_countColumn);
			_tileMatrix.push_back(row);
		}

		// Tiến hành đọc dữ liệu
		for (int i = 0; i < _countRow; i++)
		{
			getline(fs, line);
			iss.clear();
			iss.str(line);
			for (int j = 0; j < _countColumn; j++)
				iss >> _tileMatrix[i][j];
		}
		getline(fs, line);					// Bỏ qua dòng "#Tile_Matrix_End"
	}
예제 #2
0
void CWindow::renderIntro(bool *done)
{
    static CPoster post(-1,1,2,2);
    post.texId = CTexture("texture/intro.bmp").texId;

    while(!*done and !exit)
    {
        post.draw();
        pollEvent();
        window.display();
    }
}
예제 #3
0
CBarMana::CBarMana( D3DXVECTOR2 position,string name)
{
	_isDraw = true;
	_textureMana = CTexture("Resources//Sprites//Others//bar_rockman.png", D3DCOLOR_XRGB(0, 102, 102));;
	_position = position;
	_maxMana = 27;
	_textureBG =  CTexture("Resources//Sprites//Others//bar_background.png", D3DCOLOR_XRGB(0, 102, 102));

	_text =  CTextblock();
	_text._position = _position;
	_text._size = D3DXVECTOR2(SCREEN_WIDTH, SCREEN_HEIGHT / 28);
	_text._text = name;
	_text._color = D3DCOLOR_XRGB(255, 255, 255);
	
	_position.x += 15;//5


	_boundingBG.left = 0;
	_boundingBG.top = 0;
	_boundingBG.right = _boundingBG.left + _textureBG.GetWidth();
	_boundingBG.bottom = _boundingBG.top + _textureBG.GetHeight();
}
예제 #4
0
CProjectedShadow::CProjectedShadow(u32 w, u32 h, bool persistent)
: x0_texture(CTexture(ETexelFormat::I4, w, h, 1)), x81_persistent(persistent) {}
예제 #5
0
CTexture::CTexture(const char* txtName)
{
 CTexture();
 strncpy(name,txtName,8);
 }