Ejemplo n.º 1
0
void HexagonGame::drawText()
{
    ostringstream s;
    s << "time: " << toStr(currentTime).substr(0, 5) << endl;
    if(hasDied) s << "press r to restart" << endl;

    vector<Vector2f> offsets{{-1,-1},{-1,1},{1,-1},{1,1}};

    Text timeText(s.str(), getFont("imagine"), 25 / getZoomFactor());
    timeText.setPosition(15, 3);
    timeText.setColor(getColorMain());
    for(auto offset : offsets)
    {
        Text timeOffsetText(s.str(), getFont("imagine"), timeText.getCharacterSize());
        timeOffsetText.setPosition(timeText.getPosition() + offset);
        timeOffsetText.setColor(getColorB());
        drawOnWindow(timeOffsetText);
    }
    drawOnWindow(timeText);

    for (Text* textPtr : messageTextPtrs)
    {
        for(auto offset : offsets)
        {
            Text textPtrOffset{textPtr->getString(), getFont("imagine"), textPtr->getCharacterSize()};
            textPtrOffset.setPosition(textPtr->getPosition() + offset);
            textPtrOffset.setOrigin(textPtrOffset.getGlobalBounds().width / 2, 0);
            textPtrOffset.setColor(getColorB());
            drawOnWindow(textPtrOffset);
        }

        textPtr->setColor(getColorMain());
        drawOnWindow(*textPtr);
    }
}
Ejemplo n.º 2
0
	void HexagonGame::drawText()
	{
		ostringstream s;
		s << "time: " << toStr(status.currentTime).substr(0, 5) << "\n";

		if(levelStatus.tutorialMode) s << "tutorial mode" << "\n";
		else if(Config::getOfficial()) s << "official mode" << "\n";

		if(Config::getDebug()) s << "debug mode" << "\n";
		if(levelStatus.swapEnabled) s << "swap enabled" << "\n";
		if(Config::getInvincible()) s << "invincibility on" << "\n";
		if(status.scoreInvalid) s << "score invalidated (performance issues)" << "\n";
		if(status.hasDied) s << "press r to restart" << "\n";
		if(Config::getShowFPS()) s << "FPS: " << window.getFPS() << "\n";

		const auto& trackedVariables(levelStatus.trackedVariables);
		if(Config::getShowTrackedVariables() && !trackedVariables.empty())
		{
			s << "\n";
			for(const auto& t : trackedVariables)
			{
				if(!lua.doesVariableExist(t.variableName)) continue;
				string var{lua.readVariable<string>(t.variableName)};
				s << t.displayName << ": " << var << "\n";
			}
		}

		s.flush();

		const Vec2f pos{15, 3};
		const vector<Vec2f> offsets{{-1, -1}, {-1, 1}, {1, -1}, {1, 1}};

		Color offsetColor{getColor(1)};
		if(Config::getBlackAndWhite()) offsetColor = Color::Black;
		text.setString(s.str());
		text.setCharacterSize(25 / Config::getZoomFactor());
		text.setOrigin(0, 0);

		text.setColor(offsetColor);
		for(const auto& o : offsets) { text.setPosition(pos + o); render(text); }

		text.setColor(getColorMain());
		text.setPosition(pos);
		render(text);

		if(messageText.getString() == "") return;

		messageText.setOrigin(getGlobalWidth(messageText) / 2.f, 0);
		messageText.setColor(offsetColor);
		for(const auto& o : offsets) { messageText.setPosition(Vec2f{Config::getWidth() / 2.f, Config::getHeight() / 6.f} + o); render(messageText); }

		messageText.setColor(getColorMain());
		render(messageText);
	}
Ejemplo n.º 3
0
	void HexagonGame::drawText()
	{
		ostringstream s;
		s << "time: " << toStr(status.currentTime).substr(0, 5) << endl;
		if(getOfficial()) s << "official mode" << endl;
		if(getDebug()) s << "debug mode" << endl;
		if(status.scoreInvalid) s << "score invalidated (performance issues)" << endl;
		if(status.hasDied) s << "press r to restart" << endl;

		Vector2f pos{15, 3};
		vector<Vector2f> offsets{{-1, -1}, {-1, 1}, {1, -1}, {1, 1}};

		Color offsetColor{getColor(1)};
		if(getBlackAndWhite()) offsetColor = Color::Black;
		text.setString(s.str());
		text.setCharacterSize(25 / getZoomFactor());
		text.setOrigin(0, 0);

		text.setColor(offsetColor);
		for(const auto& o : offsets) { text.setPosition(pos + o); render(text); }

		text.setColor(getColorMain());
		text.setPosition(pos);
		render(text);
		
		if(messageTextPtr == nullptr) return;

		text.setString(messageTextPtr->getString());
		text.setCharacterSize(messageTextPtr->getCharacterSize());
		text.setOrigin(text.getGlobalBounds().width / 2, 0);

		text.setColor(offsetColor);
		for(const auto& o : offsets) { text.setPosition(messageTextPtr->getPosition() + o); render(text); }

		messageTextPtr->setColor(getColorMain());
		render(*messageTextPtr);
	}