Computer Science Canada Forward Procedure + Loop Selection Help!!!!!! |
Author: | SucreTeen123 [ Fri Jun 01, 2012 11:22 pm ] |
Post subject: | Forward Procedure + Loop Selection Help!!!!!! |
So this is my problem. I am using two different forward procedures and I am using a type of loop selection. When I press 1 it goes to inventory and any other random key it goes back to menu. Here is where it gets complicated. When I enter 2 it goes to Description but it won't go back to the menu, and when I press 'a' to see a description of Rihanna's CD album, it refuses to go back. I don't understand what is wrong and I really hope that someone will give me an answer. I've tried everything. I know that there is something wrong with the loop selection, which is at the bottom, but I'm also wondering if there's something wrong with the procedures. PLEASE HELP! IT'S LIKE DUE NEXT TUESDAY!!!!!!! import GUI setscreen ("nocursor") setscreen ("graphics: 1000, 1000") forward procedure Inventory forward procedure Rihanna forward procedure Rihanna1 forward procedure Rihanna2 forward procedure Rihanna3 forward procedure Rihanna4 forward procedure Rihanna5 forward procedure Rihanna6 forward procedure Rihanna7 forward procedure Rihanna8 forward procedure Rihanna9 forward procedure Rihanna10 forward procedure Rihanna11 %MUSIC %Music.PlayFileReturn ("Hedley - Invincible.mp3") %ANIMATION var PicID : int var i, j : int var k : real i := 0 PicID := Pic.FileNew ("Checker.jpg") loop i := i + 1 const m := 0.05 * i k := -0.005 * (i - 300) ** 2 + 450 j := round (k) Pic.Draw (PicID, i, j, picCopy) delay (4) exit when i > 1000 drawoval (i, round (j), 50, 50, white) end loop cls %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %MENu forward procedure menu body procedure menu %Welcome Page var x, y : int var font1, font2 : int font1 := Font.New ("serif:111") font2 := Font.New ("serif:151") x := floor (maxx / 2) y := floor (maxy / 2) %Background var pic : int := Pic.FileNew ("Butterflies3.jpg") var width : int := Pic.Width (pic) var height : int := Pic.Height (pic) var h, n : int := 0 loop exit when n > maxy loop exit when h > maxx Pic.Draw (pic, h, n, picCopy) h := h + width end loop h := 0 n := n + height end loop %Welcome Draw.Text ("W", 300, 850, font1, blue) Draw.Text ("e", 420, 850, font1, blue) Draw.Text ("l", 480, 850, font1, blue) Draw.Text ("c", 515, 850, font1, blue) Draw.Text ("o", 576, 850, font1, blue) Draw.Text ("m", 640, 850, font1, blue) Draw.Text ("e", 750, 850, font1, blue) %To Draw.Text ("T", 480, 700, font1, red) Draw.Text ("o", 550, 700, font1, red) %S&C Draw.Text ("S", 467, 500, font2, green) Draw.Text ("&", 530, 530, font1, black) Draw.Text ("C", 580, 500, font2, green) %Pictures PicID := Pic.FileNew ("Big Bang1.jpg") Pic.Draw (PicID, 20, 540, picCopy) PicID := Pic.FileNew ("Shinee1.jpg") Pic.Draw (PicID, 15, 810, picCopy) PicID := Pic.FileNew ("Rihanna2.jpg") Pic.Draw (PicID, 695, 660, picCopy) PicID := Pic.FileNew ("OneRepublic1.jpg") Pic.Draw (PicID, 765, 410, picCopy) %Box drawfillbox (1000, 200, 0, 450, 101) var font3, font4 : int font3 := Font.New ("serif:30:bold") font4 := Font.New ("arial:20:italic") assert font3 > 0 Font.Draw ("1. Inventory ", 10, maxy - 605, font3, 16) Font.Draw ("2. Description ", 10, maxy - 655, font3, 16) Font.Draw ("3. Purchase ", 10, maxy - 705, font3, 16) Font.Draw ("4. Bye", 10, maxy - 755, font3, 16) put "Please enter option" end menu %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %1- INTRODUCTION %process BigBang % loop % Music.PlayFile ("Big Bang - Always.MP3") % end loop %end BigBang %fork BigBang %MUSIC AND AMINATION body procedure Inventory cls var font5, font6 : int var s : string (1) font5 := Font.New ("serif:20:bold,underline") font6 := Font.New ("arial:18:") assert font5 > 0 %Background var pic2 : int := Pic.FileNew ("Music1.jpg") var width2 : int := Pic.Width (pic2) var height2 : int := Pic.Height (pic2) var h2, n2 : int := 0 loop exit when n2 > maxy loop exit when h2 > maxx Pic.Draw (pic2, h2, n2, picCopy) h2 := h2 + width2 end loop h2 := 0 n2 := n2 + height2 end loop %MUSIC Music.PlayFileReturn ("Big Bang - Always.mp3") var intro : string Draw.Text ("Please take a look at our inventory", 10, 960, font5, black) var PicID1 : int %Front PicID1 := Pic.FileNew ("Rihanna1.jpg") Pic.Draw (PicID1, 20, 760, picCopy) Draw.Text ("$10.99 - Rihanna", 5, 740, font6, black) PicID1 := Pic.FileNew ("Shinee2.jpg") Pic.Draw (PicID1, 40, 470, picCopy) Draw.Text ("$36.99 - Shinee: Sherlock", 5, 450, font6, black) PicID1 := Pic.FileNew ("Big Bang2.jpg") Pic.Draw (PicID1, 30, 250, picCopy) Draw.Text ("$44.00 - Big Bang: Alive", 5, 230, font6, black) PicID1 := Pic.FileNew ("MichaelJackson1.jpg") Pic.Draw (PicID1, 40, 50, picCopy) Draw.Text ("$6.99 - Michael Jackson: Invincible", 5, 30, font6, black) %Middle PicID1 := Pic.FileNew ("KellyClarkson1.jpg") Pic.Draw (PicID1, 370, 720, picCopy) Draw.Text ("$11.00 - Kelly Clarkson - Stronger", 280, 700, font6, black) PicID1 := Pic.FileNew ("2ne1 - 1.jpg") Pic.Draw (PicID1, 370, 470, picCopy) Draw.Text ("$31.00 - 2NE1: Mini Album", 370, 450, font6, black) PicID1 := Pic.FileNew ("KatyPerry1.jpg") Pic.Draw (PicID1, 370, 215, picCopy) Draw.Text ("$14.00 - Katy Perry: Teenage Dream ", 310, 195, font6, black) PicID1 := Pic.FileNew ("OneRepublic2.jpg") Pic.Draw (PicID1, 422, 34, picCopy) Draw.Text ("$15.00 - One Republic: Waking Up", 380, 12, font6, black) %422, 34 : 410, 14 %Last PicID1 := Pic.FileNew ("MBLAQ1.jpg") Pic.Draw (PicID1, 680, 760, picCopy) Draw.Text ("$40.00 - MBLAQ: BLAQ Style", 660, 740, font6, black) PicID1 := Pic.FileNew ("Adele1.jpg") Pic.Draw (PicID1, 700, 490, picCopy) Draw.Text ("$13.00 - Adele: 21", 710, 470, font6, black) PicID1 := Pic.FileNew ("Infinite1.jpg") Pic.Draw (PicID1, 690, 250, picCopy) Draw.Text ("$35.00 - Infinite: Paradise", 670, 230, font6, black) PicID1 := Pic.FileNew ("Hedley1.jpg") Pic.Draw (PicID1, 730, 60, picCopy) Draw.Text ("$14.99 - Hedley: Storms", 670, 42, font6, black) getch (s) put "please anything and enter to go to the main menu" cls end Inventory %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% forward procedure Description body procedure Description var font1, font2 : int font1 := Font.New ("serif:33:bold, underline") font2 := Font.New ("Times New Roman:30:bold") assert font1 > 0 %Background var pic3 : int := Pic.FileNew ("Black1.jpg") var width3 : int := Pic.Width (pic3) var height3 : int := Pic.Height (pic3) var h3, n3 : int := 0 loop exit when n3 > maxy loop exit when h3 > maxx Pic.Draw (pic3, h3, n3, picCopy) h3 := h3 + width3 end loop h3 := 0 n3 := n3 + height3 end loop %Choice Font.Draw ("Please pick the one you wish to view", 10, 960, font1, 55) %Choices to pick Font.Draw ("A. Rihanna", 400, 880, font2, 41) Font.Draw ("B. SHINee", 400, 820, font2, 30) Font.Draw ("C. Big Bang", 400, 760, font2, 102) Font.Draw ("D. Michael Jackson", 400, 700, font2, 35) Font.Draw ("E. Kelly Clarkson", 400, 640, font2, 68) Font.Draw ("F. 2NE1", 400, 580, font2, 12) Font.Draw ("G. Katy Perry", 400, 520, font2, 85) Font.Draw ("H. One Republic", 400, 460, font2, 55) Font.Draw ("I. MBLAQ", 400, 400, font2, 31) Font.Draw ("J. Adele", 400, 340, font2, 101) Font.Draw ("K. Infinite", 400, 280, font2, 8) Font.Draw ("L. Hedley", 400, 220, font2, 55) %Picture var PicID2 : int PicID2 := Pic.FileNew ("Rihanna3.jpg") Pic.Draw (PicID2, 30, 700, picCopy) PicID2 := Pic.FileNew ("Big Bang3.jpg") Pic.Draw (PicID2, 260, 10, picCopy) PicID2 := Pic.FileNew ("MichaelJackson2.jpg") Pic.Draw (PicID2, 750, 450, picCopy) PicID2 := Pic.FileNew ("2ne1 - 2.jpg") Pic.Draw (PicID2, 700, 230, picCopy) PicID2 := Pic.FileNew ("KatyPerry2.jpg") Pic.Draw (PicID2, 40, 200, picCopy) PicID2 := Pic.FileNew ("MBLAQ2.jpg") Pic.Draw (PicID2, 700, 750, picCopy) PicID2 := Pic.FileNew ("Infinite3.jpg") Pic.Draw (PicID2, 580, 15, picCopy) PicID2 := Pic.FileNew ("Hedley2.jpg") Pic.Draw (PicID2, 40, 500, picCopy) end Description %Songs body procedure Rihanna1 Music.PlayFile ("Rihanna 1 - S&M.mp3") end Rihanna1 body procedure Rihanna2 Music.PlayFile ("Rihanna 2 - What's My Name.mp3") end Rihanna2 body procedure Rihanna3 Music.PlayFile ("Rihanna 3 - Cheers.mp3") end Rihanna3 body procedure Rihanna4 Music.PlayFile ("Rihanna 4 - Fading.mp3") end Rihanna4 body procedure Rihanna5 Music.PlayFile ("Rihanna 5 - Only Girl.mp3") end Rihanna5 body procedure Rihanna6 Music.PlayFile ("Rihanna 6 - California King Bed.mp3") end Rihanna6 body procedure Rihanna7 Music.PlayFile ("Rihanna 7 - Man Down.mp3") end Rihanna7 body procedure Rihanna8 Music.PlayFile ("Rihanna 8 - Raining Men.mp3") end Rihanna8 body procedure Rihanna9 Music.PlayFile ("Rihanna 9 - Complicated.mp3") end Rihanna9 body procedure Rihanna10 Music.PlayFile ("Rihanna 10 - Skin.mp3") end Rihanna10 body procedure Rihanna11 Music.PlayFile ("Rihanna 11 - Love the Way You Lie.mp3") end Rihanna11 body procedure Rihanna %procedure Rhianna %Background var pic4 : int := Pic.FileNew ("Red1.jpg") var width4 : int := Pic.Width (pic4) var height4 : int := Pic.Height (pic4) var h4, n4 : int := 0 loop exit when n4 > maxy loop exit when h4 > maxx Pic.Draw (pic4, h4, n4, picCopy) h4 := h4 + width4 end loop h4 := 0 n4 := n4 + height4 end loop %Pictures var PicID3 : int PicID3 := Pic.FileNew ("Rihanna4.jpg") Pic.Draw (PicID3, 750, 700, picCopy) PicID3 := Pic.FileNew ("Rihanna5.jpg") Pic.Draw (PicID3, 750, 450, picCopy) PicID3 := Pic.FileNew ("Rihanna6.jpg") Pic.Draw (PicID3, 100, 50, picCopy) PicID3 := Pic.FileNew ("Rihanna7.jpg") Pic.Draw (PicID3, 400, 50, picCopy) PicID3 := Pic.FileNew ("Rihanna8.jpg") Pic.Draw (PicID3, 700, 50, picCopy) %Intro var hil : string (1) var font9, font10 : int font9 := Font.New ("Times New Roman:33") font10 := Font.New ("arial:35:bold,underline ") assert font9 > 0 Font.Draw (" Album List ", 370, maxy - 70, font10, 36) Font.Draw ("1. S&M", 20, maxy - 140, font9, black) Font.Draw ("2. What's My Name ft.Drake", 20, maxy - 190, font9, black) Font.Draw ("3. Cheers (Drink to That)", 20, maxy - 240, font9, black) Font.Draw ("4. Fading", 20, maxy - 290, font9, black) Font.Draw ("5. Only Girl (In the World)", 20, maxy - 340, font9, black) Font.Draw ("6. California King Bed", 20, maxy - 390, font9, black) Font.Draw ("7. Man Down", 20, maxy - 440, font9, black) Font.Draw ("8. Raining Men ft.Nicki Minai", 20, maxy - 490, font9, black) Font.Draw ("9. Complicated", 20, maxy - 540, font9, black) Font.Draw ("10. Skin", 20, maxy - 590, font9, black) Font.Draw ("11. Love the Way You Lie (Part II ft. Eminem)", 20, maxy - 640, font9, black) %Buttons var draw1 : int := GUI.CreateButtonFull (170, 860, 00, "S&M", Rihanna1, 00, '^D', true) var draw2 : int := GUI.CreateButtonFull (530, 810, 00, "What's My Name", Rihanna2, 00, '^D', true) var draw3 : int := GUI.CreateButtonFull (470, 760, 00, "Cheers", Rihanna3, 00, '^D', true) var draw4 : int := GUI.CreateButtonFull (190, 707, 00, "Fading", Rihanna4, 00, '^D', true) var draw5 : int := GUI.CreateButtonFull (500, 660, 00, "Only Girl", Rihanna5, 00, '^D', true) var draw6 : int := GUI.CreateButtonFull (430, 610, 00, "California King Bed", Rihanna6, 00, '^D', true) var draw7 : int := GUI.CreateButtonFull (270, 558, 00, "Man Down", Rihanna7, 00, '^D', true) var draw8 : int := GUI.CreateButtonFull (555, 511, 00, "Raining Men", Rihanna8, 00, '^D', true) var draw9 : int := GUI.CreateButtonFull (290, 460, 00, "Complicated", Rihanna9, 00, '^D', true) var draw10 : int := GUI.CreateButtonFull (170, 410, 00, "Skin", Rihanna10, 00, '^D', true) var draw11 : int := GUI.CreateButtonFull (650, 320, 00, "Love the Way You Lie", Rihanna11, 00, '^D', true) loop exit when GUI.ProcessEvent end loop end Rihanna %%%%% loop var option : string (1) menu getch (option) case option of label "1" : Inventory label "2" : Description exit end case end loop loop var option2 : string (1) Description getch (option2) case option2 of label "a" : Rihanna exit end case end loop |
Author: | Dreadnought [ Fri Jun 01, 2012 11:57 pm ] | ||
Post subject: | Re: Forward Procedure + Loop Selection Help!!!!!! | ||
Please don't double post... Out of the 500 lines of code here are the 20 or so that work the menu. Think through the logic in your head and the problem should be obvious.
|
Author: | helpmeplease [ Sat Jun 02, 2012 11:31 am ] |
Post subject: | Re: Forward Procedure + Loop Selection Help!!!!!! |
You can't ask for the answer, you have to figure out yourself. This is YOUR homework. Posting twice doesn't mean you will get the answer. Turing is all about logic, please try yourself first. |
Author: | Aange10 [ Sat Jun 02, 2012 1:13 pm ] |
Post subject: | RE:Forward Procedure + Loop Selection Help!!!!!! |
Also wrap your code in [ syntax="turing" ] [ /syntax ] tags. Seeing 500 lines of text makes me not want to help you |