Added 3 unicode pages for font, fixed UI, added Block.breakable

Added 1, 2, 3 and 4 unicode pages from Minecraft.
Font now uses std::wstring instead of std::string
Added Block.breakable field (the only unbreakable block is bedrock)
Bedrock is now selectable
This commit is contained in:
MihailRis 2022-07-14 19:23:31 +03:00 • committed by GitHub
parent b2872650d6
commit bdd3fbf7d4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 94 additions and 47 deletions

View file

@ -34,12 +34,16 @@ bool _load_texture(Assets* assets, std::string filename, std::string name){
}
bool _load_font(Assets* assets, std::string filename, std::string name){
Texture* texture = load_texture(filename);
if (texture == nullptr){
std::cerr << "failed to load bitmap font '" << name << "'" << std::endl;
return false;
std::vector<Texture*> pages;
for (size_t i = 0; i <= 4; i++){
Texture* texture = load_texture(filename+"_"+std::to_string(i)+".png");
if (texture == nullptr){
std::cerr << "failed to load bitmap font '" << name << "' (missing page " << std::to_string(i) << ")" << std::endl;
return false;
}
pages.push_back(texture);
}
Font* font = new Font(texture);
Font* font = new Font(pages);
assets->store(font, name);
return true;
}
@ -62,13 +66,15 @@ int initialize_assets(Assets* assets) {
LOAD_TEXTURE("res/block.png", "block");
LOAD_FONT("res/font.png", "normal");
LOAD_FONT("res/font", "normal");
return 0;
}
// All in-game definitions (blocks, items, etc..)
void setup_definitions() {
for (size_t i = 0; i < 256; i++)
Block::blocks[i] = nullptr;
// AIR 0
Block* block = new Block(0,0);
block->drawGroup = 1;
@ -128,13 +134,13 @@ void setup_definitions() {
block->selectable = false;
Block::blocks[block->id] = block;
// SEND 10
// SAND 10
block = new Block(10,12);
Block::blocks[block->id] = block;
// BEDROCK 11
block = new Block(11,13);
block->selectable = false;
block->breakable = false;
Block::blocks[block->id] = block;
}
#endif // DECLARATIONS_H