indexing description: "[ A vehicle EM_GOOF_PHYSICABLE for use on a 2d map lika for example a ship or car ]" date: "$Date$" revision: "$Revision$" class EM_GOOF_XY_VEHICLE inherit EM_GOOF_PHYSICABLE rename make as make_physic export {ANY} premade undefine draw redefine process end EM_GOOF_ROTATABLE undefine process, make, make_multiple_picture select make end create make, make_multiple_picture, premake feature -- Initialization make(img: EM_BITMAP x: DOUBLE y: DOUBLE phs: EM_GOOF_PHYSICS) is -- Make vehicle do Precursor{EM_GOOF_PHYSICABLE}(img,x,y,phs) Precursor{EM_GOOF_ROTATABLE}(img,x,y,phs) end make_multiple_picture(imgs: DS_LINKED_LIST[EM_BITMAP] x: DOUBLE y: DOUBLE phs: EM_GOOF_PHYSICS) is -- Make with multiple picture for rotation do make_physic(imgs.item(1), x, y, phs) Precursor{EM_GOOF_ROTATABLE}(imgs,x,y,phs) end feature -- Properties rudder: DOUBLE -- Rudder (acceleration rotation) set_rudder(angle: DOUBLE) is -- Set rudder angle do rudder := angle ensure rudder_set: rudder = angle end propulsion: DOUBLE -- How much propuslion does the vessel has? set_propulsion(a_propulsion: DOUBLE) is -- Set propulsion do propulsion := a_propulsion ensure propulsion_set: propulsion = a_propulsion end rect_friction: DOUBLE -- How much additional friction is there when the vehicle moves rectangluar to its 'arc' (=bearing) set_rect_friction(a_rect_friction: DOUBLE) is -- Set rect_friction do rect_friction := rect_friction ensure rect_friction_set: rect_friction = rect_friction end rect_frction_rudder_const: DOUBLE is 1000.0 -- How much is the rudder affected by rect_friction feature -- Processing process(time_length: DOUBLE) is -- Process this object local addup_propulsion: EM_VECTOR_2D addup_rect_friction: EM_VECTOR_2D do arc := arc + movement.length ^ (0.5) * rudder * time_length create addup_propulsion.make(0,0) addup_propulsion.set_x(addup_propulsion.cosine(arc)) addup_propulsion.set_y(addup_propulsion.sine(arc)) addup_propulsion.normalize addup_propulsion.stretch(propulsion, propulsion) force.add(addup_propulsion) addup_rect_friction := movement.twin addup_rect_friction.stretch(rect_friction,rect_friction) addup_rect_friction.rotate(-arc) arc := arc + addup_rect_friction.y/rect_frction_rudder_const * time_length addup_rect_friction.set_x(0) addup_rect_friction.rotate(arc) force.add(-addup_rect_friction) Precursor{EM_GOOF_PHYSICABLE}(time_length) update_angle(arc) end end