示例#1
0
文件: font.cpp 项目: codespear/GameEx
void Font::drawText(char *text, int x, int y) {
	GLfloat left, right;
	GLfloat top, bottom;
	GLfloat texMinX, texMinY;
	GLfloat texMaxX, texMaxY;
	GLfloat minx;

	glPushAttrib(GL_ALL_ATTRIB_BITS);

	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	glEnable(GL_TEXTURE_2D);
	glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

	while (0 != *text) {
		if ((minGlyph <= *text) && (*text <= maxGlyph)) {
			loadChar(*text);

			texMinX = glyphs[((int) *text)].texMinX;
			texMinY = glyphs[((int) *text)].texMinY;
			texMaxX = glyphs[((int) *text)].texMaxX;
			texMaxY = glyphs[((int) *text)].texMaxY;

			minx = glyphs[((int) *text)].minx;

			left = x + minx;
			right = x + glyphs[((int) *text)].pic->w + minx;
			top = y;
			bottom = y + glyphs[((int) *text)].pic->h;

			glBindTexture(GL_TEXTURE_2D, glyphs[((int) *text)].tex);

			glBegin(GL_TRIANGLE_STRIP);

			glTexCoord2f(texMinX, texMinY);
			glVertex2f(left, top);
			glTexCoord2f(texMaxX, texMinY);
			glVertex2f(right, top);
			glTexCoord2f(texMinX, texMaxY);
			glVertex2f(left, bottom);
			glTexCoord2f(texMaxX, texMaxY);
			glVertex2f(right, bottom);

			glEnd();

			x += glyphs[((int) *text)].advance;
		}

		text++;
	}

	glPopAttrib();
}
示例#2
0
bool NumberToChar::setConfiguration(QHash<QString, QString> propertiesList)
{
    bool res = TransformAbstract::setConfiguration(propertiesList);

    QString tmp = propertiesList.value(XMLSEPARATOR);
    char tmpChar = '\x00';
    if (!loadChar(tmp,&tmpChar)) {
        res = false;
        emit error(tr("Invalid value for %1").arg(XMLSEPARATOR),id);
    } else {
        res = setSeparator(tmpChar) && res;
    }

    return res;
}
示例#3
0
/***********************************************************************
     * Character
     * constructor

***********************************************************************/
fired::Character::Character(fired::Camera *_cam, sf::Vector2f _startpos, fired::World *_world, fired::BaseCreature *_base, const char *filename) {
	world    = _world;
	cam      = _cam;
	base     = _base;

	memcpy(&baseStats, &(base->stats), sizeof(fired::CharacterStats));
	inventory = new fired::Inventory(this);

	helm      = NULL;
	arms      = NULL;
	legs      = NULL;
	body      = NULL;
	shoe      = NULL;
	fist      = NULL;
	weapon    = NULL;
	shotSound = NULL;


	switch (_base->model->type) {
		case mtHumanoid: {
			model = new fired::ModelHumanoid(this, (fired::BaseModelHumanoid*)_base->model, (fired::ModelHumanoidColors*)_base->colors, base->modelScale, world);
			break;
		}

		case mtAnimal: {
			model = new fired::ModelAnimal(this, (fired::BaseModelAnimal*)_base->model, (fired::ModelAnimalColors*)_base->colors, base->modelScale, world);
			break;
		}

		case mtSpider: {
			model = new fired::ModelSpider(this, (fired::BaseModelSpider*)_base->model, (fired::ModelSpiderColors*)_base->colors, base->modelScale, world);
			break;
		}
	}

	level    = 1;
	XP       = 0;
	fraction = _base->fraction;

	if (filename) loadChar(this, filename);

	updateStats();
	respawn(_startpos);

	lastXP         = levelXP(level - 1);
	needXP         = levelXP(level);
}
示例#4
0
bool UrlEncode::setConfiguration(QHash<QString, QString> propertiesList)
{
    bool res = TransformAbstract::setConfiguration(propertiesList);

    QString tmp = propertiesList.value(XMLPERCENTCHAR);
    char tmpChar = '\x00';
    if (!loadChar(tmp, &tmpChar)) {
        res = false;
        emit error(tr("Invalid value for %1").arg(XMLPERCENTCHAR),id);
    } else {
        setPercentSign(tmpChar);
    }

    include = QByteArray::fromBase64(propertiesList.value(XMLINCLUDE).toUtf8());
    exclude = QByteArray::fromBase64(propertiesList.value(XMLEXCLUDE).toUtf8());

    return res;
}
示例#5
0
bool Initialize()
{
    system("title Pro MageBomb");
    system("color 1F");
    
    std::cout << "[*] Pro Magebomb by Baxnie." << std::endl;
    std::cout << "[*] Report bugs to: [email protected]" << std::endl;
    std::cout << "[*] Read the file \"readme.txt\" and configure \"config.lua\" and \"characters.xml\"\n" << std::endl;
    
    std::cout << "[*] Initializing Winsock 1.1... ";
    WSAData wsadata;
    if(WSAStartup(MAKEWORD(1,1),&wsadata) != 0)
    {
        std::cout << "[error initializing winsock]" << std::endl;
        return false;
    }
    std::cout << "[done]" << std::endl;
    
    std::cout << "[*] Loading \"config.lua\"... ";
    if(!g_config.loadFile("config.lua"))
    {
        std::cout << "[error loading config.lua]" << std::endl;
        WSACleanup();
        return false;
    }
    std::cout << "[done]" << std::endl;

    std::cout << "[*] Loading \"characters.xml\"... ";
    if(!loadChar())
    {
        std::cout << "[error loading characters.xml]" << std::endl;
        WSACleanup();
        return false;
    }
    std::cout << "[done]\n" << std::endl;
    
    return true;
}
示例#6
0
文件: font.cpp 项目: codespear/GameEx
void Font::textSize(char *text, SDL_Rect *r) {
	int maxx = 0;
	int advance = 0;

	r->x = 0;
	r->y = 0;
	r->w = 0;
	r->h = height;

	while (0 != *text) {
		if ((minGlyph <= *text) && (*text <= maxGlyph)) {
			loadChar(*text);

			maxx = glyphs[(int) *text].maxx;
			advance = glyphs[(int) *text].advance;
			r->w += advance;
		}

		text++;
	}

	r->w = r->w - advance + maxx;
}