'Picaxe "21" Game code main: let dirs = %00000010 'set pins 0 & 1 as outputs, 1,2 & 3 as inputs pause 50 b1=1 'reset 1 to 20 counter to 1 goto player_go player_go: pause 50 if pin2 = 1 then one 'press button 1 - green led one flash if pin3 = 1 then two 'press button 2 - green led two flashes if pin4 = 1 then three 'press button 3 - green led three flashes goto player_go one: 'player moves one pause 50 b1=b1+1 'increment counter by 1 high 1 pause 102 'equals 15 degrees turn low 1 goto move two: 'player moves two pause 50 for b0 = 0 to 1 'loop counter twice b1=b1+1 'increment counter by 1 pause 300 high 1 pause 102 'equals 15 degrees turn low 1 next b0 wait 1 goto move three: 'player moves three pause 50 for b0 = 0 to 2 'loop 3 times b1=b1+1 'increment counter by 1 pause 300 high 1 pause 102 'equals 15 degrees turn low 1 next b0 goto move move: sound 0,(100,100) 'machine thinking sound - check count pause 800 if b1 = 1 then m3 if b1 = 2 then m2 if b1 = 3 then m1 if b1 = 4 then m1 if b1 = 5 then m2 if b1 = 6 then m3 if b1 = 7 then m2 if b1 = 8 then m1 if b1 = 9 then m1 if b1 = 10 then m3 if b1 = 11 then m2 if b1 = 12 then m1 if b1 = 13 then m1 if b1 = 14 then m3 if b1 = 15 then m2 if b1 = 16 then m1 if b1 = 17 then mwin if b1 = 18 then mwin if b1 = 19 then mwin if b1 = 20 then pwin m1: 'machine moves on pause 50 b1=b1+1 'increment counter by 1 pause 50 high 1 pause 102 'equals 15 degrees turn low 1 pause 50 goto player_go m2: 'machine moves two pause 50 for b0 = 0 to 1 'loop two times pause 300 high 1 pause 102 'equals 15 degrees turn low 1 b1=b1+1 'increment counter by 1 pause 50 next b0 goto player_go m3: 'machine moves three pause 50 for b0 = 0 to 2 'loop three times pause 300 high 1 pause 102 'equals 15 degrees turn low 1 b1=b1+1 'increment counter by 1 next b0 goto player_go mwin: 'Machine wins sound 0,(120,200) 'machine win sound pause 50 high 0 'amber LED on for 8 seconds wait 8 low 0 goto main pwin: 'player wins high 1 wait 5 'green LED on for 5 seconds - pointer spins low 1 goto main