3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

こういうダイエットアプリがほしい

Posted at

こういうダイエットアプリがほしい

誰かiPhoneアプリにして
##動機
今までのカロリー管理系ダイエットアプリ
一日の上限カロリーと食べたものの合計カロリーの差を表示
⇒夜食の誘惑
今何を食べて良いのかわからない

##解決策
一日の可能な取得カロリーを秒単位に分割、積み上げていく
今食べられる=使用可能な取得カロリー
次に食べたいものまでどれだけ我慢すればいいかも時間表示

# include <Siv3D.hpp>

int foodToTime(String food);
String nameEatableFood(double kcal);
String nameNextFood(double kcal);

String food_name[] = { L"松屋のプレミアム牛めし", L"マクドナルドのハンバーガー", L"マクドナルドのチキンクリスプ", L"水", L"日高屋の中華そば", L"クラッシュタイプの蒟蒻畑ライト ぶどう味" };
double food_kcal[] = { 962.0, 275.0, 366.0, -0.01, 669.0, 39.0};
int kakin = 0;
double allowed_kcal = 0.1;
double kcal_per_sec = 0.0307;



void Main()
{
	const Font font(14);

	while (System::Update())
	{
		String food_name = nameEatableFood(allowed_kcal);
		kcal_per_sec = 0.0307 + 0.1*kakin*kakin;
		allowed_kcal += kcal_per_sec/60;
		font(L"今なら", food_name, L"が食べられます。").draw(0, 0);
		food_name = nameNextFood(allowed_kcal);
		int next_time = foodToTime(food_name);
		font(food_name, L"\nが食べられるのは", next_time, L"秒後です。").draw(0, 100);
		font(DecimalPlace(3), allowed_kcal , L"kcal").draw(80,200);
		Circle(400, 300, 40).draw(Palette::Orange);

		if (((Mouse::Pos().x - 400)^2 + (Mouse::Pos().y - 300)^2) < 100 && Input::MouseL.clicked){
			kakin++;
		}
		font(kakin, L"課金").drawCenter({ 400, 280 });
		font(kcal_per_sec, L"kcal/sec").drawCenter({ 400, 320 });

	}
}

int foodToTime(String food){
	for (int i = 0; i < sizeof(food_name) / sizeof(food_name[0]); i++){
		if (food_name[i] == food){
			return (food_kcal[i] - allowed_kcal) / kcal_per_sec;
		}
	}
	return 0;
}

String nameEatableFood(double kcal){

	double return_kcal = -1.0;
	String return_name;
	for (int i = 0; i < sizeof(food_name) / sizeof(food_name[0]); i++){
		if (food_kcal[i]>return_kcal && food_kcal[i] < kcal){
			return_kcal = food_kcal[i];
			return_name = food_name[i];
		}
	}
	return return_name;
}

String nameNextFood(double kcal){

	double return_kcal = 99999;
	String return_name;
	for (int i = 0; i < sizeof(food_name) / sizeof(food_name[0]); i++){
		if (food_kcal[i]<return_kcal && food_kcal[i] > kcal){
			return_kcal = food_kcal[i];
			return_name = food_name[i];
		}
	}
	return return_name;
}

3
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?