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

em.goof.collision

Class EM_GOOF_COLLIDABLE


Direct ancestors

EM_GOOF_OBJECT

Known direct descendants

EM_GOOF_OBSTACLE, EM_GOOF_PHYSICABLE

Creation

Features

Invariants

indexing

description

All data needed to check collisions with this object
Be sure not to confuse this with EM_COLLIDABLE from the
collision detection, althougt this class uses the
collision detection and EM_COLLIDABLE.

This class is intendet to be inherited by EM_GOOF_OBJECT
witch need the collision detection functionality.

Objects collide only with objects in other collision_group
(or set).

date

$Date: 2005/10/23 12:02:23 $

revision

$Revision: 1.11 $

class

EM_GOOF_COLLIDABLE

inherit

EM_GOOF_OBJECT

create

make_rect (x, y, width, height: DOUBLE a_group: INTEGER)

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

ensure
group_set: collision_group = a_group
collidable_holder_set: collidable.holder = current
make_circle (x, y, radius: DOUBLE a_group: INTEGER)

-- Make with a cicle collidable

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

feature -- Initialization

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

-- Make goof_object

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

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)

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_LOADER_NODE_PROCESSOR, EM_GOOF_PHYSICS, EM_GOOF_LEVEL_SCENE} -- Handler

collide (a_collision: EM_COLLISION [EM_COLLIDABLE])

-- It collides

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

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

-- Is it collidable within detector

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

-- Update collidable group

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

-- Update collidable position

require
a_position_not_void: a_position /= void

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 {EM_GOOF_OBJECT, EM_GOOF_LOADER_NODE_PROCESSOR, EM_GOOF_PHYSICS, EM_GOOF_LEVEL_SCENE} -- Properties

collidable: EM_COLLIDABLE

-- Collidable for detector

collision_group: INTEGER

-- Group for collision (uncolliable within group)

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)

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)

visible: BOOLEAN

-- Is this object visible?

-- (From EM_GOOF_OBJECT)

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