Now, sending information from one user to another:
To begin, you need to understand how I distinguished each user. Basically, each user is assigned a number. The first user to log on and run the scenario is given the number '1'; the second, '2'; and so on. That number is stored in the Score field of the UserInfo object for that user as a negative number. If a new user runs the scenario, their Score field will show '0', which I change to an extremely large negative number, at which point I use 'myInfo.getRank()' to determine what number to assign this new user.
Now that you see how I assign a number to each user, you can understand the rest. This number is converted to a character (whose code is that number) and used as the first character in one of the String fields that contains a message. Since, the Strings are limited to 50 characters, using one for the recipient leaves 49 for the message.
The corresponding int field (if using String 3, referring to int 3) will hold the timestamp (in minutes) that the message was recorded. Saved in the corresponding 'int + 5' field (if int 3, referring to int 8) is the timestamp of the last message recieved from that user.
So, as you can see, every field in the UserInfo object is used for something.
Finally, I had to create a list of every user's UserInfo objects, sort them by name and find all references to the current user's assigned number to adjust the color coding. And you should be able to see how the messages are restricted to the recipient, at this point.
greenfoot.UserInfo, huh. New Greenfoot API.
@MathManiac, I got your message.
Also, how did you send the data contining the message?
The message in saved in one of the Strings fields of the author's UserInfo. I mentioned before that the message is prefixed with a character whose code is the value assigned to the recipient of that message. When the recipient runs the scenario, all the UserInfos are checked for messages going to that person. If one is found, the 'switch' will be filled with blue indicating to him that there is a message there. When the recipient clicks on the sender's name, the Strings of the sender's UserInfo object are checked for any message for the user, and displayed if found.
Using this principal, would it be possible to make an online multiplayer game with greenfoot?
Let's see some turn based multiplayer games then
I also tried to make a multiplayer game but not turn based.
I tried to use Sockets to create a connection between two systems and send the information through these sockets. But I didn't get it to work through the internet. It only was possible in local networks.
I think the problem was that I only could connect to peoples router and not to their computer.
Does anyone know a way to create a connection with sockets through the internet?
That would make real-time games possible for greenfoot. Not only round based games.
So if anyone knows a way to do so that would be great.