indexing description: "Brick Breaker Objects, such as Bars, Blocks, Balls and Items" date: "$Date$" revision: "$Revision$" deferred class BB_OBJECT inherit EM_RECTANGLE_COLLIDABLE rename make as make_rectangle_collidable export {NONE} make_from_other, make_from_rectangle, make_from_position_and_size, make_rectangle_collidable redefine draw end EM_SHARED_BITMAP_FACTORY BB_CONSTANTS feature -- Access level: BB_LEVEL_SCENE -- level of `Current' feature -- Status report object_type: INTEGER -- object type. 1 = block, 2 = ball, 3 = bar, 4 = item feature -- Status setting load_image (image_path: STRING) is -- load the image at `image_path' do bitmap_factory.create_bitmap_from_image (image_path) image := bitmap_factory.last_bitmap 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 -- Drawing draw (a_surface: EM_SURFACE) is -- draw `Current' require else a_surface_not_void: a_surface /= Void do image.set_x_y ((center.x+image_offset.x).rounded, (center.y+image_offset.y).rounded) image.draw (a_surface) end feature {NONE} -- Implementation image: EM_BITMAP -- image of object image_offset: EM_VECTOR_2D -- image offset invariant image_set: image /= Void level_not_void: level /= Void end