indexing description: "[ Scene where player selects difficulty of game. ]" date: "$Date$" revision: "$Revision$" class CHOOSE_SCENE inherit EM_COMPONENT_SCENE redefine handle_key_down_event, redraw end create make feature -- Properties continue: BOOLEAN -- Continue program or quit? min_size: INTEGER -- Minimum number size for calculation range: INTEGER -- Number range for calculation button_easy: EM_BUTTON -- Chooses easy difficulty button_medium: EM_BUTTON -- Chooses easy difficulty button_hard: EM_BUTTON -- Chooses easy difficulty button_quit: EM_BUTTON -- Quit program -- key bindings label_bindings: EM_LABEL label_rot_left: EM_LABEL label_move_left: EM_LABEL label_rot_right: EM_LABEL label_move_right: EM_LABEL label_more_powder: EM_LABEL label_less_powder: EM_LABEL label_fire: EM_LABEL label_start: EM_LABEL label_rot_left_key: EM_LABEL label_move_left_key: EM_LABEL label_rot_right_key: EM_LABEL label_move_right_key: EM_LABEL label_more_powder_key: EM_LABEL label_less_powder_key: EM_LABEL label_fire_key: EM_LABEL label_start_key: EM_LABEL -- end key bindings feature -- Initialization make is -- Make 'current' do make_component_scene create button_easy.make_from_text("Easy") button_easy.set_x(50) button_easy.set_y(50) button_easy.set_width(120) button_easy.set_height(50) button_easy.clicked_event.subscribe(agent easy_click) add_component(button_easy) create button_medium.make_from_text("Medium") button_medium.set_x(50) button_medium.set_y(150) button_medium.set_width(120) button_medium.set_height(50) button_medium.clicked_event.subscribe(agent medium_click) add_component(button_medium) create button_hard.make_from_text("Hard") button_hard.set_x(50) button_hard.set_y(250) button_hard.set_width(120) button_hard.set_height(50) button_hard.clicked_event.subscribe(agent hard_click) add_component(button_hard) create button_quit.make_from_text("Quit") button_quit.set_x(50) button_quit.set_y(350) button_quit.set_width(120) button_quit.set_height(50) button_quit.clicked_event.subscribe(agent quit_click) add_component(button_quit) create label_bindings.make_from_text ("Key bindings") label_bindings.set_x(300) label_bindings.set_y(36) add_component(label_bindings) create label_rot_left.make_from_text ("Rotate gun left") label_rot_left.set_x(300) label_rot_left.set_y(60) add_component(label_rot_left) create label_rot_left_key.make_from_text ("Q") label_rot_left_key.set_x(450) label_rot_left_key.set_y(60) add_component(label_rot_left_key) create label_rot_right.make_from_text ("Rotate gun right") label_rot_right.set_x(300) label_rot_right.set_y(80) add_component(label_rot_right) create label_rot_right_key.make_from_text ("E") label_rot_right_key.set_x(450) label_rot_right_key.set_y(80) add_component(label_rot_right_key) create label_move_left.make_from_text ("Move turret left") label_move_left.set_x(300) label_move_left.set_y(100) add_component(label_move_left) create label_move_left_key.make_from_text ("A") label_move_left_key.set_x(450) label_move_left_key.set_y(100) add_component(label_move_left_key) create label_move_right.make_from_text ("Move turret right") label_move_right.set_x(300) label_move_right.set_y(120) add_component(label_move_right) create label_move_right_key.make_from_text ("D") label_move_right_key.set_x(450) label_move_right_key.set_y(120) add_component(label_move_right_key) create label_more_powder.make_from_text ("Use more powder") label_more_powder.set_x(300) label_more_powder.set_y(140) add_component(label_more_powder) create label_more_powder_key.make_from_text ("W") label_more_powder_key.set_x(450) label_more_powder_key.set_y(140) add_component(label_more_powder_key) create label_less_powder.make_from_text ("Use less powder") label_less_powder.set_x(300) label_less_powder.set_y(160) add_component(label_less_powder) create label_less_powder_key.make_from_text ("S") label_less_powder_key.set_x(450) label_less_powder_key.set_y(160) add_component(label_less_powder_key) create label_fire.make_from_text ("Fire") label_fire.set_x(300) label_fire.set_y(180) add_component(label_fire) create label_fire_key.make_from_text ("X") label_fire_key.set_x(450) label_fire_key.set_y(180) add_component(label_fire_key) create label_start.make_from_text ("Start game") label_start.set_x(300) label_start.set_y(200) add_component(label_start) create label_start_key.make_from_text ("Home") label_start_key.set_x(450) label_start_key.set_y(200) add_component(label_start_key) -- label_rot_left: EM_LABEL -- label_move_left: EM_LABEL -- label_rot_right: EM_LABEL -- label_move_right: EM_LABEL -- label_more_powder: EM_LABEL -- label_less_powder: EM_LABEL -- label_fire: EM_LABEL -- label_start: EM_LABEL end feature -- redraw redraw is -- redraw scene local color: EM_COLOR do create color.make_white screen.fill(color) precursor end feature -- Event Handlers easy_click is -- Easy is chosen do min_size := 5 range := 25 continue := true event_loop.stop end medium_click is -- Easy is chosen do min_size := 5 range := 50 continue := true event_loop.stop end hard_click is -- Easy is chosen do min_size := 5 range := 100 continue := true event_loop.stop end quit_click is -- Easy is chosen do continue := false event_loop.stop end handle_key_down_event (a_keyboard_event: EM_KEYBOARD_EVENT) is -- Handle key down event. do Precursor(a_keyboard_event) if a_keyboard_event.key = a_keyboard_event.sdlk_escape then event_loop.stop end end end