At 11/25/06 12:05 AM, Blaze wrote:
I hate to be a bother, and i hate to just come in asking for help :D But i doubt this warrants it's own thread, so please, anyone?
Ironicly, you seem to be getting more results than stating a new thread.
I do it a couple of ways, the old way i went about it in heaven's chav (or whatever crap game it was), was to have the _x on hit go out faster than it came in. You could also have a variable then slowing it down a bit after it goes beyond max speed.
Another way i code movement is using Glaiel's real hittest system.
I'll show you my code (although still glitchy).
(not sure if this will make sense, as i've written it a long while ago and I've only cut out a section)
// GG Script
onClipEvent (load) {
r = _width/2;
seg = 20;
}
onClipEvent (enterFrame) {
var nmbr = 0;
xval = 0;
yval = 0;
for (i=1; i<seg; i++) {
var tx = _x+r*Math.sin(i*(360/seg)*(Math.PI/180));
var ty = _y-r*Math.cos(i*(360/seg)*(Math.PI/180));
if (_root.land.hitTest(tx, ty, true)) {
nmbr++;
xval += tx;
yval += ty;
}
}
// My Get direction
_root.number1 = Math.round(57.2957795*Math.atan2(vspd, hspd));
_root.arr2._rotation = -_root.number1+90;
// End get direction
if (nmbr>0) {
_root.arr._x = xval/nmbr;
_root.arr._y = yval/nmbr;
_root.normal = Math.atan2(_x-xval/nmbr, _y-yval/nmbr)/(Math.PI/180)*-1+180;
_root.arr._rotation = _root.normal;
_root.arr._visible = true;
// My Get reflection
reflection = 2*_root.normal-_root.arr2._rotation+180;
_root.arr3._rotation = reflection;
// End get reflection
// Bounce
_root.angle = reflection;
_root.anglerad = (3.14/180)*_root.angle;
if (xspd<bounce) {
if (_root.normal<90 or _root.normal>270) {
xspd = bounce;
}
}
newnumberagain = Math.cos(_root.angle);
vspd = Math.cos(_root.anglerad)*xspd;
hspd = Math.sin(_root.anglerad)*xspd;
} else {
_root.arr._visible = false;
}
}
Link
Hm, it's very very glitchy. But i find it much much more effective to do movement by degrees to get nice results.