diff --git a/asteroids/ShipEntity.cc b/asteroids/ShipEntity.cc index 391038b..26f31d1 100644 --- a/asteroids/ShipEntity.cc +++ b/asteroids/ShipEntity.cc @@ -68,7 +68,7 @@ bool ShipEntity::CollisionEvent (Engine::EntityBase* entity, vector3d point, vec Engine::EventBasePtr explode_event (new Engine::EventBase()); explode_event->mEventType = EventShipExplode; explode_event->mEventUnsignedInt = mId; - explode_event->mVector3d = normal; + explode_event->mVector3d = mPhysicState->mVelocity - entity->mPhysicState->mVelocity; QueueEvent (explode_event); return true; @@ -81,7 +81,7 @@ bool ShipEntity::CollisionEvent (Engine::EntityBase* entity, vector3d point, vec Engine::EventBasePtr explode_event (new Engine::EventBase()); explode_event->mEventType = EventShipExplode; explode_event->mEventUnsignedInt = mId; - explode_event->mVector3d = normal; + explode_event->mVector3d = mPhysicState->mVelocity - entity->mPhysicState->mVelocity; QueueEvent (explode_event); return true; diff --git a/asteroids/View.cc b/asteroids/View.cc index 044d4b7..f3d6ae5 100644 --- a/asteroids/View.cc +++ b/asteroids/View.cc @@ -127,6 +127,7 @@ bool View::OnReceiveEvent (const Engine::EventBasePtr &event) { vector3d position = ship_entity->mPhysicState->mPosition; vector3d orientation = ship_entity->mPhysicState->mOrientation; vector3d velocity = ship_entity->mPhysicState->mVelocity; + vector3d rel_velocity = event->mVector3d; unsigned int i; mShipPartsEntityIds.clear(); @@ -135,8 +136,13 @@ bool View::OnReceiveEvent (const Engine::EventBasePtr &event) { Engine::EntityBase* part_sprite_particle = Engine::CreateEntity (GameEntityTypeShipPart); part_sprite_particle->mPhysicState->mPosition = position; part_sprite_particle->mPhysicState->mOrientation = orientation; - part_sprite_particle->mPhysicState->mVelocity = velocity; - part_sprite_particle->mPhysicState->mVelocity = vector3d (velocity[0] * (rand()/float(RAND_MAX)) * 1.7, 0., velocity[2] * (rand()/float(RAND_MAX)) * 1.5); + vector3d part_velocity ( + rel_velocity[0] * (rand()/float(RAND_MAX)) * 1.7, + 0., + rel_velocity[2] * (rand()/float(RAND_MAX)) * 1.5 + ); + part_sprite_particle->mPhysicState->mVelocity = part_velocity; + part_sprite_particle->mPhysicState->mAngleVelocity = (rand()/float(RAND_MAX) - 0.5 ) * 100.; mShipPartsEntityIds.push_back(part_sprite_particle->mId);