indexing description: "[ Results. ]" date: "$Date$" revision: "$Revision$" class RESULT_OBJECT inherit EM_GOOF_PHYSICABLE redefine draw, make, collide, process end create make_result feature -- Initialization make(img: EM_BITMAP x: DOUBLE y: DOUBLE phs: EM_GOOF_PHYSICS) is -- Make physicable do Precursor(img,x,y,phs) set_friction(1) set_mass(10) end make_result(img: EM_BITMAP x: DOUBLE y: DOUBLE phs: EM_GOOF_PHYSICS a_result_number: INTEGER a_is_correct: BOOLEAN an_add_points: PROCEDURE[ANY, TUPLE[INTEGER]]) is -- Create result_object do make(img, x, y,phs) result_number := a_result_number is_correct := a_is_correct add_points := an_add_points create font.make_from_ttf_file("../../../resource/font/ttf/bitstream/vera.ttf", 16) make_rect (x, y, 32, 32, 1) end feature {EM_GOOF_OBJECT, EM_GOOF_PHYSICS} -- Processing process(time_length: DOUBLE) is -- Process this object do Precursor(time_length) if position.y > 768 then if is_correct then add_points.call([-5]) end update_collidable(physics.collision_detector, false) destroy end end feature -- Properties add_points: PROCEDURE[ANY, TUPLE[INTEGER]] font: EM_TTF_FONT -- Font for drawing is_correct: BOOLEAN -- Is this result correct? result_number: INTEGER -- Result number feature {EM_GOOF_OBJECT, EM_GOOF_PHYSICS} -- Drawing draw(screen: EM_VIDEO_SURFACE at: EM_VECTOR_2D at_angle: DOUBLE) is -- Draw object local pos_copy: EM_VECTOR_2D do Precursor(screen, at, at_angle) pos_copy := position.rotation(position.zero, at_angle) font.draw_string (result_number.out, screen, (pos_copy.x+at.x+image_position.x-font.string_width(result_number.out)/2+image.width/2).rounded, (pos_copy.y+at.y+image_position.y-font.string_height(result_number.out)/2+image.height/2).rounded) end feature -- Handler collide(a_collision: EM_COLLISION [EM_COLLIDABLE]) is -- It collides local shell: SHELL do shell ?= a_collision.collidables.first.holder if shell /= void then destroy else shell ?= a_collision.collidables.second.holder if shell /= void then if is_correct then add_points.call([10]) else add_points.call([-1]) end update_collidable(physics.collision_detector, false) destroy end end end end