Post by tenochtitlanuk on Aug 5, 2021 6:47:38 GMT -5
I love how easy LB makes it to do coding tasks. My village were going to celebrate the end of lockdown restrictions with a summer fete, in open air, with various children's activities. I decided to do a variation on the traditional 'Pin the tail on the Donkey' by using not a donkey pictiure but a map of our village, and say that a treasure was hidden in a grid square. I never did trust blindfolded kids with pins in their hand- and it would be more educationally interesting! It took only about half an hour to perfect code that takes the map image and draws a grid and x/y references.
Since I wanted a big image I needed to tile it onto multtiple sheets of A4 and stick them together- again easy. The printing is easy, either by printing the tiles to my printer direct, or by saving as BMPs for putting on separate pages.
The code below is one version when I was testing- I needed to go to more tiles for a bigger poster image for the final version. But then the weather forecast was so bad for the day that it has been cancelled!! Where has Summer gone??
EDIT I of course generate the winning square- a treasure box of sweets- in LB!
nomainwin
WindowWidth =1241
WindowHeight =1064
open "KSM map +grid" for graphics_nsb as #wg
#wg "trapclose quit"
#wg "font 24 bold"
loadbmp "scr", "KSMmap.bmp"
#wg "down ; drawbmp scr 53 53 ; size 2 ; flush"
for x =2 to 1250 step 49
#wg "line "; x; " 2 "; x ;" 1030"
next x
for x =51 to 1151 step 49
#wg "place "; x +10; " 1020": #wg "\"; chr$( 64 +int( x /49))
#wg "place "; x +10; " 36": #wg "\"; chr$( 64 +int( x /49))
next x
#wg "color red"
for y =2 to 1080 step 49
#wg "line "; "2 "; y ; " 1227 "; y
next y
for y =2 to 890 step 49
#wg "place "; 10; " "; y +85: #wg "\"; right$( " " +str$( int( y /49)), 2)
#wg "place "; 1185; " "; y +85: #wg "\"; right$( " " +str$( int( y /49)), 2)
next y
#wg "getbmp scr 1 1 1241 1064"
bmpsave "scr", "griddedKSM0.bmp"
#wg "print 1241"
#wg "getbmp scr 1 1 640 544"
bmpsave "scr", "griddedKSM1.bmp"
#wg "getbmp scr 620 1 640 544"
bmpsave "scr", "griddedKSM2.bmp"
#wg "getbmp scr 1 520 640 544"
bmpsave "scr", "griddedKSM3.bmp"
#wg "getbmp scr 620 520 640 544"
bmpsave "scr", "griddedKSM4.bmp"
wait
sub quit h$
close #wg
end
end sub