indexing description: "[ First scene of bitmap_font example. ]" date: "$Date$" revision: "$Revision$" class FIRST_SCENE inherit EM_SCENE redefine handle_key_down_event end EM_KEY_CONSTANTS EM_SHARED_BITMAP_FACTORY export {NONE} all end EM_SHARED_STANDARD_FONTS export {NONE} all end EM_SHARED_SUBSYSTEMS export {NONE} all end DOUBLE_MATH export {NONE} all end create make_scene feature -- Initialization initialize_scene is -- Create all needed objects. local font: EM_FONT do create fonts.make (1,4) font := Standard_bmp_fonts.smallest_vera_font fonts.put(font,1) font := Standard_bmp_fonts.small_vera_font fonts.put(font,2) font := Standard_bmp_fonts.medium_vera_font fonts.put(font,3) font := Standard_bmp_fonts.big_vera_font fonts.put(font,4) pos4:= 1024 end feature {NONE} -- Implementation redraw is -- Draw all do screen.clear draw_circles (screen.width//2-42, screen.height//2-24) (fonts @ 4).draw_string ("EiffelMedia Bitmapfont demo", screen, pos4, screen.height // 2 - 54) pos0:=pos0+4 pos1:=pos1+3 pos2:=pos2+2 pos3:=pos3+1 if pos4 < -3000 then pos4:=screen.width else pos4:=pos4-5 end screen.redraw end draw_circles (x: INTEGER; y: INTEGER) is -- Draws the character circles centered at `x', `y' do draw_char_wheel("ABCDEFGHIJKLMNOPQRSTUVWXYZ",x,y,640,pos0,fonts @ 4) draw_char_wheel("abcdefghijklmnopqrstuvfxyz",x,y,570,pos0,fonts @ 4) draw_char_wheel("äöüéèà!?$&§/*+-_.,;:(){}[]",x,y,500,pos0,fonts @ 4) draw_char_wheel("012356789",x,y,430,pos0,fonts @ 4) draw_char_wheel("ABCDEFGHIJKLMNOPQRSTUVWXYZ",x,y,350,pos1,fonts @ 3) draw_char_wheel("abcdefghijklmnopqrstuvfxyz",x,y,300,pos1,fonts @ 3) draw_char_wheel("äöüéèà!?$&§/*+-_.,;:(){}[]",x,y,250,pos1,fonts @ 3) draw_char_wheel("012356789",x,y,200,pos1,fonts @ 3) draw_char_wheel("ABCDEFGHIJKLMNOPQRSTUVWXYZ",x,y,150,pos2,fonts @ 2) draw_char_wheel("abcdefghijklmnopqrstuvfxyz",x,y,125,pos2,fonts @ 2) draw_char_wheel("äöüéèà!?$&§/*+-_.,;:(){}[]",x,y,100,pos2,fonts @ 2) draw_char_wheel("012356789",x,y,75,pos2,fonts @ 2) draw_char_wheel("ABCDEFGHIJKLMNOPQRSTUVWXYZ",x,y,55,pos3,fonts @ 1) draw_char_wheel("abcdefghijklmnopqrstuvfxyz",x,y,45,pos3,fonts @ 1) draw_char_wheel("äöüéèà!?$&§/*+-_.,;:(){}[]",x,y,35,pos3,fonts @ 1) draw_char_wheel("012356789",x,y,25,pos3,fonts @ 1) end draw_char_wheel (s: STRING; x: INTEGER; y: INTEGER; r: INTEGER; alpha: INTEGER; a_font: EM_FONT) is -- Draws `s' around `x', `y' with radius `r' and angel `alpha' using `a_font' local lalpha, dalpha: DOUBLE i: INTEGER tmp_x, tmp_y: INTEGER do dalpha := 2*Pi/s.count lalpha := (alpha/360)*2*Pi from i:=0 until i>=s.count loop tmp_x := (sine (i*dalpha+lalpha)*r+x).rounded tmp_y := (y-cosine (i*dalpha+lalpha)*r).rounded if (tmp_x >= 0) and (tmp_y >= 0) then a_font.draw ((s @ (i+1)), screen, tmp_x, tmp_y) end i:=i+1 end end handle_key_down_event (a_keyboard_event: EM_KEYBOARD_EVENT) is -- Handle keyboard events. do if a_keyboard_event.key = sdlk_escape then event_loop.stop end if a_keyboard_event.key = sdlk_f then video_subsystem.video_surface.toggle_fullscreen end end fonts: ARRAY[EM_FONT] -- The fonts to use to draw the wheels pos0,pos1,pos2,pos3: INTEGER -- The current angel of each wheel pos4: INTEGER -- The position of the scrolling font end