Eiffel Media API
Overview Cluster Class Classes Index      Previous Next      Top Features

em.goof.object.xy

Class EM_GOOF_XY_VEHICLE


Direct ancestors

EM_GOOF_PHYSICABLE, EM_GOOF_ROTATABLE

Known direct descendants

EM_GOOF_XY_TRANSPORT

Creation

Features

Invariants

indexing

description

A vehicle EM_GOOF_PHYSICABLE for use on a 2d map lika for example a ship or car

date

$Date: 2005/10/23 09:50:12 $

revision

$Revision: 1.11 $

class

EM_GOOF_XY_VEHICLE

inherit

EM_GOOF_PHYSICABLE
EM_GOOF_ROTATABLE
EM_GOOF_OBJECT
DOUBLE_MATH
MATH_CONST

create

make (img: EM_DRAWABLE x: DOUBLE y: DOUBLE phs: EM_GOOF_PHYSICS)

-- Make vehicle

-- (From EM_GOOF_OBJECT)

require
image_not_void: img /= void
phs_not_void: phs /= void
make_multiple_picture (imgs: DS_LINKED_LIST[EM_DRAWABLE] x: DOUBLE y: DOUBLE phs: EM_GOOF_PHYSICS)

-- Make with multiple picture for rotation

-- (From EM_GOOF_ROTATABLE)

require
has_images: imgs /= void and then imgs.count > 0
phs_not_void: phs /= void
premake

-- Premake 'rotatable'
-- Must be followed by a real 'make' (or 'make_multiple_picture' in case of rotatable)

-- (From EM_GOOF_OBJECT)

feature -- Initialization

make (img: EM_DRAWABLE x: DOUBLE y: DOUBLE phs: EM_GOOF_PHYSICS)

-- Make vehicle

-- (From EM_GOOF_OBJECT)

require
image_not_void: img /= void
phs_not_void: phs /= void
make_circle (x, y, radius: DOUBLE a_group: INTEGER)

-- Make with a cicle collidable

-- (From EM_GOOF_COLLIDABLE)

ensure
group_set: collision_group = a_group
collidable_holder_set: collidable.holder = current
make_multiple_picture (imgs: DS_LINKED_LIST[EM_DRAWABLE] x: DOUBLE y: DOUBLE phs: EM_GOOF_PHYSICS)

-- Make with multiple picture for rotation

-- (From EM_GOOF_ROTATABLE)

require
has_images: imgs /= void and then imgs.count > 0
phs_not_void: phs /= void
make_physic (img: EM_DRAWABLE x: DOUBLE y: DOUBLE phs: EM_GOOF_PHYSICS)

-- Make physicable

-- (From EM_GOOF_OBJECT)

require
image_not_void: img /= void
phs_not_void: phs /= void
make_rect (x, y, width, height: DOUBLE a_group: INTEGER)

-- Make with a rect collidable
-- With x/y position (NOT top/left)

-- (From EM_GOOF_COLLIDABLE)

ensure
group_set: collision_group = a_group
collidable_holder_set: collidable.holder = current
premake

-- Premake 'rotatable'
-- Must be followed by a real 'make' (or 'make_multiple_picture' in case of rotatable)

-- (From EM_GOOF_OBJECT)

feature -- Access

arc_cosine (v: DOUBLE): DOUBLE

-- Trigonometric arccosine of radian v
-- in the range [0, pi]

-- (From DOUBLE_MATH)

arc_sine (v: DOUBLE): DOUBLE

-- Trigonometric arcsine of radian v
-- in the range [-pi/2, +pi/2]

-- (From DOUBLE_MATH)

arc_tangent (v: DOUBLE): DOUBLE

-- Trigonometric arctangent of radian v
-- in the range [-pi/2, +pi/2]

-- (From DOUBLE_MATH)

ceiling (v: DOUBLE): DOUBLE

-- Least integral greater than or equal to v

-- (From DOUBLE_MATH)

cosine (v: DOUBLE): DOUBLE

-- Trigonometric cosine of radian v approximated
-- in the range [-pi/4, +pi/4]

-- (From DOUBLE_MATH)

dabs (v: DOUBLE): DOUBLE

-- Absolute of v

-- (From DOUBLE_MATH)

exp (x: DOUBLE): DOUBLE

-- Exponential of v.

-- (From DOUBLE_MATH)

floor (v: DOUBLE): DOUBLE

-- Greatest integral less than or equal to v

-- (From DOUBLE_MATH)

log (v: DOUBLE): DOUBLE

-- Natural logarithm of v

-- (From DOUBLE_MATH)

log10 (v: DOUBLE): DOUBLE

-- Base 10 logarithm of v

-- (From DOUBLE_MATH)

log_2 (v: DOUBLE): DOUBLE

-- Base 2 logarithm of v

-- (From DOUBLE_MATH)

sine (v: DOUBLE): DOUBLE

-- Trigonometric sine of radian v approximated
-- in range [-pi/4, +pi/4]

-- (From DOUBLE_MATH)

sqrt (v: DOUBLE): DOUBLE

-- Square root of v

-- (From DOUBLE_MATH)

tangent (v: DOUBLE): DOUBLE

-- Trigonometric tangent of radian v approximated
-- in range [-pi/4, +pi/4]

-- (From DOUBLE_MATH)

feature {EM_GOOF_OBJECT, EM_GOOF_PHYSICS} -- Drawing

draw (screen: EM_VIDEO_SURFACE at: EM_VECTOR_2D at_angle: DOUBLE)

-- draw the object

-- (From EM_GOOF_OBJECT)

require
not_premade: not premade
is_screen: screen /= void

feature {EM_GOOF_OBJECT, EM_GOOF_PHYSICS, EM_GOOF_FORCE} -- Properties

acceleration: EM_VECTOR_2D

-- current acceleration

-- (From EM_GOOF_ACCELERABLE)

arc: DOUBLE

-- Current arc

-- (From EM_GOOF_ROTATABLE)

collidable: EM_COLLIDABLE

-- Collidable for detector

-- (From EM_GOOF_COLLIDABLE)

collision_group: INTEGER

-- Group for collision (uncolliable within group)

-- (From EM_GOOF_COLLIDABLE)

force: EM_VECTOR_2D

-- Force applied to the physicable

-- (From EM_GOOF_PHYSICABLE)

friction: DOUBLE

-- How much friction does apply? (speed limitation)

-- (From EM_GOOF_PHYSICABLE)

has_multiple_pictures: BOOLEAN

-- Are there multiple pictures for rotation

-- (From EM_GOOF_ROTATABLE)

image: EM_DRAWABLE

-- Image of this object

-- (From EM_GOOF_OBJECT)

image_position: EM_VECTOR_2D

-- Image positiion correcture (typically= -height/2, -width/2)

-- (From EM_GOOF_OBJECT)

images: DS_LINKED_LIST[EM_DRAWABLE]

-- Multiple images for rotation

-- (From EM_GOOF_ROTATABLE)

last_position: EM_VECTOR_2D

-- Where was it last frame(internal)?

-- (From EM_GOOF_MOVABLE)

mass: DOUBLE

-- How much mass?

-- (From EM_GOOF_PHYSICABLE)

movement: EM_VECTOR_2D

-- Current movement

-- (From EM_GOOF_MOVABLE)

physics: EM_GOOF_PHYSICS

-- Physics 'parent'

-- (From EM_GOOF_OBJECT)

position: EM_VECTOR_2D

-- Current position

-- (From EM_GOOF_OBJECT)

premade: BOOLEAN

-- Is this 'object' premade and not yet really made

-- (From EM_GOOF_OBJECT)

propulsion: DOUBLE

-- How much propuslion does the vessel has?

rect_frction_rudder_const: DOUBLE

-- How much is the rudder affected by rect_friction

rect_friction: DOUBLE

-- How much additional friction is there when the vehicle moves rectangluar to its 'arc' (=bearing)

rudder: DOUBLE

-- Rudder (acceleration rotation)

set_arc (a_arc: DOUBLE)

-- Set arc

-- (From EM_GOOF_ROTATABLE)

ensure
arc_set: arc = a_arc
set_friction (a_friction: DOUBLE)

-- Set friction

-- (From EM_GOOF_PHYSICABLE)

ensure
friction_set: friction = a_friction
set_mass (a_mass: DOUBLE)

-- Set mass

-- (From EM_GOOF_PHYSICABLE)

require
mass_not_zero: a_mass > a_mass.zero
ensure
mass_set: mass = a_mass
set_propulsion (a_propulsion: DOUBLE)

-- Set propulsion

ensure
propulsion_set: propulsion = a_propulsion
set_rect_friction (a_rect_friction: DOUBLE)

-- Set rect_friction

ensure
rect_friction_set: rect_friction = rect_friction
set_rudder (angle: DOUBLE)

-- Set rudder angle

ensure
rudder_set: rudder = angle
visible: BOOLEAN

-- Is this object visible?

-- (From EM_GOOF_OBJECT)

feature -- Processing

process (time_length: DOUBLE)

-- Process this object

-- (From EM_GOOF_OBJECT)

require
not_premade: not premade

feature {EM_GOOF_OBJECT, EM_GOOF_LOADER_NODE_PROCESSOR, EM_GOOF_PHYSICS, EM_GOOF_LEVEL_SCENE} -- Update

update_angle (a_angle: DOUBLE)

-- Update collidable angle

-- (From EM_GOOF_COLLIDABLE)

update_collidable (detector: EM_COLLISION_DETECTOR [EM_COLLIDABLE] is_collidable: BOOLEAN)

-- Is it collidable within detector

-- (From EM_GOOF_COLLIDABLE)

require
detector_not_void: detector /= void
update_group (detector: EM_COLLISION_DETECTOR [EM_COLLIDABLE] a_group: INTEGER)

-- Update collidable group

-- (From EM_GOOF_COLLIDABLE)

ensure
group_set: collision_group = a_group
detector /= void implies detector.has(collidable)
update_position (a_position: EM_VECTOR_2D)

-- Update collidable position

-- (From EM_GOOF_COLLIDABLE)

require
a_position_not_void: a_position /= void

feature -- Handler

collide (a_collision: EM_COLLISION [EM_COLLIDABLE])

-- It collides

-- (From EM_GOOF_COLLIDABLE)

require
a_collision_not_void: a_collision /= void

feature -- Destruction

destroy

-- Destory 'object'

-- (From EM_GOOF_DESTRUCTABLE)

invariant




has_image: premade or image /= void
has_position: premade or position /= void

-- From ANY
reflexive_equality: standard_is_equal (Current)
reflexive_conformance: conforms_to (Current)


has_images: has_multiple_pictures implies (images /= void and then images.count > 0)

end