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

em.goof.object

Class EM_GOOF_PHYSICABLE


Direct ancestors

EM_GOOF_ACCELERABLE, EM_GOOF_DESTRUCTABLE, EM_GOOF_COLLIDABLE

Known direct descendants

EM_GOOF_BALL, EM_GOOF_XY_VEHICLE, EM_GOOF_XZ_FIGURE

Creation

Features

Invariants

indexing

description

An EM_GOOF_OBJECT that is under the laws of physics. Therefor the EM_GOOF_FORCE are
applicable when it is added to EM_GOOF_PHYSICS.

date

$Date: 2005/10/23 09:48:58 $

revision

$Revision: 1.12 $

class

EM_GOOF_PHYSICABLE

inherit

EM_GOOF_ACCELERABLE
EM_GOOF_DESTRUCTABLE
EM_GOOF_COLLIDABLE

create

make (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

feature -- Initialization

make (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_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_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 {EM_GOOF_OBJECT, EM_GOOF_PHYSICS} -- Drawing

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

-- Draw 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)

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

friction: DOUBLE

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

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)

last_position: EM_VECTOR_2D

-- Where was it last frame(internal)?

-- (From EM_GOOF_MOVABLE)

mass: DOUBLE

-- How much mass?

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)

set_friction (a_friction: DOUBLE)

-- Set friction

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

-- Set mass

require
mass_not_zero: a_mass > a_mass.zero
ensure
mass_set: mass = a_mass
visible: BOOLEAN

-- Is this object visible?

-- (From EM_GOOF_OBJECT)

feature {EM_GOOF_OBJECT, EM_GOOF_PHYSICS} -- Processing

process (time_length: DOUBLE)

-- Process this object

-- (From EM_GOOF_OBJECT)

require
not_premade: not premade

feature -- Handler

collide (a_collision: EM_COLLISION [EM_COLLIDABLE])

-- It collides

-- (From EM_GOOF_COLLIDABLE)

require
a_collision_not_void: a_collision /= void

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 -- 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)

end