1
Graphics / Re: Strange behaviour with setTextureRect flip
« on: June 12, 2016, 05:52:30 pm »
Yeah, it's set to false.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Graphics.hpp>
#include <iostream>
int main(){
sf::RenderWindow mainWindow(sf::VideoMode(800, 600,32), "SFML window");
mainWindow.Clear(sf::Color(46,40,35));
sf::Text text;
text.SetString("TEXT FOR THE SCREEN");
text.SetPosition(200,200);
mainWindow.Draw(text);
mainWindow.Display();
while(true){
sf::Event currentEvent;
mainWindow.PollEvent(currentEvent);
if(currentEvent.Type == sf::Event::Closed){
return EXIT_FAILURE;
}
if ((currentEvent.Type == sf::Event::KeyPressed) && (currentEvent.Key.Code == sf::Key::Escape)){ // here's the problem
printf("%i\n", currentEvent.Key.Code);
return EXIT_SUCCESS;
}
}
return EXIT_SUCCESS;
}
...Excellent information...
Quote from: "hagel"For someone trying to program as object oriented as possible?Code doesn't automatically become more object oriented the more classes it uses. Inheritance to extend functionality is the Java approach, C++ additionally provides many (often better) alternatives. There is no reason why a thread cannot be a global function.
System package
- sf::Thread works now with function objects, no more inheritance
class MyClass : public sf::Thread{
private :
virtual void Run(){
for (int i = 0; i < 10; ++i)
std::cout << "I'm the thread number 2" << std::endl;
}
};
myClass.Launch();
class Server{
SocketTCP listener;
ServerReceiver recv;
vector <SocketTCP > clientlist;
void runRegularly(){
sendSometimes;
recv.Launch(); //RUN THREAD
}
}
class ServerReceiver : Thread{
SocketTCP *socketFromServer;
vector<SocketTCP > *clist;// PROBLEM. HOW DO I STORE A POINTER TO A VECTOR?
func initialize(SocketTCP s, vector c ){ // PROBLEM. HOW DO I PASS A POINTER TO A VECTOR?
scoketFromServer = s;
clist=c;
}
func Launch(){
acceptSockets(putTheSocketInThisSharedVector);
receive();
}
}
If it halts the whole loop, try looking at threading. Although, it might be a bit unnecessary. Not sure if you can implement the situation you outlined above, sorry. It might be able to be done, I have no idea.
All wait does is wait for at least one socket to be ready. Can be found on the documentation here.
This sort of problem (handling multiple TCP connections) has been discussed before in this thread
For your 2-player situation, you probably don't need a selector.
Use a view of 320x240 on a RenderWindow of 640x480.
For example:Code: [Select]sf::RenderWindow window(sf::VideoMode(640, 480), ...);
window.GetDefaultView().SetFromRect(sf::FloatRect(0, 0, 320, 240));