indexing description: "[ Image moving example. Put this file into the directory ${EM}/example/loveley. ]" date: "$Date: 2005/10/26 18:07:42 $" revision: "$Revision: 1.6 $" class LOVELY inherit EM_SHARED_BITMAP_FACTORY EM_SHARED_SUBSYSTEMS create make feature {NONE} -- Initialization make is -- Create the main application. do setup_video_subsystem setup_event_loop event_loop.dispatch Video_subsystem.disable end setup_video_subsystem is -- Setup the video subsystem. -- TODO: Proper error handling! do Video_subsystem.set_video_surface_width (800) Video_subsystem.set_video_surface_height (600) Video_subsystem.enable Bitmap_factory.create_bitmap_from_image ("lovely.gif") cow_image := bitmap_factory.last_bitmap bitmap_factory.create_bitmap_from_image ("matterhorn.jpg") mountain_image := bitmap_factory.last_bitmap x := 300 y := 350 end setup_event_loop is -- Setup event loop. do create event_loop.make_poll -- TODO: Subscribe to events event_loop.outside_event.subscribe (agent draw_scene) event_loop.quit_event.subscribe (agent quit) event_loop.key_down_event.subscribe (agent process_key_down_event) ensure event_loop_not_void: event_loop /= Void end feature -- Event handling process_key_down_event (an_event: EM_KEYBOARD_EVENT) is require an_event_not_void: an_event /= Void do if an_event.key = an_event.sdlk_up then y := y - 10 end end quit (an_event: EM_QUIT_EVENT) is require an_event_not_void: an_event /= Void do event_loop.stop end draw_scene is -- Draws the image on the root video surface. require video_subsystem_enabled: Video_subsystem.is_enabled mountian_image_not_void: mountain_image /= Void cow_imager_not_void: cow_image /= Void do Video_subsystem.video_surface.blit_surface (mountain_image, 0, 0) Video_subsystem.video_surface.blit_surface (cow_image, x, y) Video_subsystem.video_surface.redraw end feature -- Images cow_image: EM_BITMAP -- Image of a cow mountain_image: EM_BITMAP -- Image of a mountaint feature {NONE} -- Implementation x: INTEGER -- X position of cow y: INTEGER -- Y position of cow event_loop: EM_EVENT_LOOP -- Event loop end