I just joined up to this forum, its looks pretty comprehensive, I'm impressed.
I hoping someone here is going to be able to help me,
I'm making a game where you drive a boat around a harbour and have to park the boat in the right area. If you hit anything like other boats or dock/land its game over.
The problem I'm having is the hitTest im using isn't very accurate at all but I can't work out why.
this is code im using to control the boat and its hitTest, it sits on the on the mc_mainboat
- Code: Select all
onClipEvent(load)
{
speed =0 ;
}
//control the current strenght
onClipEvent(enterFrame){
_root.imainboat.onEnterFrame=function(){
this._x-=(this._x-_root.icurrent._x)*.0001;
this._y-=(this._y-_root.icurrent._y)*.0001;
}
}
onClipEvent (enterFrame) {
// make the boat go forward
if (Key.isDown(Key.UP)) {
speed += 0.2;
}
// make the boat go backwards
if (Key.isDown(Key.DOWN)) {
speed -= 0.2;
}
// tells the boat to slow down after the speed of 20
if (Math.abs(speed)>10) {
speed *= .3;
}
// you can change the rotation of the boat to your desire
if (Key.isDown(Key.LEFT)) {
_rotation -= speed*0.6;
}
if (Key.isDown(Key.RIGHT)) {
_rotation += speed*0.6;
}
// here is where the hittest is for the boundary
speed *= 0.98;
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
if (!_root.iland1.hitTest(this)) {
if (!_root.iland4.hitTest(this)){
_x += x;
_y += y;
} else {
speed *= -0;
this.gotoAndStop(5);
}
}
}
Thanks in advance for your help.
Johnny




