43 lines
1.2 KiB
Text
43 lines
1.2 KiB
Text
beads 1 program simple title:'Simple windowed application' // written by CodingFiend
|
|
|
|
var g : record // global tracked mutable state
|
|
label : str
|
|
nclicks : num
|
|
|
|
========================
|
|
calc main_init // our one time initialization for the program
|
|
g.label = "There have been no clicks yet"
|
|
g.nclicks = 0
|
|
|
|
========================
|
|
// In beads you subdivide the screen by slicing it horizontally or vertically
|
|
// so as to gradually break it down into pieces, some of which are drawn
|
|
horz slice main_draw // our main drawing function
|
|
under
|
|
draw_rect(fill:DARK_SLATE_GRAY) // fill entire screen
|
|
|
|
// slice the screen into 3 horz pieces, leaving 200 pt for our body
|
|
skip 10 al
|
|
add 200 pt main_draw2
|
|
skip 10 al
|
|
|
|
vert slice main_draw2 // now take the middle horz slice, and slice it vertically
|
|
skip 10 al
|
|
add 50 pt draw_click_count
|
|
skip 2 al
|
|
add 80 px draw_button
|
|
skip 10 al
|
|
|
|
========================
|
|
draw draw_click_count
|
|
draw_str(g.label, size:0.7, color:WHITE)
|
|
|
|
========================
|
|
draw draw_button
|
|
draw_rect(fill:ORANGE, corner:20 pt, thick:2 pt, color:BROWN)
|
|
draw_str("Click me", size:40, indent:8 pt, color:BLACK)
|
|
-------------------
|
|
track EV_TAP
|
|
// update our click count
|
|
inc g.nclicks
|
|
g.label = to_str(g.nclicks)
|