Computer Science Canada need help```~ |
Author: | powzow [ Thu Apr 28, 2005 3:46 pm ] |
Post subject: | need help```~ |
% set the screen so it does not have the buttonbars, % does not have the cursor, keys does not echo, % and let the mode be compatible with View.Update View.Set ("nobuttonbar,offscreenonly,noecho,nocursor") %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %Variable Library: % %fontx: where x is a number, declares a font and stores it. % %timer: a variable created to store time % %jackie, bruce, etc: declares the variable and stores a picture, % % which is usedlater in the program. % %chars: a variable created in order to use the Input.KeyDown command % %healthx, specialx: where x is a number, is a variable that is used % % to create the health and special bar. % %w , e: variables that indicate the starting position of both fighters% %x , y: a variable that is used to store a random number which is the % % damage assigned to a character when hit. % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % process kungfufighting % Music.PlayFile ("Foo Fighters - Kung Fu Fighting.mp3") % end kungfufighting process tigerroar Music.PlayFile ("tigerroar.wav") end tigerroar process dragonroar Music.PlayFile ("dragonroar.wav") end dragonroar var font1 : int font1 := Font.New ("serif:12") var font2 : int font2 := Font.New ("Times New Roman:40:Bold,Italic") var font3 : int font3 := Font.New ("arial:14:Bold,Italic") var timer : int var jackie := Pic.FileNew ("jackie chan.bmp") var bruce := Pic.FileNew ("bruce lee.bmp") var tigersuper := Pic.FileNew ("Tiger2.bmp") var dragonsuper := Pic.FileNew ("Dragon2.bmp") var superback := Pic.FileNew ("tiger_dragon.bmp") var tigersign := Pic.FileNew ("tigersign.bmp") var dragonsign := Pic.FileNew ("dragonsign.bmp") var rushhour := Pic.FileNew ("rushhour.bmp") var chars : array char of boolean var health1 := 200 var special1 := 50 var health2 := 550 var special2 := 400 var w := 200 var e := 400 var x, y : int % the inroduction proc intro var x, y, x1, y1 := 0 var key : string (1) loop colorback (black) cls Font.Draw ("Chinese Edition", 160, 180, font2, yellow) Font.Draw ("press any key to continue", 250, 3, font1, white) View.Update % if a key is pressed, it exits the loop if hasch then getch (key) exit end if end loop loop % draw lines which start at mid screen and go around by using trig. y := round (cosd (y1) * 3200) x := round (sind (x1) * 3200) drawline (maxx div 2, maxy div 2, x, y, purple) delay (20) View.Update x1 += 1 y1 += 1 exit when x1 = 360 end loop loop colorback (white) cls % displaying instructions on the screen Font.Draw ("In order to overcome your foe,", 190, 300, font3, red) Font.Draw ("you must have longanimity and be", 190, 250, font3, red) Font.Draw ("proficient in the deadly skills of", 190, 200, font3, red) Font.Draw ("Martial Arts. Here are some guides", 190, 150, font3, red) Font.Draw ("in becoming a Kung Fu Master.", 190, 100, font3, red) Font.Draw ("press any key to continue", 250, 3, font1, black) View.Update if hasch then getch (key) exit end if end loop cls loop Font.Draw ("1P : punch: a, move: j and k", 190, 300, font3, red) Font.Draw ("2P : punch: 1, move: left arrow and right arrow", 100, 250, font3, red) Font.Draw ("Watch for the health and special bar also,", 120, 200, font3, red) Font.Draw ("They will aid you in overcoming your opponent", 100, 150, font3, red) Font.Draw ("press any key to continue", 250, 3, font1, black) View.Update if hasch then getch (key) exit end if end loop end intro % the POW program proc pow (clr : int) % creating an array of 20 x variables var x : array 1 .. 20 of int var clr1 : int % assigning values to the varables randint (x (1), 100, 400) x (2) := x (1) + 30 x (3) := x (1) + 20 x (4) := x (1) + 38 x (5) := x (1) + 40 x (6) := x (1) + 46 x (7) := x (1) + 60 x (8) := x (1) + 54 x (9) := x (1) + 80 x (10) := x (1) + 62 x (11) := x (1) + 100 x (12) := x (1) + 70 x (13) := x (1) + 80 x (14) := x (1) + 62 x (15) := x (1) + 60 x (16) := x (1) + 54 x (17) := x (1) + 40 x (18) := x (1) + 46 x (19) := x (1) + 20 x (20) := x (1) + 38 var y : array 1 .. 20 of int randint (y (1), 100, 400) y (2) := y (1) + 10 y (3) := y (1) + 40 y (4) := y (1) + 15 y (5) := y (1) + 60 y (6) := y (1) + 30 y (7) := y (1) + 60 y (8) := y (1) + 30 y (9) := y (1) + 40 y (10) := y (1) + 15 y (11) := y (1) + 10 y (12) := y (1) + 0 y (13) := y (1) - 10 y (14) := y (1) - 15 y (15) := y (1) - 40 y (16) := y (1) - 30 y (17) := y (1) - 60 y (18) := y (1) - 30 y (19) := y (1) - 60 y (20) := y (1) - 15 % draw a 20 sided polygon drawpolygon (x, y, 20, clr) % write the word POW in the center of the polygon Font.Draw ("POW", x (1) + 32, y (1) - 3, font1, clr + 2) end pow proc hyperscreen (clr : int) % declaring an array of variable which is used to store the values of the line var x : array 1 .. 256 of int var y : array 1 .. 256 of int % assigning values to the x and y variable for i : 1 .. 256 randint (x (i), maxx, maxx + 200) randint (y (i), 0, maxy) end for loop for i : 1 .. 256 % drawing a line of 40 pixels long x (i) := x (i) - 400 drawline (x (i), y (i), x (i) + 100, y (i), clr) View.Update delay (20) % blanking the line out drawline (x (i), y (i), x (i) + 100, y (i), colorbg) % if the line reaches the left side, get another x and draw another line if x (i) <= 0 then randint (x (i), maxx, maxx * 2) end if end for % put a timer on the program, so it only runs for the time allowed clock (timer) exit when timer >= 100 end loop end hyperscreen % drawing the fighters proc jackiestand (x, y, clr : int) % drawing everything in term of x and y, so it is possible to move it later % draw neck drawbox (x + 15, y, x + 45, y + 10, 1) % draw body drawline (x, y, x + 60, y, 1) drawline (x + 60, y, x + 40, y - 55, 1) drawline (x + 40, y - 55, x + 20, y - 55, 1) drawline (x + 20, y - 55, x, y, 1) % draw right arm drawline (x + 56, y - 10, x + 66, y - 20, clr) drawline (x + 66, y - 20, x + 81, y - 10, clr) drawline (x + 81, y - 10, x + 85, y - 15, clr) drawline (x + 85, y - 15, x + 66, y - 28, clr) drawline (x + 66, y - 28, x + 53, y - 15, clr) % draw left arm drawline (x + 16, y - 10, x + 26, y - 20, 1) drawline (x + 26, y - 20, x + 41, y - 10, 1) drawline (x + 41, y - 10, x + 45, y - 15, 1) drawline (x + 45, y - 15, x + 26, y - 28, 1) drawline (x + 26, y - 28, x + 13, y - 15, 1) % draw left leg drawline (x + 20, y - 55, x + 5, y - 80, 1) drawline (x + 27, y - 55, x + 13, y - 80, 1) drawline (x + 5, y - 80, x + 13, y - 80, 1) % draw right leg drawline (x + 40, y - 55, x + 55, y - 80, 1) drawline (x + 33, y - 55, x + 47, y - 80, 1) drawline (x + 55, y - 80, x + 47, y - 80, 1) % draw right fists drawoval (x + 88, y - 9, 5, 5, clr) drawline (x + 87, y - 7, x + 89, y - 5, clr) drawline (x + 89, y - 9, x + 91, y - 7, clr) % draw left fists drawoval (x + 48, y - 9, 5, 5, 1) drawline (x + 47, y - 7, x + 49, y - 5, 1) drawline (x + 49, y - 9, x + 51, y - 7, 1) % draw right foot drawline (x + 45, y - 85, x + 47, y - 80, 1) drawline (x + 45, y - 85, x + 65, y - 85, 1) drawline (x + 65, y - 85, x + 55, y - 80, 1) % draw left foot drawline (x + 13, y - 80, x + 15, y - 85, 1) drawline (x + 15, y - 85, x - 5, y - 85, 1) drawline (x - 5, y - 85, x + 5, y - 80, 1) end jackiestand proc jackiepunch (x, y, clr : int) % draw neck drawbox (x + 15, y, x + 45, y + 10, 1) %draw body drawline (x, y, x + 60, y, 1) drawline (x + 60, y, x + 40, y - 55, 1) drawline (x + 40, y - 55, x + 20, y - 55, 1) drawline (x + 20, y - 55, x, y, 1) % draw left leg drawline (x + 20, y - 55, x + 5, y - 80, 1) drawline (x + 27, y - 55, x + 13, y - 80, 1) drawline (x + 5, y - 80, x + 13, y - 80, 1) % draw right leg drawline (x + 40, y - 55, x + 55, y - 80, 1) drawline (x + 33, y - 55, x + 47, y - 80, 1) drawline (x + 55, y - 80, x + 47, y - 80, 1) % draw right foot drawline (x + 45, y - 85, x + 47, y - 80, 1) drawline (x + 45, y - 85, x + 65, y - 85, 1) drawline (x + 65, y - 85, x + 55, y - 80, 1) % draw left foot drawline (x + 13, y - 80, x + 15, y - 85, 1) drawline (x + 15, y - 85, x - 5, y - 85, 1) drawline (x - 5, y - 85, x + 5, y - 80, 1) % draw left arm drawline (x + 16, y - 10, x + 26, y - 20, 1) drawline (x + 26, y - 20, x + 41, y - 10, 1) drawline (x + 41, y - 10, x + 45, y - 15, 1) drawline (x + 45, y - 15, x + 26, y - 28, 1) drawline (x + 26, y - 28, x + 13, y - 15, 1) % draw left fists drawoval (x + 48, y - 9, 5, 5, 1) drawline (x + 47, y - 7, x + 49, y - 5, 1) drawline (x + 49, y - 9, x + 51, y - 7, 1) % draw right arm drawline (x + 56, y - 10, x + 100, y - 10, clr) drawline (x + 53, y - 16, x + 100, y - 16, clr) drawline (x + 100, y - 10, x + 100, y - 16, clr) % draw right fist drawoval (x + 105, y - 13, 5, 5, clr) drawline (x + 105, y - 11, x + 109, y - 11, clr) drawline (x + 105, y - 14, x + 109, y - 14, clr) end jackiepunch % drawing the other fighter, same technique proc brucestand (x, y, clr : int) % draw neck drawbox (x + 15, y, x + 45, y + 10, clr) %draw body drawline (x, y, x + 60, y, 1) drawline (x + 60, y, x + 40, y - 55, 1) drawline (x + 40, y - 55, x + 20, y - 55, 1) drawline (x + 20, y - 55, x, y, 1) % draw right arm drawline (x + 56, y - 10, x + 75, y - 35, clr) drawline (x + 54, y - 17, x + 70, y - 39, clr) drawline (x + 75, y - 35, x + 71, y - 39, clr) % draw left arm drawline (x + 60 - 56, y - 10, x + 60 - 75, y - 35, clr) drawline (x + 60 - 54, y - 17, x + 60 - 70, y - 39, clr) drawline (x + 60 - 75, y - 35, x + 60 - 71, y - 39, clr) % draw right fist drawoval (x + 76, y - 42, 5, 5, clr) drawline (x + 78, y - 40, x + 80, y - 42, clr) drawline (x + 76, y - 42, x + 78, y - 44, clr) % draw left fist drawoval (x + 60 - 76, y - 42, 5, 5, clr) drawline (x + 60 - 78, y - 40, x + 60 - 80, y - 42, clr) drawline (x + 60 - 76, y - 42, x + 60 - 78, y - 44, clr) % draw left leg drawline (x + 20, y - 55, x + 5, y - 80, 1) drawline (x + 27, y - 55, x + 13, y - 80, 1) drawline (x + 5, y - 80, x + 13, y - 80, 1) % draw right leg drawline (x + 40, y - 55, x + 55, y - 80, 1) drawline (x + 33, y - 55, x + 47, y - 80, 1) drawline (x + 55, y - 80, x + 47, y - 80, 1) % draw right foot drawline (x + 45, y - 85, x + 47, y - 80, 1) drawline (x + 45, y - 85, x + 65, y - 85, 1) drawline (x + 65, y - 85, x + 55, y - 80, 1) % draw left foot drawline (x + 13, y - 80, x + 15, y - 85, 1) drawline (x + 15, y - 85, x - 5, y - 85, 1) drawline (x - 5, y - 85, x + 5, y - 80, 1) end brucestand proc brucepunch (x, y, clr : int) % draw neck drawbox (x + 15, y, x + 45, y + 10, 1) %draw body drawline (x, y, x + 60, y, 1) drawline (x + 60, y, x + 40, y - 55, 1) drawline (x + 40, y - 55, x + 20, y - 55, 1) drawline (x + 20, y - 55, x, y, 1) % draw right arm drawline (x + 16, y - 10, x + 26, y - 20, clr) drawline (x + 26, y - 20, x + 41, y - 10, clr) drawline (x + 16, y - 10, x + 13, y - 15, clr) drawline (x + 45, y - 15, x + 26, y - 28, clr) drawline (x + 26, y - 28, x + 13, y - 15, clr) % draw right fists drawoval (x + 10, y - 9, 5, 5, clr) drawline (x + 11, y - 9, x + 7, y - 5, clr) drawline (x + 9, y - 11, x + 5, y - 7, clr) % draw left arm drawline (x - 40, y - 10, x + 3, y - 10, clr) drawline (x - 40, y - 16, x + 5, y - 16, clr) drawline (x - 40, y - 10, x - 36, y - 16, clr) % draw left fist drawoval (x - 41, y - 13, 5, 5, clr) drawline (x - 40, y - 11, x - 46, y - 11, clr) drawline (x - 40, y - 14, x - 46, y - 14, clr) % draw left leg drawline (x + 20, y - 55, x + 5, y - 80, 1) drawline (x + 27, y - 55, x + 13, y - 80, 1) drawline (x + 5, y - 80, x + 13, y - 80, 1) % draw right leg drawline (x + 40, y - 55, x + 55, y - 80, 1) drawline (x + 33, y - 55, x + 47, y - 80, 1) drawline (x + 55, y - 80, x + 47, y - 80, 1) % draw right foot drawline (x + 45, y - 85, x + 47, y - 80, 1) drawline (x + 45, y - 85, x + 65, y - 85, 1) drawline (x + 65, y - 85, x + 55, y - 80, 1) % draw left foot drawline (x + 13, y - 80, x + 15, y - 85, 1) drawline (x + 15, y - 85, x - 5, y - 85, 1) drawline (x - 5, y - 85, x + 5, y - 80, 1) end brucepunch % drawing the super moves of the characters proc jackiesuper var x1, y1 := 0 loop cls % changing the position of the picture, so it goes up x1 += 15 y1 += 15 View.Update % exit the program when the y value reaches a specific spot exit when y1 >= 490 end loop end jackiesuper % samething for this, except it's going dowm proc brucesuper var x1, y1 := 640 loop cls x1 -= 15 y1 -= 15 View.Update exit when y1 <= -180 end loop end brucesuper %main program % kung fu music %fork kungfufighting intro cls loop % displaying the health and special bar of both of the characters locate (1, 1) put health1 - 50 locate (2, 1) put special1 - 50 % drawing the health bar, % and make sure the box changes everytime the value of the varaible changes drawfillbox (50, 350, health1 + 5, 356, colorbg) drawfillbox (50, 350, health1, 356, red) drawfillbox (400, 350, health2 + 5, 356, colorbg) locate (1, 78) put health2 - 400 locate (2, 78) put special2 - 400 drawfillbox (400, 350, health2, 356, red) drawfillbox (50, 344, special1, 350, green) drawfillbox (400, 344, special2, 350, green) % drawing the fighters standing jackiestand (w, 200, 1) brucestand (e, 200, 1) View.Update % the Input.KeyDown allow more than one button to be pressed down at the same time Input.KeyDown (chars) % setting if statements, % which test to see if the fist of one fighter meets the other person if chars ('a') then jackiestand (w, 200, colorbg) jackiepunch (w, 200, 1) if w + 100 - e >= 0 then randint (x, 1, 5) health2 += -x randint (y, 3, 9) special1 += y special2 += 2 % checks to see if it touches the other guy, % if it did, the puching sound plays Music.PlayFile ("jackiepunch.wav") end if pow (red) View.Update delay (250) jackiepunch (w, 200, colorbg) end if % setting the if statements, % so that the fighters can move, and will not overlap each other if chars ('l') and w - e not= -95 then delay (10) cls w += 5 end if if chars ('j') and w not= 20 then delay (10) cls w -= 5 end if % samething for this fighter if chars ('1') then brucestand (e, 200, colorbg) brucepunch (e, 200, 1) if e - 36 - w <= 60 then randint (x, 1, 5) health1 += -x randint (y, 3, 9) special2 += y special1 += 2 Music.PlayFile ("brucepunch.wav") end if pow (green) View.Update delay (250) brucepunch (e, 200, colorbg) end if % using the arrow keys instead of numbers if chars (chr (205)) and e + 80 < maxx then delay (10) e += 5 cls end if if chars (chr (203)) and abs (e - w) not= 95 then delay (10) e -= 5 cls end if % check to see if the health is at zero, % if it is, it display the ending, % and the game ends if health1 <= 45 then Pic.Draw (superback, 0, 0, 2) Pic.Draw (dragonsign, 220, 100, 2) Font.Draw ("K.O.", 280, 200, font2, yellow) View.Update fork dragonroar exit end if if health2 <= 395 then Font.Draw ("K.O.", 280, 200, font2, yellow) View.Update fork tigerroar exit end if % check the special bar variable, % if it is over or equal to 150, % then it uses the special move if special1 >= 200 then cls hyperscreen (red) cls View.Update delay (1000) fork tigerroar jackiesuper % resetting the special value, % and subtracting the other player's health special1 := 50 health2 -= 30 end if % samething for this one if special2 >= 550 then cls hyperscreen (green) cls View.Update delay (1000) fork dragonroar brucesuper special2 := 400 health1 -= 30 end if end loop this game is for my computer final project``but i need to change some programs i need to add a clock on it when they start to finght and there's a time limit, i don't know how to add those things on~can anybody help me with it? waiting for your reply! |