OPTION C_COORDS OPTION ESCAPE OFF OPTION SHOW OFF dim sprite_main as int dim sprite_n as int dim sprite_main_name[6,20] as char dim sprite_n_name[6,20] as char dim lines[10,10] as char dim selection_name[6,20] as char dim sides[6] as int dim last_rnd as int last_rnd=1000 function myrand(roll as int) as int dim x as int x = rnd(roll-1) while x = last_rnd x = rnd(roll-1) wend last_rnd = x myrand = x end function sub init sprite_main = 1 sprite_n = 2 sprite_main_name[0]="4sided.pic" sprite_n_name[0]="4s.pic" sprite_main_name[1]="6sided.pic" sprite_n_name[1]="6s.pic" sprite_main_name[2]="8sided.pic" sprite_n_name[2]="8s.pic" sprite_main_name[3]="10sided.pic" sprite_n_name[3]="10s.pic" sprite_main_name[4]="12sided.pic" sprite_n_name[4]="12s.pic" sprite_main_name[5]="20sided.pic" sprite_n_name[5]="20s.pic" sprite sprite_main, sprite_main_name[0] sprite sprite_n, sprite_n_name[0] selection_name[0]=" 4" selection_name[1]=" 6" selection_name[2]=" 8" selection_name[3]="10" selection_name[4]="12" selection_name[5]="20" sides[0] = 4 sides[1] = 6 sides[2] = 8 sides[3] = 10 sides[4] = 12 sides[5] = 20 for i=0 to 9 lines[i]="" next end sub dim last as int last=0 sub animate(n as int) dim x as int dim rolling as int dim s[20] as char last = last+1 if last=8 then last = 0 x=last if x=0 then x=rnd(sides[n]-1) move sprite_n,50,20,x redraw sprite_n x=x+1 sprint s, sides[n], "s=",x add_line(s) else move sprite_main, 50, 20, x redraw sprite_main end if beep 20 beep -1 ' wait 2 end sub sub selection(n as int) dim x as int dim y as int x=1 y=15 ink white paper black font "mini_normal_font" printxy 1,1, "Sides" line 0,10,25,10 line 25, 0,25,99 for i=0 to 5 if n=i then font "mini_bold_font" printxy x,y,">",selection_name[i] else font "mini_normal_font" printxy x,y,selection_name[i] end if y=y+15 next end sub sub show_lines font "mini_normal_font" line 125,0,125,99 for i=0 to 9 printxy 127,i*10,lines[i] next end sub sub add_line(s[] as char) for i=1 to 9 lines[i-1]=lines[i] next lines[9]=s end sub sub clear_lines for i=0 to 9 lines[i]="" next end sub sub repaint(n as int, roll as int) cls selection(n) if roll then animate(n) show_lines redraw show end sub sub mainsub dim n as int dim k as int dim last_key as int n=0 init ink white paper black repaint(n, 1) while true inline _escape(0); if key(#KEY_SPACE) then k = dialog("EXIT", "SPACE PRESSED - QUIT?") if k then exit while endif k = rnd(100) if key(#KEY_DOWN) then while key(#KEY_DOWN) wend if n<=4 then n=n+1 sprite sprite_main, sprite_main_name[n] sprite sprite_n, sprite_n_name[n] last=0 repaint(n, 1) elseif key(#KEY_UP) then while key(#KEY_UP) wend if n>0 then n=n-1 sprite sprite_main, sprite_main_name[n] sprite sprite_n, sprite_n_name[n] last=0 repaint(n, 1) elseif key(#KEY_DEL) then while key(#KEY_DEL) wend clear_lines last=0 repaint(n, 1) elseif key(#KEY_ENTER) then repaint(n, 1) last_key=#KEY_ENTER elseif key(#KEY_SPACE) then exit while elseif last_key=#KEY_ENTER then last=7 repaint(n,1) last_key=0 endif wend end sub mainsub