⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 demo.h

📁 小游戏 有碰撞检测和音乐 使用键盘openal
💻 H
字号:
#pragma once
#include <fstream>
#include <string>
#include <vector>
#include <iostream>

using namespace std;

const int FAIL = 0;
const int SUCCESS = 1;
//bool result;

// compare 2 strings
bool IsEqual ( const string s1, const string s2 )
{
	if ( s1 == s2 ) 
		return true;
	return false;
}


string StripSpace ( const string s )
{
	string temp = "";
	unsigned int pos = 0;
	while ( pos < s.length() )
	{
		if ( !isspace( s[ pos ] ) )
			temp = temp + s[ pos ];
		pos++;
	}
	return temp;
}
vector <string> Tokenize( const string s, const string separator )
{
	string temp = s;
	vector < string > elements;
	int index = 0;
	while ( index >= 0 )
	{
		index = (int) temp.find( separator );
		elements.push_back ( temp.substr ( 0, index ) );
		temp = temp.substr ( index + 1 , temp.length()- index - 1 );
	}
	return elements;
}
// APP SPECIFIC
const string app_data_file = "app.dat";
float parameter1;


bool ReadAppDataFile(const string app_data_file)
{
	vector <string> elements;
	ifstream ifile( app_data_file.c_str());
	if (!ifile.fail() )
	{
		string line;
		while(getline(ifile,line))
		{
			string s = StripSpace(line);
			elements = Tokenize( s, "=" );
			if ( IsEqual( elements[0], "PARAMETER1") )
			{
				parameter1 = (float) atof(elements[1].c_str());
				return SUCCESS;
			}
		}
	} 
	else
		return FAIL; // error - reading text file
	ifile.close();

	
}


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -