Example #1
0
const char *fontInit(love_font *self, const char *filename, int size) {

	if (!fileExists(filename)) return "Could not open font. Does not exist.";

	self->font = sftd_load_font_file(filename);
	self->size = size;

	return NULL;

}
Example #2
0
/***
Load a TTF font.
@function load
@tparam string path path to the file
@treturn font the loaded font.
*/
static int font_load(lua_State *L) {
	const char *path = luaL_checkstring(L, 1);

	font_userdata *font = lua_newuserdata(L, sizeof(*font));
	luaL_getmetatable(L, "LFont");
	lua_setmetatable(L, -2);

	font->font = sftd_load_font_file(path);

	// SFTD doesn't actually check if the file exist, so we have to do this ourselves.
	if (font->font == NULL || access(path, F_OK) != 0) {
		lua_pushnil(L);
		lua_pushfstring(L, "No valid font file at %s", path);
		return 2;
	}

	return 1;
}
Example #3
0
void init(void) {
    // Starting services
    sf2d_init();
    sf2d_set_vblank_wait(0);
    sftd_init();
    srvInit();
    aptInit();
    hidInit();
    audio_init();
    //romfsInit();

    // Configuring the right font to use (8bitoperator), and its proprieties
    font = sftd_load_font_file("font/eightbit.ttf");

    // Configuring graphics in general (images, textures, etc)
    sf2d_set_clear_color(RGBA8(0x00, 0x00, 0x00, 0xFF));

    /* Load Frisk textures
       Loop over every element in tex_arr_friskWalk and load the PNG buffer. */

    for (int i = 0; i < 4; ++i) {
        for (int j = 0; j < 4; ++j) {
            tex_arr_friskWalk[i][j] = loadTexture(friskFilenames[i][j]);
        }
    }

    room_init();

    // Reusing 'i' from above.
    // Load room textures.
    for (int i = 0; i < 3; ++i) fillTexture(&rooms[i].bg);

    // TODO: Add actual save loading logic. For now, just assume this room.
    player_pos = rooms[room].exits[0].entrance;

    // Play music
    home = sound_create(BGM);
    if (home != NULL) audio_load_ogg("sound/music/house1.ogg", home);
    else home->status = -1;

    timerStep();
}