Posts Tagged ‘games’

Predictive collision detection techniques

Saturday, January 9th, 2010

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.
(more…)

Installing ElectroServer on Mac OSX

Monday, December 28th, 2009

What else to do in the Christmas holidays but finally get my head around ElectroServer? :-) Of course the first (sometimes significant) hurdle in getting started with any multi-user technology is just installing the server on your machine! ElectroServer4 (ES4) is Java based so it should work on OSX, but most of the documentation is for Windows, so I spent today installing it on my MacBook and thought I would share what I learned.

ES4 runs on Java 1.6 and OSX is shipped with 1.5. You can find instructions on getting the update here, but whatever you do don’t complete the steps to make 1.6 the default Java Virtual Machine (JVM), otherwise FlexBuilder won’t work any more!

Now you need to download the Unix package (the one marked “without JVM”) on the ElectroServer downloads page, and unzip it somewhere suitable (I put it in my documents folder).

Then open up a terminal window and navigate into the folder where you unzipped it. (Handy shortcut : type “cd” followed by a space and then drag the folder from the finder onto your terminal where the full path name will be inserted).

There’s a file in here called ElectroServer that you run but you need to tell it where to find the latest JVM. According to this rather useful thread you can do this by typing :

export INSTALL4J_JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6/Home/

And then start the server normally by typing :

./ElectroServer

At which point you should see the happy message :

16:28:08,523 [main] INFO  DisplayLogger  - 
-=-=-=-=-=-=-=-
Starting ElectroServer 4.0.6
Go to http://www.electro-server.com/ for the newest version.
-=-=-=-=-=-=-=-
Computer Information
	Operating System: Mac OS X
	Operating System Architecture: x86_64
	Processors Available: 2
	Memory Available: 682Mb
-=-=-=-=-=-=-=-
Virtual Machine Information
	Virtual Machine Vendor: Apple Inc.
	Virtual Machine Version: 1.6.0_17
 
 
16:28:14,863 [pool-1-thread-1] INFO  DisplayLogger  - 
-=-=-=-=-=-=-=-
ElectroServer has started successfully

After several hours of fiddling around this was somewhat of a relief.

The next problem was that I couldn’t navigate to the admin panel which by default you can find at 127.0.0.1:8080/admin. But whenever I pointed my browser at it all I got was an empty binary file in my downloads folder. Thank goodness for Twitter where Matt Bolt saved the day with his tweet :

@sebleedelisle Make sure you’re using https, not http – I run into this constantly :-)

Thank you Matt! I have no idea how I would have figured that one out without you! So I just navigated to https://127.0.0.1:8080/admin and it worked.

I expect to be furthering my adventures in ElectroServer over the next few days so I’ll keep you informed of how I get along.

Bad Behavior has blocked 2871 access attempts in the last 7 days.