Esempio n. 1
0
File: l_quad.c Progetto: rxi/lovedos
int l_quad_new(lua_State *L) {
  quad_t *self = luaobj_newudata(L, sizeof(*self));
  luaobj_setclass(L, CLASS_TYPE, CLASS_NAME);
  self->x = luaL_checknumber(L, 1);
  self->y = luaL_checknumber(L, 2);
  self->width = luaL_checknumber(L, 3);
  self->height = luaL_checknumber(L, 4);
  return 1;
}
Esempio n. 2
0
int joystickNew(lua_State *L, int id) {
		
	love_joystick *self = luaobj_newudata(L, sizeof(*self));
	
	luaobj_setclass(L, CLASS_TYPE, CLASS_NAME);
	
	const char *error = joystickInit(self, id);
	
	if (error) luaError(L, error);
	
	return 1;
	
}
Esempio n. 3
0
int fontNew(lua_State *L) { // love.graphics.newFont()

	if (fontCounter <= fontLimit) {

		fontCounter += 1;
        
        int argc = lua_gettop(L);
        char *filename = 0;
        int fontSize = 14;
        
        //newFont(fontSize)
        if( argc == 1){
            fontSize = lua_isnoneornil(L, 1) ? NULL : luaL_checkinteger(L, 1);
        }
        
        //newFont(filename, fontsize)
        if( argc == 2 ) {
            filename = lua_isnoneornil(L, 1) ? NULL : luaL_checkstring(L, 1);
            fontSize = lua_isnoneornil(L, 2) ? NULL : luaL_checkinteger(L, 2);
        }

		love_font *self = luaobj_newudata(L, sizeof(*self));

		luaobj_setclass(L, CLASS_TYPE, CLASS_NAME);

		if (filename) {

			const char *error = fontInit(self, filename, fontSize);

			if (error) luaError(L, error);

		} else {

			fontDefaultInit(self, fontSize);
		}

		return 1;

	} else {

		luaError(L, "LovePotion currently has a 2 font limit. This limitation will hopefully be lifted in future versions.");
		return 0;

	}


}
Esempio n. 4
0
int imageNew(lua_State *L) { // love.graphics.newImage()

	const char *filename = luaL_checkstring(L, 1);

	love_image *self = luaobj_newudata(L, sizeof(*self));
	luaobj_setclass(L, CLASS_TYPE, CLASS_NAME);

	const char *error = imageInit(self, filename);
	if (error) luaError(L, error);

	sf2d_texture_set_params(self->texture, defaultFilter);
	self->minFilter = defaultMinFilter;
	self->magFilter = defaultMagFilter;

	return 1;

}
Esempio n. 5
0
int imageNew(lua_State *L) { // love.graphics.newImage()

	const char *filename = luaL_checkstring(L, 1);

	if (!fileExists(filename)) luaError(L, "Could not open image, does not exist");

	int type = getType(filename);
	if (type == 4) luaError(L, "Unknown image type");

	love_image *self = luaobj_newudata(L, sizeof(*self));
	luaobj_setclass(L, CLASS_TYPE, CLASS_NAME);

	const char *error = imageInit(self, filename);
	if (error) luaError(L, error);

	return 1;

}
Esempio n. 6
0
int quadNew(lua_State *L) { // love.graphics.newQuad()

	int x = luaL_checkint(L, 1);
	int y = luaL_checkint(L, 2);

	int width = luaL_checkint(L, 3);
	int height = luaL_checkint(L, 4);

	love_quad *self = luaobj_newudata(L, sizeof(*self));

	luaobj_setclass(L, CLASS_TYPE, CLASS_NAME);

	const char *error = quadInit(self, x, y, width, height);

	if (error) luaU_error(L, error);

	return 1;
}