This site requires JavaScript, please enable it in your browser!
Greenfoot back
kiarocks
kiarocks wrote ...

2011/6/15

Multiplayer?

kiarocks kiarocks

2011/6/15

#
Is it possible to create multiplayer games with Greenfoot? If so, how? If not, what prevents that?
DonaldDuck DonaldDuck

2011/6/15

#
Hi Kia. Long story short, you can make an online game for two person play, but the Gallery has very strict privacy rules and will disallow your scenario from actually running the connection, meaning that the scenario will crash.
nccb nccb

2011/6/15

#
Local multiplayer is quite easy, with both of you using the keyboard. There's also resources for using gamepads which would help with local multiplayer. For networked multiplayer (e.g. over the Internet), it is possible to use sockets in Java but that's not the most approachable API. It's also the case that dealing with lag over the Internet is surprisingly tricky: most real-time networked multiplayer games (e.g. FPS, driving games) have client-side prediction to compensate for laggy connections. Turn-based games are fine over the Internet, though. DonaldDuck is also right that we don't allow sockets on scenarios uploaded to the gallery. There is good reason for this: you could upload a scenario which could use our machines to DoS someone else's machine, which obviously we don't want to happen.
kiarocks kiarocks

2011/6/16

#
ok, just wondering
mjrb4 mjrb4

2011/6/16

#
I had a go at doing something like this a long time (3 years ish) ago to see if I could get something working. It never will on the gallery but doing it offline wasn't too tricky (http://greenfootgallery.org/scenarios/221 is the result, though you'll need to download it to work.) Originally I was trying to make a simpler networking class for others to use, but it didn't really turn out that well and I haven't looked at it since. If you do want an example of scenario networking not on the gallery though it might be something worth taking a look at.
jasonwchan jasonwchan

2011/7/13

#
Hello mjrb4 and everyone else... thanks for the lead for "http://greenfootgallery.org/scenarios/221", yet when I tried to load it, Greenfoot complained that the code was obsolete and needed to be upgraded. I'm afraid that the upgrade process would be too confusing for a newbie -- like me -- to handle. :( Does anyone out there have a current networked multi-player scenario that is running clean on the current Greenfoot, for me to learn from? thanks in advance... jay
mjrb4 mjrb4

2011/7/13

#
In all honesty it sounds like given your experience level it'd be better to steer clear of networking stuff at least for now - modifying the code to run on a current distribution of Greenfoot is much easier than understanding the underlying network code and how it works! As said above, even if you did get it working it wouldn't run on the gallery at all. If you *really* want to get it running easily then you could download an old version of Greenfoot and just open it there. There's no other scenarios (at least that I know of) on the gallery that do networking at the moment.
davmac davmac

2011/7/13

#
jay, did you try compiling and running the existing code? The warning just says that the API has changed and the scenario might need some changes. It's worth just seeing if it runs ok. If you get a compilation error you can post it here.
kiarocks kiarocks

2011/7/13

#
uploading new version
kiarocks kiarocks

2011/7/13

#
DONE:/
RedPhoneBooth RedPhoneBooth

2012/4/7

#
So, wait, Is online multilayer possible in greenfoot? but just not on the Greenfoot gallery? How would one go about doing such a thing? also, would it be easier in a different environment?
davmac davmac

2012/4/7

#
The statement earlier:
but the Gallery has very strict privacy rules
... isn't really accurate. It's not that the Gallery that prevents multiplayer applets from working, it's the standard Java plugin security measures. That is: Java applets are not normally able to establish network connections to any machine except the server they are hosted on. As for your questions:
How would one go about doing such a thing?
The answer to this is not short; creating multiplayer games is quite complicated. First you need to learn how to do networking, then you need to apply that to your game. There should be some Java networking tutorials around if you do a web search.
also, would it be easier in a different environment?
In general, no. Did you have any other environment(s) in mind?
RedPhoneBooth RedPhoneBooth

2012/4/7

#
MMmm, not really, I was just wondering if there was a different environment that was made specifically for teaching networking and such.
apps92 apps92

2016/10/4

#
Hi, I have run the scenario in latest version of greenfoot, it shows the compilation error, of three old methods setSimulation being obselete. I have replaced them with the new set method. However still when I run the scenario as a server, keeping ip address blank, it shows a runtime exception java.lang.RuntimeException: Error: Connection has not been initialised. at Connection.receiveInts(Connection.java:197) at Rocket.act(Rocket.java:92)
You need to login to post a reply.