Jump to content
  • Advertisement

Asokanta

Member
  • Content Count

    14
  • Joined

  • Last visited

Community Reputation

2 Neutral

About Asokanta

  • Rank
    Member

Personal Information

Social

  • Twitter
    Asokanta
  • Github
    Asokanta
  • Twitch
    Asokanta
  • Steam
    Asokanta

Recent Profile Visitors

1048 profile views
  1. Asokanta

    My game idea

    Good luck about this I hope you will make some good ideas
  2. Thank you guys it's working now.Topic can be locked. The last code is here : void GetSettings() { ifstream nameFileout; nameFileout.open("Settings.conf"); string line; if (!nameFileout.is_open()) { exit(0); } while (std::getline(nameFileout, line)) { std::string s = line; std::string delimiter = "[Zoom]"; size_t pos = 0; std::string token; while ((pos = s.find(delimiter)) != std::string::npos) { token = s.substr(0, pos); std::cout << token << std::endl; s.erase(0, pos + delimiter.length()); stringstream convert(s); Z2 = atof(s.c_str()); } AllocConsole(); freopen("CONOUT$", "w", stdout); std::cout << s << std::endl; } nameFileout.close(); } Output : Z2 = -10; Settings.conf : [Zoom]-10 int main(int argc, char** argv) { //Initialize GLUT glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); glutInitWindowSize(400, 400); //Create the window glutCreateWindow("Window"); initRendering(); GetSettings(); AllocConsole(); freopen("CONOUT$", "w", stdout); std::cout << Z2 << std::endl; //Set handler functions glutDisplayFunc(drawScene); glutKeyboardFunc(handleKeypress); glutReshapeFunc(handleResize); glutSpecialFunc(specialKeys); glutMainLoop(); }
  3. There is no member write code for me i just wan't be more specify like example code and i will try this codes i tried google and i just found other private forums but i didin't understood and i created a topic from here. Thank you guys helping me anyway :D.
  4. I'm getting settings(variables) from this code : void GetSettings() { ifstream nameFileout; nameFileout.open("Settings.conf"); string line; if (!nameFileout.is_open()) { exit(0); } while (std::getline(nameFileout, line)) { string parse = "[Zoom]-10"; stringstream ss(parse); string temp = "[Zoom]"; getline(ss, temp, ']'); getline(ss, temp, '['); double Result; stringstream convert(temp); double Z2 = atof(temp.c_str()); AllocConsole(); freopen("CONOUT$", "w", stdout); std::cout << line << std::endl; } nameFileout.close(); } This function's output is here : double Z2 = -10; But i wan't use this Z2 like this global variables : //Global Variables double rotated_y = 0.0; double rotated_x = 0.0; double rotate_y = 0.0; double rotate_x = -65.0; double zoom = 90.0; //String Variables string Var1 = "[Zoom]"; string null = "\0"; //Camera Variables double X2 = 0.0f; double Y2 = 0.0f; // double Z2 need to be here. //Movement Variables double X1 = 0.0f; // ←→ double Y1 = 0.0f; // ↕ double Z1 = 0.0f; // double speed = 1.0f; //Colission Variables bool CanMoveToLeft = true; bool CanMoveToRight = true; bool CanMoveToUp = true; bool CanMoveToDown = true;
  5. //global variables double X2 = 0.0f; double Y2 = 0.0f; // double Z2 need to be here. i'm trying to make this but i can't remove the function and don't know how to declare without this function can u be more specify like write code ?
  6. code in the function.If i remove the function and just write double Z2 = -10 it won't getsettings from config file...
  7. I know i need put out of function and top of the code but i don't know how.
  8. Hello guys,i created a config file and got line by line then parsed to variables.How can i set local (function) variable to global variable ? sorry for bad english. Current code: void GetSettings() { ifstream nameFileout; nameFileout.open("Settings.conf"); string line; if (!nameFileout.is_open()) { exit(0); } while (std::getline(nameFileout, line)) { string parse = "[Zoom]-10"; stringstream ss(parse); string temp = "[Zoom]"; getline(ss, temp, ']'); getline(ss, temp, '['); double Result; stringstream convert(temp); double Z2 = atof(temp.c_str()); AllocConsole(); freopen("CONOUT$", "w", stdout); std::cout << line << std::endl; } nameFileout.close(); } Output : Z2 = -10
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!