jump to navigation

line physics February 1, 2008

Posted by headwinds in Gaming.
trackback

Line Rider Port

A few days ago, I ported Emanuele’s AS2 line rider tutorial to AS3 in about an hour, and then went on to add keyboard control and gave him a grenade launcher — I’m not going to include the source in this post because it was fun to port :-D and don’t want you to miss out. Its amazing how fast one can knock together a Metal Slug prototype these days.

For our game [stay tuned], I needed to change a few things such as moving the terrain and not Manny so that he stays locked to the centre of the screen; giving the illusion that he’s actually moving — this prevents him from sliding off the screen.

I’ve been been experimenting with different collision detection techniques (hitTestPoint, using circles, and even colour getPixel), and found Keith Peter’s book invaluable; especially the relatively simple radius detection (compared to the vector stuff) — great introduction to trig and physics — I wish he was my highschool math teacher. I’ve learned that switching between different techniques can increase performance dramatically.

RESOURCES
Line Rider
HIVE Keyboard Manager
Line Rider Tutorial by Emanuele Feronato
Actionscript 3.0 Animation by Keith Peters

* update Aug.19/2009 — see comments — I was encouraged to dig up and post the source *

demo
source

Comments»

1. Lysle - August 19, 2009

Hi Brandon,

I was enjoying your blog and was wondering if you could elaborate on your post about creating an AS3 Linerider.

I followed some of that tutorial but found his sliding code to be incomplete and not sure where to change it, and not to mention in AS2 which is unacceptable for me… I was wondering if you could let me see your linerider code or tell me a bit more about it. Thanks,

Lysle

2. headwinds - August 19, 2009

thanks for digging that up — I also had to do some digging and rebuild the fla which I lost. Luckily, I still had the source and it was fun to go through it again this morning. I groaned a bit looking back at this abandoned experiment. It did have a lot of promise though and perhaps you can pick it up and run with it.

My goal was to get the line rider to turn around and go back the other way which I accomplished but it takes a huge performance hit and really grinds to halt eventually. He also knows how to fire bullets and react to the keyboard but that needs to be rewired.

demo

source

I should add more of these mini experiments to the HIVE SVN so I don’t lose them.

enjoy! I know I did…

3. Steven - January 22, 2010

Hi
I am making a game based on the same tutorial and when I watch your demo I notice that your hero acts the same way mine does. I want my hero to slide of the slopes, not bounce everytime I hit one. Any idea how to pull this off?
Email me if you want to help, than I can send you my swf so you can see what my problem is exactly

4. headwinds - January 23, 2010

you want to cheat physics eh? you could try to extending the length of the radians so that they feel the slope well before your hero arrives. Then, this hero can react and reduce its velocity accordingly — land smoothly — and slide away to further adventure.