Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

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.


Messages - Tank

Pages: 1 ... 93 94 [95] 96 97
1411
Network / Three general questions about networking in SFML
« on: January 20, 2009, 12:55:45 pm »
Quote
Firstly, is it possible to have both a client program and a server program running on the same computer?

Sure. You only specify a port when you setup a listening socket. When you connect to a host, your operating system chooses a port number by itself, mostly just a free one. This means serving and connecting on the same machine is absolutely no problem.

Quote
I'm new to network coding, but I think it has to be something with the ports you use. At present, both my client and server program are using two ports, one for TCP listening and sending and one for UDP listening and sending.

I guess you've an error in your design. Clients normally don't listen on any ports for connections coming from a server. Just open the two ports (TCP and UDP) at the server. Then connect via TCP to the remote host and send an UDP packet to the server. When you're using a router to connect to the internet, it will take care of routing the UDP packets straight to your computer in case the server sends something back. This is called Network Address Translation (NAT).

Quote
HAs this something to do with the fact that I'm using a selector in the client program as well (which is not necessary, however, abit easier)?

Nope, Selectors only tell you if a socket is ready for reading and/or writing, nothing else.

Quote
However, if the client just cuts its connection with the server (e.g. it crashes) the connection will not be closed properly and I've experienced that the selector's timeout-function goes crazy and behaves as if it's set on a very short time (like 0.0...01 seconds). Is it possible to have the TCP socket nature of a constant connection to tackle this problem (which is the reason why I've been using it in the first plce)?

Even if TCP is connection-oriented (that means, when a peer disconnects, it sends a last packet stating that he's going to shutdown the connection), you'll experience problems when a machine just crashes, thus not able to shutdown the connection gracefully. You surely have read something like "UserXYZ timed out." in a game. That occurs because the client wasn't responding in a specific period of time. You can implement such a mechanism by yourself, for example a simple PING/PONG.
The reason why your Selector nearly immediately returns is because he may have detected a connection shutdown -- or better: a problem. :) As soon as a connection interrupts or a socket gets invalid for any reason, the Selector will return immediately. You should call IsValid() on your Socket object to check if it's valid anymore, see http://www.sfml-dev.org/documentation/1.4/classsf_1_1SocketTCP.htm#134bc86320cc3f4c1ed9075e1c713082 .

1412
General discussions / C# and SFML for OS X (and iPhone)
« on: January 20, 2009, 12:55:13 am »
I'm not familiar with the iPhone, but doesn't it heavily use Java?

1413
General discussions / C# and SFML for OS X (and iPhone)
« on: January 19, 2009, 04:12:31 pm »
Hi and welcome to the forums.

Regarding to your question: generally yes. It's a thing called abstraction. That means you completely separate any graphics and sound functionality in separate modules, thus allowing you to replace them easily. You just have to define an interface which applies to all of these modules.

An example of that is the MVC pattern (try it on Google, should give you some pointers).

Generally it's always possible to use SFML for rendering and playing sounds/music, as long as SFML is compatible with the proper platform. These are currently Windows, Linux and OSX.

1414
General discussions / German forum
« on: January 19, 2009, 04:54:37 am »
Quote from: "quasius"
I am opposed to any further fragmentation of the SFML userbase.

Yes, a German forum means a slight separation, but of a different kind than separating users completely. The forum is meant to be a place to ask questions regarding to programming with SFML in the native language, and not to replace the official forums. Feature requests, bug reports and also project demonstrations can and still should be done here, since it guarantees the communication with the developers. I stated that in a welcome posting at the German forum.

Quote
I think most german developers should be able to speak decent english.

Many do, but by far not everybody. Many people also just have a better understanding of things when they're written/explained in their native language. Especially younger people and beginners can benefit from that.

Quote
f not, they can maybe post here in german, and the germans here can help out

I don't think that is a practicable solution. This forum is intended to be English, so that most people can understand what's written here. If it'd be mixed with German, it can be mixed with everything, thus leading to a huge confusion. ;)

Don't get me wrong here. I can fully understand your doubts about a German forum (or maybe call it a section). But I bet if there'd be a German sub-forum here, a lot of Germans would also use it. Currently there's nearly no activity at the German forum, and I'm still waiting for some progress so that it pays off. But what I disagree with is that the forum is a user separation. It's more an enhancement to help people in their native language. Since only concrete (project-wise) questions are asked in the several package boards, I think an extra forum is just okay.

But we'll see how that works out. I hope that more users will be visiting the forum and also take part in it, i.e. writing posts. If that won't happen, well, then there's obviously really not a need for it. But it's worth a try in my opinion.

1415
Network / Remove Output Messages?
« on: January 17, 2009, 01:00:43 pm »
I also think SFML shouldn't generate any error messages except in debug mode. When errors occure, the underlying application must catch them and can then display a message if wanted. Else a library should be kept silent IMHO. Redirecting std::cerr works, of course. But that means that things that *I* print out to std::cerr in my application get redirected, too.

1416
Feature requests / IRC Channel for this great project
« on: January 17, 2009, 12:56:25 pm »
If you don't mind being in a special network like Freenode, then you could give the channel #sfml at the server irc.boxbox.org (port 6667 for plain connections, 6697 for SSL-encrypted) a try.

1417
Graphics / Does SFML support texture-filled polygons? ...and collision?
« on: January 13, 2009, 09:15:52 pm »
1) No, not directly. You can archieve this by directly using OpenGL together with SFML for setting the texture.
2) No, it doesn't. I'm sure there're libraries, but since I never needed one, I can't tell you any names.

1418
General / Flexible Object Manager
« on: January 13, 2009, 03:18:22 pm »
e_barroga:
Please read the posts more carefully. :)

Using an object manager class, your code could look like as follows:
Code: [Select]

int main() {
  ObjectManager mgr;

  mgr.addObject( new MyObject ); // MyObject derived from BaseObject
  mgr.addObject( new MyOtherObject ); // MyOtherObject derived from BaseObject

  while( true ) { // Some kind of main loop.
    mgr.processObjects(); // Calls step() for every object.
  }
}


BaseObject has the virtual functions create() and step(). create() can be called in several ways: Either by the constructor or by ObjectManager::addObject(). ObjectManager::processObjects() iterates through all added objects and calls step() on each. I hope it's more clear this time.

Edit:
klusark:
You're implementing some kind of factory pattern. I would either prefer to implement functions like: createPlayer(), create...() instead of comparing type strings (we're using OOP ;) ), or directly pass a pointer to the proper object by using the new statement.
For example something like:
Code: [Select]

objectmanager.register( ObjectFactory::createPlayer(), "an_unique_id" );

1419
General / Flexible Object Manager
« on: January 12, 2009, 12:41:48 am »
No, your approach with the base class having virtual functions is just fine. My example above does exactly use your public interface.

At first you have your base class containing the virtual functions (maybe make them pure virtual, think about it).
Then you have all the derived classes from the base class which implement the functionality
And last, but not least, you must have some kind of management class, which manages all your objects, which are derived from your base class. That's what my example is meant for.

1420
General / Flexible Object Manager
« on: January 11, 2009, 12:15:28 pm »
Normally you would have a manager class to manage these objects. Let's do a simple example without such a class.

Let's assume BaseObject is the base class and ObjectA and ObjectB are derived from it.

Code: [Select]

std::vector<BaseObject*> objects;

// Create some objects.
objects.push_back( new ObjectA );
objects.push_back( new ObjectB );

// Iterate through objects.
for( std::vector<BaseObject*>::iterator iter = objects.begin(); iter != objects.end(); ++iter ) {
  iter->step();
}


You have to make sure that all objects get deleted properly when you don't need them anymore, since the vector only holds pointers, thus not destroying the objects they point to.

Everything regarding the objects (create, destroy, step through etc) should take place in a manager class to encapsulate it.

1421
Window / Invisable title bar
« on: January 10, 2009, 12:21:59 pm »
Please post a minimal example to reproduce your problem.

1422
General / Flexible Object Manager
« on: January 10, 2009, 12:20:18 pm »
Besides BaseObject you need a manager class like ObjectManager. This one holds and manages all your objects derived from BaseObject and has an interface for at least adding, removing/deleting and processing all added objects.
Like klusark said you can use std::vector as a storage. I'd suggest to use std::vector<BaseObject*>. This manages pointers to BaseObjects (and compatibles).

1423
SFML projects / PixelArt schmup (working title)
« on: January 10, 2009, 12:37:42 am »
Looks promising, keep it up! :)

1424
General discussions / German forum
« on: January 09, 2009, 04:52:07 pm »
Hi,

I've been thinking of this for a couple of weeks and finally decided to give it a try:
SFML currently has forums for French- and English-speaking people. Since there're at least some German developers out there that I know of, it's maybe a good idea to have a place where you can ask your questions in your native language. So I created a small new forum for the German folks.

I don't know if there're really enough German guys out there so that a German forum pays off. But it's worth a try, I think.

The forum is currently reachable at http://sfml.boxbox.org . If there're enough users, I'd register a more recognizable domain like sfml-forum.de or something similar.

Feedback welcome -- also at the new forum. :)

1425
General discussions / SFML 1.4
« on: January 09, 2009, 03:01:39 pm »
Congratulations on release 1.4 Laurent, keep up the good work!

Pages: 1 ... 93 94 [95] 96 97
anything