Exemple #1
0
	void CPlayer::drawPivot()
	{
		float thickness{5}, div{360.f / hexagonGame.getSides()}, radius{hexagonGame.getRadius() * 0.75f};
		Color colorMain{hexagonGame.getColorMain()}, colorB{hexagonGame.getColor(1)};
		if(getBlackAndWhite()) colorB = Color::Black;
		VertexArray vertices2{PrimitiveType::Quads, 4}, vertices3{PrimitiveType::Triangles, 3};

		for(unsigned int i{0}; i < hexagonGame.getSides(); ++i)
		{
			float angle{div * i};

			Vector2f p1{getOrbitFromDegrees(startPos, angle - div * 0.5f, radius)};
			Vector2f p2{getOrbitFromDegrees(startPos, angle + div * 0.5f, radius)};
			Vector2f p3{getOrbitFromDegrees(startPos, angle + div * 0.5f, radius + thickness)};
			Vector2f p4{getOrbitFromDegrees(startPos, angle - div * 0.5f, radius + thickness)};

			vertices2.append({p1, colorMain});
			vertices2.append({p2, colorMain});
			vertices2.append({p3, colorMain});
			vertices2.append({p4, colorMain});

			vertices3.append({p1, colorB});
			vertices3.append({p2, colorB});
			vertices3.append({startPos, colorB});
		}

		if(!hexagonGame.getStatus().drawing3D) hexagonGame.render(vertices3);
		hexagonGame.render(vertices2);
	}
void HexagonGame::update(float mFrameTime)
{
    if(!hasDied)
    {
        manager.update(mFrameTime);

        updateLevelEvents(mFrameTime);

        if(timeStop <= 0)
        {
            currentTime += mFrameTime / 60.0f;
            incrementTime += mFrameTime / 60.0f;
        }
        else timeStop -= 1 * mFrameTime;

        updateIncrement();
        updateLevel(mFrameTime);
        updateRadius(mFrameTime);
        if(!getBlackAndWhite()) styleData.update(mFrameTime);
    }
    else setRotationSpeed(getRotationSpeed() / 1.001f);

    updateKeys();
    if(!getNoRotation()) updateRotation(mFrameTime);

    if(mustRestart) newGame(levelData.getId(), false);
}
Exemple #3
0
void displayImageGreyScale(struct pixel* pp, unsigned int size, unsigned int width, unsigned int height){      
    /*initialize first 16 greyscale colors.*/
  for(int i = 0; i < 16; i++){
    init_color(i, i * 62, i * 62, i * 62);
    init_pair(i, i, i);
  }
  
    /*print colors
     start from height down to zero because bmp arranges 
     data from bottom left to top right*/
  for(int i = height-1; i > 0; i--){    
    for(int q = 0; q < width; q++){                  
      
      attron(COLOR_PAIR(getBlackAndWhite(pp, (i * width) + q)));      
      mvprintw(abs(i-height),q," ");                        
    }
  }
}
Exemple #4
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);
	}
Color HexagonGame::getColorB() 						{
    return getBlackAndWhite() ? Color::Black : styleData.getCurrentB();
}
Color HexagonGame::getColorMain() 					{
    return getBlackAndWhite() ? Color::White : styleData.getCurrentMain();
}