indexing description: "Brick Breaker Items" date: "$Date$" revision: "$Revision$" class BB_ITEM inherit BB_OBJECT creation make feature -- Initialization make (a_block: BB_BLOCK; an_item_type: INTEGER) is -- creates an item out of `a_block' require a_block_not_void: a_block /= Void an_item_type_in_bounds: an_item_type >= 1 and an_item_type <= Number_of_items do level := a_block.level item_type := an_item_type object_type := Object_type_item load_correct_image create center.make_from_other (a_block.center) initialize level.random.forth speed := (level.random.item \\ (Maximum_item_speed.rounded - Minimum_item_speed.rounded)) + Minimum_item_speed level.items.force_last (Current) level.collision_detector.add (Current, object_type) end feature -- Status report item_type: INTEGER -- item_type (see BB_CONSTANTS for a list) feature -- Status setting load_correct_image is -- loads the correct image for the item require level_not_void: level /= Void do image := level.item_images.item (item_type) half_height := image.height / 2 half_width := image.width / 2 create image_offset.make (-half_width, -half_height) radius := sqrt((image_offset.x)^2 + (image_offset.y)^2) end feature -- Movement move (delay: INTEGER) is -- move `Current' do move_by (0, speed / 1000 * delay) ensure -- moved: center.y = old center.y + speed / 1000 * delay end feature {NONE} -- Impelementation speed: DOUBLE -- speed in y direction, between `Minimum_item_speed' and `Maximum_item_speed' end