diff options
author | Steve Bennett <steveb@workware.net.au> | 2020-12-30 13:54:59 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2021-01-01 16:54:26 +1000 |
commit | 8e818b3a5ee8647b746bf7ce7d601ca42b6a0ec4 (patch) | |
tree | 22c44e4d9e1f7fcb5f92c45ddb5924d3372ea4f5 /examples/sdltest.tcl | |
parent | 3b834e42ee5887f85d10d7e50814b29d1b81a09f (diff) | |
download | jimtcl-8e818b3a5ee8647b746bf7ce7d601ca42b6a0ec4.zip jimtcl-8e818b3a5ee8647b746bf7ce7d601ca42b6a0ec4.tar.gz jimtcl-8e818b3a5ee8647b746bf7ce7d601ca42b6a0ec4.tar.bz2 |
sdl: convert to using jim-subcmd
And add:
- poll ?script?
- optional window title
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'examples/sdltest.tcl')
-rw-r--r-- | examples/sdltest.tcl | 58 |
1 files changed, 38 insertions, 20 deletions
diff --git a/examples/sdltest.tcl b/examples/sdltest.tcl index 6607574..cf42d88 100644 --- a/examples/sdltest.tcl +++ b/examples/sdltest.tcl @@ -1,28 +1,46 @@ package require sdl -set xres 1024 -set yres 768 +# Basic test of all sdl commands + +set xres 640 +set yres 384 set s [sdl.screen $xres $yres] -proc drawlist {s list} { - foreach item $list { - $s {*}$item - } -} +set cyan {0 255 255 200} +set yellow {255 255 0 200} +set red {255 0 0 200} +set green {0 255 0 200} +set grey {50 50 50 200} +set white {255 255 255} +set blue {0 0 255 200} + +$s clear {*}$grey -proc rand_circle {xres yres maxradius alpha} { - list fcircle [rand $xres] [rand $yres] [rand $maxradius] [rand 256] [rand 256] [rand 256] $alpha +$s fcircle 320 280 40 {*}$cyan +$s circle 320 280 60 {*}$yellow +$s aacircle 320 280 80 {*}$green + +$s rectangle 200 100 300 180 {*}$cyan +$s box 210 110 290 170 {*}$yellow + +set x 20 +set y 20 +set dy 10 +set dx 10 +foreach i [range 50] { + set nx $($x + $dx) + set ny $($y + $dy) + $s line $x $y $nx $ny {*}$green + $s aaline $x $($y+30) $nx $($ny+30) {*}$red + set x $nx + set y $ny + set dy $(-$dy) } -loop i 0 200 { - set commands {} - loop j 0 1000 { - lappend commands [rand_circle $xres $yres 40 100] - if {$j % 50 == 0} { - #$s clear 200 200 200 - drawlist $s $commands - $s flip - sleep 0.1 - } - } +$s rectangle 50 200 150 300 {*}$yellow +foreach i [range 500] { + $s pixel $([rand 100] + 50) $([rand 100] + 200) {*}$white } + +$s poll { sleep 0.25 } +$s free |