system assets
This commit is contained in:
parent
cb2d30bf4f
commit
2a5b777cd9
|
@ -4,4 +4,7 @@
|
|||
|
||||
.vs
|
||||
x64
|
||||
build
|
||||
build
|
||||
*.tlog
|
||||
*.idb
|
||||
*pdb
|
Binary file not shown.
|
@ -0,0 +1,3 @@
|
|||
[default-font-prop.png]
|
||||
proportional = true
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
|
@ -13,4 +13,12 @@
|
|||
#include "vec2.h"
|
||||
|
||||
const double PI = 3.141592653589793238462643383279502884197169399375105820974944592307816406286;
|
||||
const double TAU = PI * 2;
|
||||
const double TAU = PI * 2;
|
||||
|
||||
/*
|
||||
|
||||
TODO:
|
||||
make resource manager global
|
||||
disallow more than one game instance
|
||||
|
||||
*/
|
|
@ -13,6 +13,8 @@ struct font : resource {
|
|||
//font(std::string const& path, bool proportional);
|
||||
|
||||
image const* get(char ch) const;
|
||||
int lineheight() const;
|
||||
private:
|
||||
std::map<char, image> _glyphs;
|
||||
int _lineheight;
|
||||
};
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
del src\system_assets.h
|
||||
7z a system_assets.7z _
|
||||
binpack system_assets.7z
|
||||
move Resources.h src\system_assets.h
|
||||
del system_assets.7z
|
|
@ -1,7 +1,13 @@
|
|||
#include "image.h"
|
||||
|
||||
void image::draw(std::string const& str, vec2i pos, font const* font, color color) {
|
||||
auto origx = pos.x;
|
||||
for(auto ch = str.begin(); ch != str.end(); ++ch) {
|
||||
if(*ch == '\n') {
|
||||
pos.x = origx;
|
||||
pos.y += font->lineheight();
|
||||
continue;
|
||||
}
|
||||
draw(font->get(*ch), pos, color);
|
||||
pos.x += font->get(*ch)->size().x;
|
||||
}
|
||||
|
|
|
@ -18,11 +18,11 @@ font::font(resource_manager& rm, ini_category const* ini, std::string const& pat
|
|||
}
|
||||
int count = slices.size();
|
||||
slices.push_back(image->size().x);
|
||||
auto height = image->size().y;
|
||||
_lineheight = image->size().y - 1;
|
||||
|
||||
auto charset = " !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_'abcdefghijklmnopqrstuvwxyz{|}~";
|
||||
for(int i = 0; i < count; ++i) {
|
||||
auto r = recti(vec2i(slices[i], 1), vec2i(slices[i + 1] - slices[i], height - 1));
|
||||
auto r = recti(vec2i(slices[i], 1), vec2i(slices[i + 1] - slices[i], _lineheight));
|
||||
//auto img = ::image(r.size);
|
||||
auto ch = charset[i];
|
||||
_glyphs.emplace(ch, r.size);
|
||||
|
@ -38,3 +38,7 @@ image const* font::get(char ch) const {
|
|||
else
|
||||
return &_glyphs.at(' ');
|
||||
}
|
||||
|
||||
int font::lineheight() const {
|
||||
return _lineheight;
|
||||
}
|
||||
|
|
|
@ -3,9 +3,13 @@
|
|||
#include <string>
|
||||
#include <physfs.h>
|
||||
|
||||
#define BP_INSER_RESOURCES
|
||||
#include "system_assets.h"
|
||||
|
||||
resource_manager::resource_manager() {
|
||||
PHYSFS_init(0);
|
||||
mount("assets", "/");
|
||||
PHYSFS_mountMemory(BP_system_assets, sizeof(BP_system_assets), 0, "system-assets", "/", 0);
|
||||
}
|
||||
|
||||
void resource_manager::mount(std::string const& path, std::string const& mounting_point) {
|
||||
|
|
|
@ -0,0 +1,57 @@
|
|||
// auto-generated using BinPack. https://github.com/TheOathMan/BinPack
|
||||
//IMPORTANT: You must #define BP_INSER_RESOURCES only once before including this header file in order to insert the data into the compilation process
|
||||
extern const unsigned char BP_system_assets[1464];
|
||||
#ifdef BP_INSER_RESOURCES
|
||||
const unsigned char BP_system_assets[1464] = {
|
||||
55,122,188,175,39,28,0,4,184,62,235,5,117,5,0,0,0,0,0,0,35,0,0,0,0,0,0,0,19,9,
|
||||
33,13,1,4,224,91,100,101,102,97,117,108,116,45,102,111,110,116,45,112,114,111,112,46,112,110,103,93,13,10,
|
||||
112,114,111,112,111,114,116,105,111,110,97,108,32,61,32,116,114,117,101,13,10,13,10,137,80,78,71,13,10,26,
|
||||
10,0,0,0,13,73,72,68,82,0,0,2,12,0,0,0,12,8,6,0,0,0,14,25,229,38,0,0,0,1,
|
||||
115,82,71,66,0,174,206,28,233,0,0,4,107,73,68,65,84,120,156,237,91,109,114,227,32,12,37,59,123,188,
|
||||
220,167,103,232,125,114,63,239,143,93,239,168,47,239,233,3,112,236,180,188,153,142,49,8,33,132,16,66,78,219,
|
||||
182,109,91,51,216,223,85,61,131,215,54,218,110,219,34,153,20,159,76,61,163,137,218,103,140,241,174,245,21,221,
|
||||
69,245,85,57,122,251,93,189,254,232,241,190,203,24,87,179,151,234,184,213,117,191,146,62,123,121,100,253,197,21,
|
||||
247,252,43,244,163,240,138,121,85,230,113,195,138,143,251,157,209,165,240,249,120,108,31,247,251,109,127,154,250,110,
|
||||
158,11,215,196,136,157,44,44,124,39,68,254,109,237,149,133,239,128,207,199,163,253,34,149,27,123,122,101,213,15,
|
||||
104,88,196,130,117,155,160,83,52,25,250,163,129,115,68,153,152,188,138,198,155,143,71,159,149,33,75,239,213,187,
|
||||
64,187,200,182,239,246,194,236,10,255,162,126,179,232,213,216,158,76,170,142,233,64,201,200,232,50,245,106,188,12,
|
||||
175,170,110,60,249,71,245,95,157,119,86,31,61,252,162,245,255,215,37,180,249,200,38,60,185,123,219,71,249,91,
|
||||
186,145,125,141,101,207,62,223,13,239,38,55,219,95,106,125,25,237,239,202,64,246,185,151,109,70,1,159,166,251,
|
||||
214,254,102,51,246,103,131,50,190,99,27,163,105,9,250,163,145,153,207,62,239,214,158,101,180,52,138,239,254,142,
|
||||
200,232,71,209,90,71,23,173,147,199,247,11,200,186,63,65,100,160,232,187,226,167,218,237,123,134,95,68,143,245,
|
||||
56,143,104,254,145,62,188,57,42,100,233,45,93,246,112,154,165,203,106,31,43,103,69,23,71,3,101,177,122,132,
|
||||
54,182,103,158,248,88,31,218,179,246,103,96,84,70,101,19,11,175,135,90,75,182,255,172,141,154,178,14,24,208,
|
||||
89,160,129,23,13,41,10,22,102,35,27,112,28,49,198,222,54,11,246,16,159,201,175,183,111,107,173,221,118,231,
|
||||
215,99,15,104,75,81,63,199,81,15,225,104,7,54,155,127,143,142,177,92,229,115,36,142,148,129,205,49,184,212,
|
||||
148,249,1,220,160,1,229,176,207,236,248,216,127,180,62,226,143,1,142,226,193,2,83,239,16,194,113,51,242,169,
|
||||
224,55,154,115,150,126,111,179,246,17,241,193,75,180,23,20,103,234,213,129,93,229,167,116,87,129,178,209,116,134,
|
||||
33,98,206,210,28,36,10,111,45,119,208,142,28,104,229,155,241,132,113,88,155,58,224,109,189,202,34,84,116,149,
|
||||
225,163,128,114,222,68,189,11,229,8,144,14,111,27,25,7,130,244,108,108,37,19,27,183,138,170,67,86,109,51,
|
||||
210,199,213,121,120,217,145,51,130,6,92,195,51,130,22,54,247,40,144,40,232,42,29,52,100,101,101,229,222,236,
|
||||
143,58,156,189,204,79,38,27,24,201,168,208,115,227,173,206,185,66,239,205,209,243,73,71,218,113,53,200,85,114,
|
||||
171,0,90,141,165,248,79,249,36,161,38,70,6,87,89,6,44,99,93,22,246,160,99,60,109,25,121,163,67,143,
|
||||
2,130,106,91,212,238,233,9,235,153,236,246,176,87,227,85,222,89,16,66,29,152,114,194,205,65,213,49,51,251,
|
||||
195,113,70,156,151,130,119,232,70,125,170,183,188,72,142,153,206,73,5,96,12,61,135,188,234,51,99,93,148,143,
|
||||
201,30,112,81,208,128,243,40,202,56,53,104,176,114,244,246,205,200,63,26,208,86,113,149,44,23,131,58,72,85,
|
||||
123,150,103,111,118,171,167,79,198,190,179,129,145,197,83,192,144,189,149,116,44,56,11,16,216,198,194,250,74,214,
|
||||
1,249,226,1,171,126,27,192,14,97,54,118,228,8,102,111,0,239,112,63,3,242,147,4,179,15,236,28,217,78,
|
||||
207,225,60,130,171,57,173,72,158,179,130,134,76,240,167,250,120,55,183,87,35,10,46,60,250,34,166,6,13,217,
|
||||
180,125,182,63,195,89,217,166,43,237,63,15,179,46,32,61,168,6,26,71,202,247,20,48,120,131,121,55,5,44,
|
||||
3,31,220,60,184,161,108,102,128,181,99,61,43,55,65,63,11,153,96,33,243,57,128,101,50,178,217,13,143,71,
|
||||
36,67,164,79,70,159,149,167,181,246,213,9,120,153,130,108,155,58,208,170,55,38,60,36,24,159,108,54,32,115,
|
||||
160,103,229,196,189,146,233,31,5,102,35,153,148,138,236,149,96,163,50,191,172,76,202,129,142,220,228,24,148,126,
|
||||
49,96,38,248,239,195,34,61,69,54,238,233,186,98,231,222,126,202,218,81,37,51,21,97,102,208,80,221,219,189,
|
||||
25,54,228,109,249,68,54,238,101,182,88,121,31,155,5,185,74,126,150,137,101,115,102,250,201,172,3,115,72,81,
|
||||
31,9,231,251,80,55,207,127,56,242,118,125,133,155,251,219,225,227,126,63,253,198,184,112,45,252,84,123,136,252,
|
||||
219,136,79,189,58,42,107,126,134,125,92,225,86,254,10,188,66,254,79,239,191,36,122,96,35,153,137,108,87,176,
|
||||
112,65,188,251,6,91,152,143,101,15,63,3,189,191,105,89,246,49,23,163,191,171,88,88,88,88,88,88,88,88,
|
||||
56,4,127,0,2,250,26,26,6,173,233,101,0,0,0,0,73,69,78,68,174,66,96,130,0,0,0,129,51,7,
|
||||
174,15,213,93,230,102,167,37,71,87,5,211,28,163,88,34,62,138,95,234,247,189,134,92,115,241,181,21,199,82,
|
||||
146,81,26,15,184,26,224,126,254,177,234,148,95,89,248,60,160,8,143,105,92,152,95,251,50,89,239,43,171,220,
|
||||
131,227,43,42,246,223,203,134,165,37,172,6,22,121,73,113,219,43,138,205,189,136,242,133,146,217,86,11,96,173,
|
||||
30,44,170,22,48,226,211,12,149,51,184,160,100,251,165,142,170,131,249,90,208,223,222,207,245,36,89,254,183,93,
|
||||
86,109,69,15,166,103,164,187,166,213,67,235,27,96,158,160,209,118,184,23,6,132,229,1,9,128,144,0,7,11,
|
||||
1,0,1,35,3,1,1,5,93,0,16,0,0,12,128,194,10,1,36,20,65,57,0,0};
|
||||
|
||||
|
||||
#endif // BP_INSER_RESOURCES
|
Binary file not shown.
Before Width: | Height: | Size: 1.2 KiB |
|
@ -9,6 +9,7 @@ struct my_game : game {
|
|||
image const* img;
|
||||
ini const* ini;
|
||||
|
||||
|
||||
//tileset tileset;
|
||||
font const* font;
|
||||
double time;
|
||||
|
@ -16,13 +17,9 @@ struct my_game : game {
|
|||
|
||||
void my_game::init(settings& settings) {
|
||||
settings.target_fps = 60;
|
||||
img = get<image>("test.png");
|
||||
ini = get<::ini>("test.ini");
|
||||
font = get<::font>("habbo.png");
|
||||
std::cout << ini->get<std::string>("", "meow") << std::endl;
|
||||
std::cout << ini->get<std::string>("cat1", "squish") << std::endl;
|
||||
std::cout << ini->get<bool>("cat1", "bool") << std::endl;
|
||||
std::cout << ini->get<int>("cat1", "num") << std::endl;
|
||||
//img = get<image>("test.png");
|
||||
//ini = get<::ini>("test.ini");
|
||||
font = get<::font>("_/default-font-prop.png");
|
||||
//cursor(&font['\\']);
|
||||
}
|
||||
|
||||
|
@ -34,9 +31,10 @@ void my_game::render(image& target) {
|
|||
target.clear(0xffdddd);
|
||||
auto pos = vec2i(std::sin(time * TAU / 4) * 100, std::cos(time * TAU / 4) * 100);
|
||||
//target.draw(img, vec2i(320, 180) + pos, recti(vec2i(8, 14), vec2i(8 * 4, 14 * 4)));
|
||||
target.draw(img, vec2i::zero);
|
||||
//target.draw(img, vec2i::zero);
|
||||
//target.draw(tileset[0xda], vec2i(320, 180) + pos, 0xff00ff);
|
||||
target.draw("hello world!", vec2i(320, 180) + pos, font, 0xffffff, 0);
|
||||
auto str = "Can only be played if\nthere are no card in\nyour draw pile.\nDeal 50 damage to ALL\nenemies.";
|
||||
target.draw(str, vec2i(100, 100) + pos, font, 0xffffff, 0);
|
||||
//target.draw("\\", mouse_pos(), font, 0xffffff, 0);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue