Giving ElectroServer more memory

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.

../jre/bin/java -Xmx128M -jar lib/ElectroServer4-bootstrap.jar -mode StandAlone -config config/ES4Configuration.xml

where 128M is the amount of RAM made available.

[UPDATE]

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 parameters
INSTALL4J_ADD_VM_PARAMS="-Xmx512m"

Where 512 is the amount of RAM in Mb you want ElectroServer to use.

ElectroServer security sandbox violation error

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://games.seblee.me/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.

Earlier Teresa had told me how to do this.
Continue reading “ElectroServer security sandbox violation error”

Predicting circle line collisions

IMG_8179

IMG_8179

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?

Continue reading “Predicting circle line collisions”

Multi-user gaming in Flash – Lunar Lander tests

Lunar Lander multi-user tests

Lunar Lander multi-user tests

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 :
Continue reading “Multi-user gaming in Flash – Lunar Lander tests”

Predictive collision detection techniques

IMG_8165

IMG_8165

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.
Continue reading “Predictive collision detection techniques”

Further adventures with ElectroServer

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!

And here’s what it looks like screen captured :

And here’s the actual app!
Continue reading “Further adventures with ElectroServer”