Computer Science Canada weird error with "Pic" Command |
Author: | person [ Sat Jan 15, 2005 7:17 pm ] |
Post subject: | weird error with "Pic" Command |
Run the program about 12 times and there's an error with the program but i dont know wats wrong. import GUI var win := Window.Open ("position:0;0,graphics:1201;720") var b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12, b13, b14, b15, menubutton, exitb, playb, helpb, buttonstartgame, bs : int var pictureID, pictureID2, pictureID3, pictureID4, picture, picture2, picture3, pictureWidth, pictureHeight, pictureWidth2, pictureHeight2, s1, s2, s3, s4, s5 : int var money : int := 45 var p1, p2, p3 : string var a, b, c, d, e, f, g, h, i, j, k, l, m, n, o : int := 0 pictureID3 := Pic.FileNew ("startline.jpg") pictureID4 := Pic.FileNew ("finishline.jpg") procedure title cls pictureID := Pic.FileNew ("back.jpg") pictureWidth := Pic.Width (pictureID) pictureHeight := Pic.Height (pictureID) picture := Pic.Scale (pictureID, pictureWidth * 3, pictureHeight * 2) Pic.Draw (picture, 0, 0, picMerge) var font1 : int := Font.New ("Edwardian Script ITC:50") Draw.Text ("Racing", 515, 650, font1, 44) end title procedure hide GUI.Hide (b1) GUI.Hide (b2) GUI.Hide (b3) GUI.Hide (b4) GUI.Hide (b5) GUI.Hide (b6) GUI.Hide (b7) GUI.Hide (b8) GUI.Hide (b9) GUI.Hide (b10) GUI.Hide (b11) GUI.Hide (b12) GUI.Hide (b13) GUI.Hide (b14) GUI.Hide (b15) GUI.Hide (menubutton) end hide procedure introduction hide title locate (20, 1) var font : int := Font.New ("Coronet:56") Font.Draw ("Welcome to the Exciting World of Horse Racing!!", 50, 450, font, red) GUI.Show (helpb) GUI.Show (buttonstartgame) GUI.Show (exitb) end introduction procedure mainmenu hide title GUI.Show (buttonstartgame) GUI.Show (helpb) GUI.Show (exitb) end mainmenu procedure secondMenu GUI.Show (b1) GUI.Show (b2) GUI.Show (b3) GUI.Show (b4) GUI.Show (b5) GUI.Show (b6) GUI.Show (b7) GUI.Show (b8) GUI.Show (b9) GUI.Show (b10) GUI.Show (b11) GUI.Show (b12) GUI.Show (b13) GUI.Show (b14) GUI.Show (b15) GUI.Show (bs) GUI.Show (menubutton) end secondMenu procedure help cls title locate (20, 1) var font : int := Font.New ("Mistral:20") Font.Draw ("The objective of the game is to maximize your number of coins. You begin with 45 coins, and you will have the option of", 100, 400, font, red) Font.Draw ("betting on any of the 5 horses. You can choose to bet on who will be first, second, or third with their odds written beside the horse", 5, 350, font, red) Font.Draw ("number. To bet on a horse, just click the horse number. Havefun, and the best of luck to you!", 5, 300, font, red) GUI.Show (menubutton) end help procedure display var pa, pb, pc, pd, pe : int := 1050 var s6, s7, s8, s9, s10 : int pictureID := Pic.FileNew ("horse.jpg") pictureWidth := Pic.Width (pictureID) pictureHeight := Pic.Height (pictureID) picture := Pic.Scale (pictureID, pictureWidth div 6, pictureHeight div 6) pictureID2 := Pic.FileNew ("back.jpg") pictureWidth2 := Pic.Width (pictureID2) pictureHeight2 := Pic.Height (pictureID2) picture2 := Pic.Scale (pictureID2, pictureWidth2 div 0.6, pictureHeight2 div 1.2) s1 := Rand.Int (1, 12) s2 := Rand.Int (1, 8) s3 := Rand.Int (1, 5) s4 := Rand.Int (1, 3) s5 := Rand.Int (1, 2) loop s6 := Rand.Int (1, 20) s7 := Rand.Int (1, 20) s8 := Rand.Int (1, 20) s9 := Rand.Int (1, 20) s10 := Rand.Int (1, 20) pa := pa - s1 - s6 pb := pb - s2 - s7 pc := pc - s3 - s8 pd := pd - s4 - s9 pe := pe - s5 - s10 Pic.Draw (picture2, 105, 200, picMerge) Pic.Draw (pictureID3, 1035, 200, picMerge) Pic.Draw (pictureID4, 0, 200, picMerge) Pic.Draw (picture, pa, 520, picMerge) Pic.Draw (picture, pb, 440, picMerge) Pic.Draw (picture, pc, 360, picMerge) Pic.Draw (picture, pd, 280, picMerge) Pic.Draw (picture, pe, 200, picMerge) if pa <= 100 and pb > pa and pc > pa and pd > pa and pe > pa then p1 := "Horse 1 is the Winner!" elsif pb <= 100 and pa > pb and pc > pb and pd > pb and pe > pb then p1 := "Horse 2 is the Winner!" elsif pc <= 100 and pb > pc and pa > pc and pd > pc and pe > pc then p1 := "Horse 3 is the Winner!" elsif pd <= 100 and pb > pd and pc > pd and pa > pd and pe > pd then p1 := "Horse 4 is the Winner!" elsif pe <= 100 and pb > pe and pc > pe and pd > pe and pa > pe then p1 := "Horse 5 is the Winner!" end if if pa <= 100 and p1 not= "Horse 1 is the Winner!" and (pb < pa or pc < pa or pd < pa or pe < pa) and ((pb > 100 and pc > 100 and pd > 100 and pe < pa) or (pb > 100 and pc > 100 and pe > 100 and pd < pa) or (pd > 100 and pc > 100 and pe > 100 and pb < pa) or (pb > 100 and pe > 100 and pd > 100 and pc < pa)) then p2 := "Horse 1 is Second" elsif pb <= 100 and p1 not= "Horse 2 is the Winner!" and (pa < pb or pc < pb or pd < pb or pe < pb) and ((pa > 100 and pc > 100 and pd > 100 and pb > pe) or (pa > 100 and pc > 100 and pe > 100 and pb > pd) or (pd > 100 and pc > 100 and pe > 100 and pb > pa) or (pa > 100 and pe > 100 and pd > 100 and pb > pc)) then p2 := "Horse 2 is Second" elsif pc <= 100 and p1 not= "Horse 3 is the Winner!" and (pb < pc or pa < pc or pd < pc or pe < pc) and ((pb > 100 and pa > 100 and pd > 100 and pc > pe) or (pb > 100 and pa > 100 and pe > 100 and pc > pd) or (pd > 100 and pa > 100 and pe > 100 and pc > pb) or (pb > 100 and pe > 100 and pd > 100 and pc > pa)) then p2 := "Horse 3 is Second" elsif pd <= 100 and p1 not= "Horse 4 is the Winner!" and (pb < pd or pc < pd or pa < pd or pe < pd) and ((pb > 100 and pc > 100 and pa > 100 and pd > pe) or (pb > 100 and pc > 100 and pe > 100 and pd > pa) or (pa > 100 and pc > 100 and pe > 100 and pd > pb) or (pb > 100 and pe > 100 and pa > 100 and pd > pc)) then p2 := "Horse 4 is Second" elsif pe <= 100 and p1 not= "Horse 5 is the Winner!" and (pb < pe or pc < pe or pd < pe or pa < pe) and ((pb > 100 and pc > 100 and pd > 100 and pe > pa) or (pb > 100 and pc > 100 and pa > 100 and pe > pd) or (pd > 100 and pc > 100 and pa > 100 and pe > pb) or (pb > 100 and pa > 100 and pd > 100 and pe > pc)) then p2 := "Horse 5 is Second" end if if pa <= 100 and p1 not= "Horse 1 is the Winner!" and p2 not= "Horse 1 is Second" and ((pe > pa and pb > pa) or (pe > pa and pc > pa) or (pe > pa and pd > pa) or (pb > pa and pc > pa) or (pb > pa and pd > pa) or (pc > pa and pd > pa)) then p3 := "Horse 1 is Third" exit elsif pb <= 100 and p1 not= "Horse 2 is the Winner!" and p2 not= "Horse 2 is Second" and ((pe > pb and pa > pb) or (pe > pb and pc > pb) or (pe > pb and pd > pb) or (pa > pb and pc > pb) or (pa > pb and pd > pb) or (pc > pb and pd > pb)) then p3 := "Horse 2 is Third" exit elsif pc <= 100 and p1 not= "Horse 3 is the Winner!" and p2 not= "Horse 3 is Second" and ((pe > pc and pa > pc) or (pe > pc and pb > pc) or (pe > pc and pd > pc) or (pa > pc and pb > pc) or (pa > pc and pd > pc) or (pb > pc and pd > pc)) then p3 := "Horse 3 is Third" exit elsif pd <= 100 and p1 not= "Horse 4 is the Winner!" and p2 not= "Horse 4 is Second" and ((pe > pd and pa > pd) or (pe > pd and pb > pd) or (pe > pd and pc > pd) or (pa > pd and pb > pd) or (pa > pd and pd > pc) or (pb > pd and pd > pc)) then p3 := "Horse 4 is Third" exit elsif pe <= 100 and p1 not= "Horse 5 is the Winner!" and p2 not= "Horse 5 is Second" and ((pd > pe and pa > pe) or (pd > pe and pb > pe) or (pd > pe and pd > pe) or (pa > pe and pb > pe) or (pa > pe and pd > pe) or (pb > pe and pd > pe)) then p3 := "Horse 5 is Third" exit end if end loop var font : int := Font.New ("Blackadder ITC:36") Font.Draw (p1, 300, 500, font, red) Font.Draw (p2, 300, 400, font, red) Font.Draw (p3, 300, 300, font, red) title Pic.Draw (pictureID3, 1035, 200, picMerge) Pic.Draw (pictureID4, 0, 200, picMerge) end display procedure mon locate (38, 101) put "Number of Coins Remaining: ", money end mon procedure bets colourback (2) locate (36, 1) put "1:1 - ", a locate (38, 1) put "2:1 - ", b locate (40, 1) put "4:1 - ", c locate (42, 1) put "10:1 - ", d locate (44, 1) put "16:1 - ", e locate (36, 31) put "2:1 - ", f locate (38, 31) put "1:1 - ", g locate (40, 31) put "4:1 - ", h locate (42, 31) put "8:1 - ", i locate (44, 31) put "12:1 - ", j locate (36, 61) put "4:1 - ", k locate (38, 61) put "2:1 - ", l locate (40, 61) put "1:1 - ", m locate (42, 61) put "6:1 - ", n locate (44, 61) put "8:1 - ", o end bets procedure nill a := 0 b := 0 c := 0 d := 0 e := 0 f := 0 g := 0 h := 0 i := 0 j := 0 k := 0 l := 0 m := 0 n := 0 o := 0 end nill procedure processing if a > 0 and p1 = "Horse 1 is the Winner!" then money := money + a * 2 end if if b > 0 and p1 = "Horse 2 is the Winner!" then money := money + b * 3 end if if c > 0 and p1 = "Horse 3 is the Winner!" then money := money + c * 5 end if if d > 0 and p1 = "Horse 4 is the Winner!" then money := money + d * 11 end if if e > 0 and p1 = "Horse 5 is the Winner!" then money := money + e * 17 end if if f > 0 and p2 = "Horse 1 is Second" then money := money + f * 3 end if if g > 0 and p2 = "Horse 2 is Second" then money := money + g * 2 end if if h > 0 and p2 = "Horse 3 is Second" then money := money + h * 5 end if if i > 0 and p2 = "Horse 4 is Second" then money := money + i * 9 end if if j > 0 and p2 = "Horse 5 is Second" then money := money + j * 13 end if if k > 0 and p3 = "Horse 1 is Third" then money := money + k * 5 end if if l > 0 and p3 = "Horse 2 is Third" then money := money + l * 3 end if if m > 0 and p3 = "Horse 3 is Third" then money := money + m * 2 end if if n > 0 and p3 = "Horse 4 is Third" then money := money + n * 7 end if if o > 0 and p3 = "Horse 5 is Third" then money := money + o * 9 end if nill bets mon secondMenu end processing procedure userInput if GUI.GetEventWidgetID = b1 then a := a + 1 elsif GUI.GetEventWidgetID = b2 then b := b + 1 elsif GUI.GetEventWidgetID = b3 then c := c + 1 elsif GUI.GetEventWidgetID = b4 then d := d + 1 elsif GUI.GetEventWidgetID = b5 then e := e + 1 elsif GUI.GetEventWidgetID = b6 then f := f + 1 elsif GUI.GetEventWidgetID = b7 then g := g + 1 elsif GUI.GetEventWidgetID = b8 then h := h + 1 elsif GUI.GetEventWidgetID = b9 then i := i + 1 elsif GUI.GetEventWidgetID = b10 then j := j + 1 elsif GUI.GetEventWidgetID = b11 then k := k + 1 elsif GUI.GetEventWidgetID = b12 then l := l + 1 elsif GUI.GetEventWidgetID = b13 then m := m + 1 elsif GUI.GetEventWidgetID = b14 then n := n + 1 elsif GUI.GetEventWidgetID = b15 then o := o + 1 end if bets mon secondMenu if GUI.GetEventWidgetID = b1 or GUI.GetEventWidgetID = b2 or GUI.GetEventWidgetID = b3 or GUI.GetEventWidgetID = b4 or GUI.GetEventWidgetID = b5 or GUI.GetEventWidgetID = b6 or GUI.GetEventWidgetID = b7 or GUI.GetEventWidgetID = b8 or GUI.GetEventWidgetID = b9 or GUI.GetEventWidgetID = b10 or GUI.GetEventWidgetID = b11 or GUI.GetEventWidgetID = b12 or GUI.GetEventWidgetID = b13 or GUI.GetEventWidgetID = b14 or GUI.GetEventWidgetID = b15 then money := money - 1 end if if money <= -1 then mainmenu money := 45 nill else mon end if end userInput procedure race display processing end race procedure game GUI.Hide (helpb) GUI.Hide (buttonstartgame) GUI.Hide (exitb) title Pic.Draw (pictureID3, 1035, 200, picMerge) Pic.Draw (pictureID4, 0, 200, picMerge) userInput end game procedure goodBye for x : 1 .. 100 put "This program was created by Xiao Hao" .. end for end goodBye b1 := GUI.CreateButtonFull (140, 140, 0, "Horse #1", userInput, 0, '^S', false) b2 := GUI.CreateButtonFull (140, 109, 0, "Horse #2", userInput, 0, '^S', false) b3 := GUI.CreateButtonFull (140, 77, 0, "Horse #3", userInput, 0, '^S', false) b4 := GUI.CreateButtonFull (140, 45, 0, "Horse #4", userInput, 0, '^S', false) b5 := GUI.CreateButtonFull (140, 12, 0, "Horse #5", userInput, 0, '^S', false) b6 := GUI.CreateButtonFull (380, 140, 0, "Horse #1", userInput, 0, '^S', false) b7 := GUI.CreateButtonFull (380, 109, 0, "Horse #2", userInput, 0, '^S', false) b8 := GUI.CreateButtonFull (380, 77, 0, "Horse #3", userInput, 0, '^S', false) b9 := GUI.CreateButtonFull (380, 45, 0, "Horse #4", userInput, 0, '^S', false) b10 := GUI.CreateButtonFull (380, 12, 0, "Horse #5", userInput, 0, '^S', false) b11 := GUI.CreateButtonFull (620, 140, 0, "Horse #1", userInput, 0, '^S', false) b12 := GUI.CreateButtonFull (620, 109, 0, "Horse #2", userInput, 0, '^S', false) b13 := GUI.CreateButtonFull (620, 77, 0, "Horse #3", userInput, 0, '^S', false) b14 := GUI.CreateButtonFull (620, 45, 0, "Horse #4", userInput, 0, '^S', false) b15 := GUI.CreateButtonFull (620, 12, 0, "Horse #5", userInput, 0, '^S', false) bs := GUI.CreateButtonFull (820, 12, 200, "Start Race!!", race, 0, '^S', false) menubutton := GUI.CreateButtonFull (1100, 160, 0, "Menu", mainmenu, 0, '^S', false) helpb := GUI.CreateButtonFull (420, 120, 0, "Help", help, 0, '^S', false) buttonstartgame := GUI.CreateButtonFull (620, 120, 0, "Start Game", game, 0, '^S', false) exitb := GUI.CreateButtonFull (820, 120, 0, "Quit Game", GUI.Quit, 0, '^S', false) title introduction loop exit when GUI.ProcessEvent end loop |