Esempio n. 1
0
//文字を描画
void DrawImpl::textLine(const Vector2& pos, int color, int fontHandle, const std::string &str, int alpha, HorizontalPlace::en fh, VerticalPlace::en fv, int blendMode){
	Vector2 dPos(0, 0);
	if (fh == HorizontalPlace::en::center){
		dPos.x -= GetDrawFormatStringWidthToHandle(fontHandle, "%s", str.c_str()) / 2.0;
	}
	else if (fh == HorizontalPlace::en::right){
		dPos.x -= GetDrawFormatStringWidthToHandle(fontHandle, "%s", str.c_str());
	}
	if (fv == VerticalPlace::en::center){
		dPos.y -= GetFontSizeToHandle(fontHandle) / 2.0;
	}
	else if (fv == VerticalPlace::en::bottom){
		dPos.y -= GetFontSizeToHandle(fontHandle);
	}

	SetDrawBlendMode(blendMode, alpha);

	size_t preNum = 0;
	size_t num = 0;
	while (1){
		preNum = num;
		num = str.find('\n', num);
		DrawFormatStringToHandle(pos.x + dx + dPos.x, pos.y + dy + dPos.y, color, fontHandle, "%s", str.substr(preNum, num - preNum).c_str());
		if (num == std::string::npos){
			break;
		}
		else{
			dPos += Vector2(0, GetFontSizeToHandle(fontHandle));
			num++;
		}
	}
	textDrawLog.set(pos, color, fontHandle, alpha, blendMode);
}
Esempio n. 2
0
//テキストとその背景に
void DrawImpl::textBox(const Vector2& pos, int color, int fontHandle, const std::string &str, int alpha, HorizontalPlace::en fh, VerticalPlace::en fv, const Vector2 &boxMargeV2, int boxColor, int boxAlpha, int blendMode, int boxBlendMode){
	Vector2 dPos(0, 0);
	Vector2 fontSize = Vector2(
		GetDrawFormatStringWidthToHandle(fontHandle, "%s", str.c_str()),
		GetFontSizeToHandle(fontHandle)
		);
	if (fh == HorizontalPlace::en::center){
		dPos.x -= fontSize.x / 2.0;
	}
	else if (fh == HorizontalPlace::en::right){
		dPos.x -= fontSize.x;
	}
	if (fv == VerticalPlace::en::center){
		dPos.y -= fontSize.y / 2.0;
	}
	else if (fv == VerticalPlace::en::bottom){
		dPos.y -= fontSize.y;
	}
	Vector2 shift(-(int)fh * fontSize.x * 0.5, -(int)fv * fontSize.y * 0.5);
	Vector2 leftTop(pos.x + dx + dPos.x, pos.y + dy + dPos.y);
	Draw.box(leftTop - boxMargeV2 * 0.5, leftTop + fontSize + boxMargeV2 * 0.5, boxColor, boxAlpha);
	SetDrawBlendMode(blendMode, alpha);
	DrawFormatStringToHandle(leftTop.x, leftTop.y, color, fontHandle, "%s", str.c_str());
	textDrawLog.set(leftTop, color, fontHandle, alpha, blendMode);
}
Esempio n. 3
0
//文字を描画・位置指定
void DrawImpl::textPlace(const Vector2& pos, int color, int fontHandle, const std::string &str, int alpha, HorizontalPlace::en fh, VerticalPlace::en fv, int blendMode){
	SetDrawBlendMode(blendMode, alpha);
	Vector2 dPos(0, 0);
	if (fh == HorizontalPlace::en::center){
		dPos.x -= GetDrawFormatStringWidthToHandle(fontHandle, "%s", str.c_str()) / 2.0;
	}
	else if (fh == HorizontalPlace::en::right){
		dPos.x -= GetDrawFormatStringWidthToHandle(fontHandle, "%s", str.c_str());
	}
	if (fv == VerticalPlace::en::center){
		dPos.y -= GetFontSizeToHandle(fontHandle) / 2.0;
	}
	else if (fv == VerticalPlace::en::bottom){
		dPos.y -= GetFontSizeToHandle(fontHandle);
	}
	DrawFormatStringToHandle(pos.x + dx + dPos.x, pos.y + dy + dPos.y, color, fontHandle, "%s", str.c_str());
	textDrawLog.set(pos, color, fontHandle, alpha, blendMode);
}
Esempio n. 4
0
//文字を描画・位置指定
void DrawImpl::textPlaceSpace(const Vector2& pos, int color, int fontHandle, const std::string &str, int alpha, double space, HorizontalPlace::en fh, VerticalPlace::en fv, int blendMode){
	Vector2 dPos(0, 0);
	if (fv == VerticalPlace::en::center){
		dPos.y -= GetFontSizeToHandle(fontHandle) / 2.0;
	}
	else if (fv == VerticalPlace::en::bottom){
		dPos.y -= GetFontSizeToHandle(fontHandle);
	}

	SetDrawBlendMode(blendMode, alpha);
	if (fh == HorizontalPlace::en::left){
		for (int i = 0; i < str.size(); i++){
			centerText(Vector2(pos.x + i * space, pos.y) + dPos, color, fontHandle, str.substr(i, 1), alpha, blendMode);
		}
	}
	else if (fh == HorizontalPlace::en::center){
		if ((str.size() % 2) == 0){
			for (int i = 0; i < str.size(); i++){
				dPos.x = -(double)(str.size() / 2) * space + space / 2;
				centerText(Vector2(pos.x + i * space, pos.y) + dPos, color, fontHandle, str.substr(i, 1), alpha, blendMode);
			}
		}
		else{
			for (int i = 0; i < str.size(); i++){
				dPos.x = -(double)(str.size() / 2) * space;
				centerText(Vector2(pos.x + i * space, pos.y) + dPos, color, fontHandle, str.substr(i, 1), alpha, blendMode);
			}
		}
	}
	else if (fh == HorizontalPlace::en::right){
		for (int i = 0; i < str.size(); i++){
			dPos.x = -(double)(str.size() - 1) * space;
			centerText(Vector2(pos.x + i * space, pos.y) + dPos, color, fontHandle, str.substr(i, 1), alpha, blendMode);
		}
	}
	textDrawLog.set(pos, color, fontHandle, alpha, blendMode);
}
Esempio n. 5
0
void Engine::intCar(Car* car){
  
  double nVel = 0;
  if(car->getVelocity()>0){
    nVel = std::min(car->getVelocity()+car->getGear()
		    *car->getAcceleration()*dt/100 
		    - 0.4*dt/100,+0.5*car->getGear());
  } else {
    nVel = std::max(car->getVelocity()+car->getGear()
		    *car->getAcceleration()*dt/100 
		    + 0.4*dt/100,0. -car->getGear());
  }
  
  if(fabs(nVel) <= 0.041) { nVel = 0; } 

  car->setVelocity(nVel);

  QPointF dPos(-sin(car->getOrientation()*3.14/180)*car->getVelocity(),
	      cos(car->getOrientation()*3.14/180)*car->getVelocity());

  double nAng = 0;
  if(car->getAngVelocity()>0){
    nAng = std::min(car->getAngle()+car->getAngVelocity()*dt/30,+45.);
  } else {
    nAng = std::max(car->getAngle()+car->getAngVelocity()*dt/30,-45.);
  }
  
  car->setAngle(nAng);  
  
  car->setOrientation(fmod(car->getOrientation()
			   -tan((3.14/180)*car->getAngle())
			   *car->getVelocity()*dt/10,360));

  car->setPosition(car->getPosition()+dPos);

}