Help with multi-threaded programing.

I need to run the window function [window()] and the console input/output subroutine [screen()] I currently have the boost development library installed
P.S. this is only one file out of my program that spans about 2000 lines

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135

///////////////////////////////////
//      Console application      //
//            for                //
//        Rouge! RPG             //
//	This program is under the//
//GPL Public License you may mod //
//it as you see fit. -Noah Klabo //
///////////////////////////////////

//standard librarys 
#include <iostream>  
#include <fstream>   
#include <iomanip>  
#include <string>
#include <cstdlib>
//program headers          /*And so day two starts!*/
#include "map.h"
#include "navigation.h"
#include "render.h"
#include "save.h"
#include "DEFS.h"
#include "save.h"
#include "dialogue.h"

#include "convert.h" 
#include "window.h" 

using namespace std;

int command()

{
loadmap();//loads information from "map.h"
Convert();
do{ 

Convert();//loops to keep updated
screen();//FIXME //put navigate() inside the "screen" function needs 
//window(); FIXME needs to run at the same time as "screen()" for input 
if (input == "exit")
  {                                           
    cout << "Quiting...NOW!\n";
    return 0;                                 
  }                                           
if (input == "save")                       
     {                                        
     save(); 
     cout << "Saving...Profile.SAV\n";               
     }   
 if (input == "quit")                      
     {                                       
      cout << "Quiting...NOW!\n";            
     return 0;                                 
     }
 if (input == "display")                      
     {                                       
      window();//FIXME                                
     }
//Direction commands
if (input == "north")
  {
   playerlocation = playerlocation - map_width; //would be only twenty units for this demo but adding this will give the engine more flexability
  }
   if (input == "east")
     {
     playerlocation = playerlocation + 1;
     }
      if (input == "south")
        {
          playerlocation = playerlocation + map_width; //would be twenty ten units for this demo but adding this will give the engine more flexability
        } 
         if (input == "west")
          {
           playerlocation = playerlocation - 1;
          }
           if (input == "let")
            {
             cout << let[50];//floor is not changing to player!
            }
             if (input == "play")
               {
                system("./audio");
               }
 }while (input != "quit");
 
return 0; //program must always return a value DUH
}

int main() 
{
//intro graphic and music
    // Create the main rendering window
    sf::RenderWindow screen(sf::VideoMode(800, 600, 32), "NOT FINISHED");
//1   
    sf::Image Image;
    if (!Image.LoadFromFile("Logo.png"))
	        return 1;
	  sf::Sprite Sprite;
	  Sprite.SetImage(Image);
	  Sprite.SetPosition(0.0f, 0.0f);
	  Sprite.SetRotation(0.0f);
	  Sprite.SetScale(1.0f, 1.0f);
	 

    // Start game loop
    while (screen.IsOpened())
    {
        // Process events
        sf::Event Event;
        while (screen.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                screen.Close();
        }

        // Clear the screen (fill it with black color)
        screen.Clear();
        
        //draws sprite
         
//LINE1
        screen.Draw(Sprite); 
        // Display window contents on screen
        screen.Display();   
}

command();

 cout << "Welcome, User"; //could use "endl" but I prefer newline 
 cin.ignore();//ignore function!
cout << command();
return 0;
}
Last edited on
I can't tell what exactly you are asking, could you be a little more specific? If you just need to run a function and another function at the same time, there is an SFML Threading thing that will do that.
yes thats exactly what I'm looking for, what would this function be called?
Ok using the new C++0x library to create a multi-threaded main loop
Last edited on
Topic archived. No new replies allowed.