So after last time, I thought I’d given ElectroServer more memory, but it turns out I hadn’t. I’m not exactly sure why, but I suspect it’s something about how Media Temple is set up.
So rather than call the main ElectroServer app (which is just a shell script), I’m opening the ElectroServer jar file, and that way I can tell java how much memory to use (and other options) as parameters.
I’m pretty sure Java is installed somewhere on Media Temple (you need to install the dev tools) but I couldn’t find it anywhere! And if I just typed java it couldn’t find it. I even ran a find command, but it was nowhere! But then I realised that the Java runtime is packaged with ElectroServer in the jre folder!
So with a bit of fiddling I worked out that I could start ElectroServer with more memory by running the jar file, but I had to do it while in the server subfolder within the ES install.
There is a better way! Thanks to Paul Hayes (a colleague at Plug-in Media, see comments below) I have now realised that ElectroServer’s main app is nothing more than a shell script that you can edit. Furthermore there is a line you can uncomment right at the top to change the Java parameters :
# Uncomment the following line to add additional VM parameters# INSTALL4J_ADD_VM_PARAMS=
Change this to :
# Uncomment the following line to add additional VM parametersINSTALL4J_ADD_VM_PARAMS="-Xmx512m"
Where 512 is the amount of RAM in Mb you want ElectroServer to use.
I suddenly started getting a really weird error from Flash when trying to connect to ElectroServer :
Error #2044: Unhandled securityError:. text=Error #2048: Security sandbox violation: http://sebleedelisle.com/games/moonlander/MoonLanderViewer.swf cannot load data from 72.47.193.154:9899.
I posted to the ElectroServer forums and quick as a flash, Teresa got back to me – apparently ElectroServer was running out of memory. But apparently that’s not surprising – all Java gives it is 64Mb by default! But before I could fix it I had to stop ElectroServer from running, which isn’t easy when it’s running in the background.
In my previous collision detection post (in what I expect will become a series), I talked about predicting whether two objects would collide in between frames. This is to avoid the situation where the objects are moving so fast that they pass through each other before you’ve had a chance to see if they’re overlapping. This is often known as a sweep test (amongst other things!)
And I showed how you could predict collisions between a 2D circle and a vertical line but what about lines that aren’t vertical? How do you work out collisions between circles and lines of any angle?
Anyone playing my Lunar Lander game won’t know it, but we’re spying on them! The game gets around 20,000 hits a month, which is very roughly one a minute or so, so I thought it’d be the perfect vehicle to test out some real-time gaming techniques.
I’ve replaced the original game with one that transmits your position to ElectroServer, although you won’t notice any difference at all. The only way to see the all the current players is via the swf below : Read the rest of this entry »
In preparation for my upcoming Flash game programming training courses, I’m getting my head back into game physics, and I so I thought I’d share some useful collision detection methods I’ve discovered over the last few years.
Reactive collision detection
Collision detection in Flash games often occurs after things have moved. So you have a circle (usually a 2D representation of a ball) and you’re moving it towards a vertical line on the side of the screen (representing a wall). Every frame, you update its position and check whether it’s overlapping the wall.
Which is great, but of course if the ball is moving fast it may go from one side of the wall all the way to the other side between frames and no collision is detected. One way to get around this is to split up the movement of the ball into small segments and run this check several times between frames. This seems pretty inelegant to me so I have always strived to use predictive collision detection methods where my maths knowledge has allowed me! (This is also known as sweep testing, frame independent or continuous collision detection (CCD)).
Predicting when things will collide before you move them
So rather than just check whether the ball is intersecting with the wall between renders, we actually check the velocity of the ball to see at what point in time it would hit the wall if it continued in the direction it’s going. Read the rest of this entry »
As there has been a lot of interesting talk on my recent live chat example I thought it’d be nice to actually see what you’ve been saying! So I checked out the Logging Chat By Room tutorial on the ElectroServer wiki.
After some minor tweaks I got the Java extension compiled (the methods should not be marked @Override as the class isn’t extending anything) and tested them locally – all was fine.
So I uploaded them to the server and restarted but ElectroServer wouldn’t come back! There was a Java error message and it was just way beyond my capabilities to troubleshoot it. Thankfully, Teresa from ElectroServer checked the forum at 7.30am on a Sunday morning and responded to my plea for help! She assures me that she’s not usually so ultra-responsive but I have yet to see evidence of that! So far, the support I’ve got from Teresa is just phenomenal.
I never did quite get to the bottom of what happened, but I suspect it was a problem with a persistent room as I had been playing with those settings in the web admin interface (frankly without really knowing what I’m doing ) . But I fixed it by reinstalling ElectroServer with these instructions, and I was back where I started! I’m still working on getting chat logging done, but in the meantime I wanted to try something a little more interesting to me. There’s a tutorial on the ElectroServer wiki which extends the chat example and shows everyone’s mouse as they move it around!
Further news to report on my ElectroServer adventures! I’ve now got an ES4 installation up and running on a MediaTemple Dedicated Virtual server. It was actually pretty easy too, thanks to this tutorial from Greg Sidbury.
I had no problems following although there are a couple of bits that confused me. The first was that the download link didn’t work so I just found the Linux RPM link on the ElectroServer download pages and used that, which for the current version is :
The other thing that got me is that I put in the domain name into the ES4Configuration.xml which didn’t work. I should have put the ip address for the virtual server (which you should find in your Media Temple account or you could always just ping your domain from a terminal window).
Once I’d opened the ports and started the server running I tried to telnet in to port 9898 (the default chat port) but it was refused. So I edited the crossdomain.xml on the main webserver to include the IP address of my home internet connection and it seemed to be OK after that. (At least I think that’s what fixed it!).
So apart from a few minor hassles it was pretty seamless and only took me an hour or so. I must admit to feeling way out of my depth, this isn’t something I’m particularly expert on so please feel free to comment with further advice