%boom.t %written by Mr. Fredrickson %Fall 2000 setscreen ("graphics:v16") setscreen ("nocursor") procedure clear colorback (blue) cls end clear procedure cleartop drawfillbox (0, maxy - 70, maxx, maxy, blue) end cleartop var nNum: int randomize randint(nNum, 5, 25) var g : real % gravity g := nNum * 1.0 procedure city (var y0left, y0right : int) var height, window, buildingx : int buildingx := 0 window := 10 % draws the buildings, and assigns y0 to the left and right sides for count : 1 .. 30 randint (height, 150, 333) drawfillbox (buildingx, 0, buildingx + 35, height, 0) if count = 2 then drawfillbox (buildingx + 5, height, buildingx + 20, height + 10, 4) drawfillarc (buildingx + 12, height + 5, 18, 18, 45, 60, red) y0left := height + 22 elsif count = 15 then drawfillbox (buildingx + 15, height, buildingx + 30, height + 10, green) drawfillarc (buildingx + 22, height + 5, 18, 18, 45 + 80, 60 + 80, green) y0right := height + 22 end if % draws the windows loop drawfillbox (buildingx + 5, window, buildingx + 9, window + 4, 255) drawfillbox (buildingx + 16, window, buildingx + 20, window + 4, 255) drawfillbox (buildingx + 27, window, buildingx + 31, window + 4, 255) window := window + 10 exit when (window + 9) > height end loop buildingx := buildingx + 40 window := 10 end for end city procedure getinfo (var a, v0 : int, turn : int) var xpos : int := 0 if turn = 1 then xpos := 0 elsif turn = - 1 then xpos := 420 end if cleartop locatexy (xpos, maxy) put "Enter the angle: " .. get a cleartop locatexy (xpos, maxy) put "Enter the speed: " .. get v0 cleartop end getinfo procedure booml (y0, a, v0 : int, var win : string) var y, x := 0 var x0 := 66 x := x0 loop y := round (y0 + (x - x0) * (sind (a) / cosd (a)) - 0.5 * g * ( (x - x0) / (v0 * cosd (a))) ** 2) x := x + 1 exit when x = maxx drawfilloval (x, y, 4, 4, 255) delay (5) % exits if green is hit if y + 15 < maxy - 5 then if x + 15 < maxx - 5 then if whatdotcolor (x, y + 5) = green then for count : 1 .. 10 drawfilloval (x, y, count, count, yellow) end for win := "left" exit elsif whatdotcolor (x + 5, y) = green then for count : 1 .. 10 drawfilloval (x, y, count, count, yellow) end for win := "left" exit elsif whatdotcolor (x, y - 5) = green then for count : 1 .. 10 drawfilloval (x, y, count, count, yellow) end for win := "left" exit end if end if end if if y + 15 < maxy - 5 then if x + 15 < maxx - 5 then if whatdotcolor (x, y + 5) not= blue then drawfilloval (x, y, 20, 20, blue) exit elsif whatdotcolor (x + 5, y) not= blue then drawfilloval (x, y, 20, 20, blue) exit elsif whatdotcolor (x, y - 5) not= blue then drawfilloval (x, y, 20, 20, blue) exit end if end if end if drawfilloval (x, y, 4, 4, blue) end loop end booml procedure boomr (y0, a, v0 : int, var win : string) var y, x, x0 := 0 var backw := maxx - 82 x := x0 loop y := round (y0 + (x - x0) * (sind (a) / cosd (a)) - 0.5 * g * ( (x - x0) / (v0 * cosd (a))) ** 2) x := x + 1 exit when x = maxx drawfilloval (x + backw, y, 4, 4, 255) delay (5) if y + 15 < maxy - 5 then if x + backw - 15 > 0 then if whatdotcolor (x + backw, y + 5) = red then for count : 1 .. 10 drawfilloval (x + backw, y, count, count, yellow) end for win := "right" exit elsif whatdotcolor (x + backw + 5, y) = red then for count : 1 .. 10 drawfilloval (x + backw, y, count, count, yellow) end for win := "right" exit elsif whatdotcolor (x + backw, y - 5) = red then for count : 1 .. 10 drawfilloval (x + backw, y, count, count, yellow) end for win := "right" exit end if end if end if if y + 15 < maxy - 5 then if x + backw - 15 > 0 then if whatdotcolor (x + backw, y + 5) not= blue then drawfilloval (x + backw, y, 20, 20, blue) exit elsif whatdotcolor (x + backw + 5, y) not= blue then drawfilloval (x + backw, y, 20, 20, blue) exit elsif whatdotcolor (x + backw, y - 5) not= blue then drawfilloval (x + backw, y, 20, 20, blue) exit end if end if end if drawfilloval (x + backw, y, 4, 4, blue) backw := backw - 2 end loop end boomr var y0left, y0right : int var al, v0l, ar, v0r : int var win := "" var turn : int var ans : string (1) loop clear city (y0left, y0right) turn := 1 win :="" loop getinfo (al, v0l, turn) booml (y0left, al, v0l, win) turn := - turn if win = "left" then put "Left Side Wins" exit end if getinfo (ar, v0r, turn) boomr (y0right, ar, v0r, win) turn := - turn if win = "right" then put "Right Side Wins" exit end if end loop put "Quit? (y/n) " .. getch (ans) exit when ans = "y" end loop clear put "Press to leave programme" getch (ans) clear