PDA

View Full Version : How is this done?



Pattt
October 24th, 2006, 12:33 PM
Line Rider by *fsk
http://www.deviantart.com/deviation/40255643/

How is the collisions with the ground (line) done? Vectors?

:pope:

Joppe
October 24th, 2006, 01:34 PM
Like this?
http://img339.imageshack.us/my.php?image=exampelrb2.swf

If so, just do a hittest with shapeflag
ActionScript Code:

// While or if
while(whateveryourdrawingclipisnamed.hitTest(this. _x,this._y,true)){
this._y--;
}





Something like that...

Note; This is not the best example, becouse its using my code which sucks. So with a better engine for those particles it would work in all instances :)

edit: It doesnt seem to work, however im sure its just my code with the particles that messes it up...

Thinker2501
October 24th, 2006, 07:09 PM
Using hitTest is insanely inefficient, especially with shape tag and a large number of objects.

Templarian
October 24th, 2006, 11:33 PM
That guys is based off of some sick line detection algorithm. Basically takes a normal array of lines and calculates where the dot hits... think that spider man thing but only in the downward direction.

The easiest way is to find the distance under the sled to a given line. Then use the angle that it intersects at to find the angle the sled is at... only hard part is multiple lines under the sled and verticle lines.

Actually i think im over simplifying it some.

Exos Sho
October 26th, 2006, 02:01 PM
http://tonypa.pri.ee/vectors/tut07.html
take a look at this