Help with Simple Graphics Demo

new topic     » topic index » view thread      » older message » newer message

Here's something just for fun. I was wondering if somebody could 
complete the missing puzzle piece for me...

I'd like the results charted in real time, so that as each roll is made, 
one of the bar graphs for the respective value would pop up by one 
value. Thanks!!!

-- start of code
--  code generated by Win32Lib IDE v0.18.6m
 
include Win32lib.ew
without warning

--------------------------------------------------------------------------------
--  Window Window1
constant Window1 = createEx( Window, "Thrown Dice Chart", 0, Default, 
Default, 276, 300, 0, 0 )
constant txt_Sides = createEx( EditText, "6", Window1, 48, 8, 48, 20, 0, 0 )
constant LText3 = createEx( LText, "Sides", Window1, 12, 12, 36, 20, 0, 0 )
constant LText4 = createEx( LText, "QTY", Window1, 12, 36, 36, 20, 0, 0 )
constant txt_QTY = createEx( EditText, "3", Window1, 48, 32, 48, 20, 0, 0 )
constant LText6 = createEx( LText, "Rolls", Window1, 12, 60, 36, 20, 0, 0 )
constant txt_Rolls = createEx( EditText, "1000", Window1, 48, 56, 48, 
20, 0, 0 )
constant bttn_Roll = createEx( PushButton, "Roll", Window1, 104, 8, 156, 
68, 0, 0 )
constant Bitmap9 = createEx( Pixmap, "Bitmap9", Window1, 8, 84, 252, 
184, 0, 0 )
---------------------------------------------------------
--------------------------------------------------------------------------------

procedure update_roll_button()   
    setText( bttn_Roll, getText( txt_QTY ) & "d" & getText( txt_Sides ) 
& " x " & getText( txt_Rolls ) )
end procedure

update_roll_button()

--------------------------------------------------------------------------------
procedure txt_Sides_onChange (integer self, integer event, sequence 
params)--params is ()
    update_roll_button()
end procedure
setHandler( txt_Sides, w32HChange, routine_id("txt_Sides_onChange"))
--------------------------------------------------------------------------------
procedure bttn_Roll_onClick (integer self, integer event, sequence 
params)--params is ()
integer dice_num, dice_sides, dice_rolls, roll
sequence dice_results

    dice_num = getNumber( txt_QTY )
    dice_sides = getNumber( txt_Sides )
    dice_rolls = getNumber( txt_Rolls )
    dice_results = repeat(0,dice_sides)

    for t=1 to dice_rolls do
        roll = rand( dice_sides )
        dice_results[roll] += 1

--YOUR HELP NEEDED HERE!!!
-- chart results in a bar graph in the available pixmap

    end for

end procedure
setHandler( bttn_Roll, w32HClick, routine_id("bttn_Roll_onClick"))
--------------------------------------------------------------------------------
procedure txt_QTY_onChange (integer self, integer event, sequence 
params)--params is ()
    update_roll_button()
end procedure
setHandler( txt_QTY, w32HChange, routine_id("txt_QTY_onChange"))
--------------------------------------------------------------------------------
procedure txt_Rolls_onChange (integer self, integer event, sequence 
params)--params is ()
    update_roll_button()
end procedure
setHandler( txt_Rolls, w32HChange, routine_id("txt_Rolls_onChange"))


WinMain( Window1,Normal )
---end of code

As an example (use non-proportional font to view)...

   |
 ||||
||||||
123456

A nice bell curve should be expected on 3d6x1000.

new topic     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu