Computer Science Canada Frogger |
Author: | WhatAmIDoing [ Mon Mar 08, 2004 12:22 pm ] |
Post subject: | Frogger |
ok guys this is my greatest game of all time frogger. only no pics i used turing based shapes to do this. this is a long one but i can't make exe files at school import GUI setscreen ("graphics:800;500,nobuttonbar,title:Frogger") var win, cd : boolean := false var music : boolean := true var x, y, f, s : int var chars : array char of boolean var font, font2 : int var a, b, a2, b2, a3, b3, a4, b4, a5, b5, a6, b6, c : int var a7, b7, a8, b8, a9, b9, a10, b10, a11, b11, a12, b12 : int var level : int := 1 var score, score2 : int := 0 var name, answer : string var Delay : int := 30 var lives, timer := 10 var window : int := Window.GetSelect font := Font.New ("comic sans ms:50") font2 := Font.New ("comic sans ms:15") process song loop if music = false then Music.SoundOff end if if music = true and cd = false then randint (f, 1, 4) if f = 1 then Music.PlayFile ("Faint.wav") elsif f = 2 then Music.PlayFile ("cd:5") elsif f = 3 then Music.PlayFile ("Smells.wav") elsif f = 4 then Music.PlayFile ("blah.wav") end if end if if music = true and cd = true then randint (s, 1, 10) if s = 1 then Music.PlayFile ("cd:1") elsif s = 2 then Music.PlayFile ("cd:2") elsif s = 3 then Music.PlayFile ("cd:3") elsif s = 4 then Music.PlayFile ("cd:4") elsif s = 5 then Music.PlayFile ("cd:5") elsif s = 6 then Music.PlayFile ("cd:6") elsif s = 7 then Music.PlayFile ("cd:7") elsif s = 8 then Music.PlayFile ("cd:8") elsif s = 9 then Music.PlayFile ("cd:9") elsif s = 10 then Music.PlayFile ("cd:10") end if end if end loop end song procedure Game drawfillbox (0, 0, maxx, maxy, black) drawfillbox (0, maxy - 20, maxx, maxy, white) drawfillbox (maxx - 300, 0, maxx, 150, blue) Font.Draw ("FINISH", maxx div 2, maxy - 20, font2, brightblue) Font.Draw (name, 700, 130, font2, white) Font.Draw ("Lives:", 500, 20, font2, white) Font.Draw (intstr (lives), 575, 20, font2, white) Font.Draw ("LVL:", 500, 110, font2, white) Font.Draw (intstr (level), 575, 110, font2, white) Font.Draw ("Score:", 500, 70, font2, white) Font.Draw (intstr (score), 575, 70, font2, white) x := maxx div 2 y := 10 win := false var fileNo : int if level > 30 then cls drawfillbox (0, 0, maxx, maxy, 7) Font.Draw ("YOU WIN", maxx div 2 - 400, maxy - 300, font, magenta) delay (2000) %high scores open : fileNo, "High Scores", read, write, mod, seek assert fileNo > 0 cls drawfillbox (0, 0, maxx, maxy, 7) Font.Draw ("High Scores", 200, maxy - 50, font, brightgreen) colorback (black) color (white) locatexy (maxx div 2 - 300, maxy div 2 + 150) put "Name" : 10, "Level" : 10, "Score" : 10 locatexy (maxx div 2 - 300, maxy div 2 + 190) put "----" : 10, "-----" : 10, "-----" : 10 seek : fileNo, * write : fileNo, name, level, score locatexy (maxx div 2 - 300, maxy div 2 + 130) put name : 10, level : 5, score : 10 close : fileNo delay (5000) quit elsif lives = 0 then cls drawfillbox (0, 0, maxx, maxy, 7) Font.Draw ("YOU Lose", maxx div 2 - 300, maxy - 300, font, magenta) delay (2000) drawfillbox (0, 0, maxx, maxy, 7) Font.Draw ("High Scores", 200, maxy - 50, font, brightgreen) colorback (black) color (white) locatexy (maxx div 2 - 300, maxy div 2 + 180) open : fileNo, "High Scores", read, write, mod, seek assert fileNo > 0 put "Name" : 10, "Level" : 10, "Score" : 10 locatexy (maxx div 2 - 300, maxy div 2 + 190) put "----" : 10, "-----" : 10, "-----" : 10 seek:fileNo, * write : fileNo, name, level, score locatexy (maxx div 2 - 300, maxy div 2 + 150) put name : 10, level : 5, score : 10 close : fileNo delay (6000) quit end if if level >= 10 then Delay := 15 %starting co-ord for 1st line randint (a, 100, maxx div 2) randint (b, 150, maxy - 100) %starting co-ord for 2nd line randint (a2, -1000, 10) randint (b2, 150, maxy - 100) %starting co-ord for 3rd line randint (a3, -1000, 10) randint (b3, 150, maxy - 100) %starting co-ord for 4th line randint (a4, -500, 10) randint (b4, 150, maxy - 100) %starting co-ord for 5th line randint (a5, -150, 0) randint (b5, 150, maxy - 100) %starting co-ord for 6th line randint (a6, -2000, 10) randint (b6, 150, maxy - 100) %OTHER WAY %starting co-ord for 1st line randint (a7, maxx - 150, maxx) randint (b7, 150, maxy - 100) %starting co-ord for 2nd line randint (a8, maxx + 1000, maxx + 5000) randint (b8, 150, maxy - 100) %starting co-ord for 3rd line randint (a9, maxx, maxx + 1000) randint (b9, 150, maxy - 100) %starting co-ord for 4th line randint (a10, maxx + 500, maxx + 1000) randint (b10, 150, maxy - 100) %starting co-ord for 5th line randint (a11, maxx div 2, maxx) randint (b11, 150, maxy - 100) %starting co-ord for 6th line randint (a12, maxx, maxx + 2000) randint (b12, 150, maxy - 100) loop colorback (blue) color (white) %move square Input.KeyDown (chars) if chars (KEY_UP_ARROW) then y += 10 elsif chars (KEY_DOWN_ARROW) then y -= 10 elsif chars (KEY_LEFT_ARROW) then x -= 10 elsif chars (KEY_RIGHT_ARROW) then x += 10 elsif chars ('n') then randint (s, 1, 10) fork song end if %winning if y > maxy - 20 then win := true exit %can't go off screen elsif x > maxx - 350 and y < 175 then x := 0 elsif y > 175 and x > maxx then x := 0 elsif x < 0 and y < 175 then x := maxx - 350 elsif y > 175 and x < 10 then x := maxx elsif y < 5 then y := 5 end if % losing if x > a - 30 and x < a + 30 and y > b - 15 and y < b + 15 then win := false exit elsif x > a2 - 90 and x < a2 + 30 and y > b2 - 15 and y < b2 + 15 then win := false exit elsif x > a3 - 90 and x < a3 + 30 and y > b3 - 15 and y < b3 + 15 then win := false exit elsif x > a4 - 90 and x < a4 + 30 and y > b4 - 15 and y < b4 + 15 then win := false exit elsif x > a5 - 90 and x < a5 + 30 and y > b5 - 15 and y < b5 + 15 then win := false exit elsif x > a6 - 90 and x < a6 + 30 and y > b6 - 15 and y < b6 + 15 then win := false exit elsif x > a7 - 30 and x < a7 + 90 and y > b7 - 15 and y < b7 + 15 then win := false exit elsif x > a8 - 30 and x < a8 + 90 and y > b8 - 15 and y < b8 + 15 then win := false exit elsif x > a9 - 30 and x < a9 + 90 and y > b9 - 15 and y < b9 + 15 then win := false exit elsif x > a10 - 30 and x < a10 + 90 and y > b10 - 15 and y < b10 + 15 then win := false exit elsif x > a11 - 30 and x < a11 + 90 and y > b11 - 15 and y < b11 + 15 then win := false exit elsif x > a12 - 30 and x < a12 + 90 and y > b12 - 15 and y < b12 + 15 then win := false exit end if %draws square drawfillbox (x, y, x + 10, y + 10, white) delay (Delay) drawfillbox (x + 15, y, x + 10, y + 10, black) drawfillbox (x - 15, y, x + 10, y + 10, black) drawfillbox (x, y + 15, x + 10, y + 10, black) drawfillbox (x, y - 15, x + 10, y + 10, black) randint (c, 0, maxcolor) %moves and draws 1st line a += 5 drawfilloval (a, b, 5, 5, c) drawfilloval (a - 90, b, 5, 5, black) drawfilloval (a + 10, b, 5, 5, black) %moves and draws 2nd line a2 += 15 drawfilloval (a2, b2, 5, 5, c) drawfilloval (a2 - 90, b2, 5, 5, black) drawfilloval (a2 + 10, b2, 5, 5, black) %moves and draws 3rd line a3 += 15 drawfilloval (a3, b3, 5, 5, c) drawfilloval (a3 - 90, b3, 5, 5, black) drawfilloval (a3 + 10, b3, 5, 5, black) %moves and draws 4th line a4 += 15 drawfilloval (a4, b4, 5, 5, c) drawfilloval (a4 - 90, b4, 5, 5, black) drawfilloval (a4 + 10, b4, 5, 5, black) %moves and draws 5th line a5 += 30 drawfilloval (a5, b5, 5, 5, c) drawfilloval (a5 - 90, b5, 5, 5, black) drawfilloval (a5 + 10, b5, 5, 5, black) %moves and draws 6th line a6 += 15 drawfilloval (a6, b6, 5, 5, c) drawfilloval (a6 - 90, b6, 5, 5, black) drawfilloval (a6 + 10, b6, 5, 5, black) %moves and draws 7th line a7 -= 5 drawfilloval (a7, b7, 5, 5, c) drawfilloval (a7 + 90, b7, 5, 5, black) drawfilloval (a7 - 10, b7, 5, 5, black) %moves and draws 8th line a8 -= 15 drawfilloval (a8, b8, 5, 5, c) drawfilloval (a8 + 90, b8, 5, 5, black) drawfilloval (a8 - 10, b8, 5, 5, black) %moves and draws 9th line a9 -= 30 drawfilloval (a9, b9, 5, 5, c) drawfilloval (a9 + 90, b9, 5, 5, black) drawfilloval (a9 - 10, b9, 5, 5, black) %moves and draws 10th line a10 -= 15 drawfilloval (a10, b10, 5, 5, c) drawfilloval (a10 + 90, b10, 5, 5, black) drawfilloval (a10 - 10, b10, 5, 5, black) %moves and draws 11th line a11 -= 15 drawfilloval (a11, b11, 5, 5, c) drawfilloval (a11 + 90, b11, 5, 5, black) drawfilloval (a11 - 10, b11, 5, 5, black) %moves and draws 12th line a12 -= 15 drawfilloval (a12, b12, 5, 5, c) drawfilloval (a12 + 90, b12, 5, 5, black) drawfilloval (a12 - 10, b12, 5, 5, black) if a > maxx + 90 then a := -10 elsif a2 > maxx + 90 then a2 := -10 elsif a3 > maxx + 90 then a3 := -10 elsif a4 > maxx + 90 then a4 := -10 elsif a5 > maxx + 90 then a5 := -10 elsif a6 > maxx + 90 then a6 := -10 elsif a7 < -90 then a7 := maxx elsif a8 < -90 then a8 := maxx elsif a9 < -90 then a9 := maxx elsif a10 < -90 then a10 := maxx elsif a11 < -90 then a11 := maxx elsif a12 < -90 then a12 := maxx end if end loop elsif level < 10 and level > 0 and timer >= 0 then %starting co-ord for 1st line randint (a, 100, maxx div 2) randint (b, 150, maxy - 100) %starting co-ord for 2nd line randint (a2, -1000, 10) randint (b2, 150, maxy - 100) %starting co-ord for 3rd line randint (a3, -500, 10) randint (b3, 150, maxy - 100) %starting co-ord for 4th line randint (a4, 1, 10) randint (b4, 150, maxy - 100) %starting co-ord for 5th line randint (a5, -5000, -1000) randint (b5, 150, maxy - 100) %starting co-ord for 6th line randint (a6, -50, 100) randint (b6, 150, maxy - 100) loop colorback (blue) color (white) %move square Input.KeyDown (chars) if chars (KEY_UP_ARROW) then y += 10 elsif chars (KEY_DOWN_ARROW) then y -= 10 elsif chars (KEY_LEFT_ARROW) then x -= 10 elsif chars (KEY_RIGHT_ARROW) then x += 10 elsif chars ('n') then randint (s, 1, 10) fork song end if %winning if y > maxy - 20 then win := true exit %can't go off screen elsif x > maxx - 350 and y < 175 then x := 0 elsif y > 175 and x > maxx then x := 0 elsif x < 0 and y < 175 then x := maxx - 350 elsif y > 175 and x < 0 then x := maxx elsif y < 0 then y := 10 end if % losing if x > a - 90 and x < a + 30 and y > b - 15 and y < b + 15 then win := false exit elsif x > a2 - 90 and x < a2 + 30 and y > b2 - 15 and y < b2 + 15 then win := false exit elsif x > a3 - 90 and x < a3 + 30 and y > b3 - 15 and y < b3 + 15 then win := false exit elsif x > a4 - 90 and x < a4 + 30 and y > b4 - 15 and y < b4 + 15 then win := false exit elsif x > a5 - 90 and x < a5 + 30 and y > b5 - 15 and y < b5 + 15 then win := false exit elsif x > a6 - 90 and x < a6 + 30 and y > b6 - 15 and y < b6 + 15 then win := false exit end if %draws square drawfillbox (x, y, x + 10, y + 10, white) delay (Delay) drawfillbox (x + 15, y, x + 10, y + 10, black) drawfillbox (x - 15, y, x + 10, y + 10, black) drawfillbox (x, y + 15, x + 10, y + 10, black) drawfillbox (x, y - 15, x + 10, y + 10, black) randint (c, 0, maxcolor) %moves and draws 1st line a += 5 drawfilloval (a, b, 5, 5, c) drawfilloval (a - 90, b, 5, 5, black) drawfilloval (a + 10, b, 5, 5, black) %moves and draws 2nd line a2 += 15 drawfilloval (a2, b2, 5, 5, c) drawfilloval (a2 - 90, b2, 5, 5, black) drawfilloval (a2 + 10, b2, 5, 5, black) %moves and draws 3rd line a3 += 15 drawfilloval (a3, b3, 5, 5, c) drawfilloval (a3 - 90, b3, 5, 5, black) drawfilloval (a3 + 10, b3, 5, 5, black) %moves and draws 4th line a4 += 15 drawfilloval (a4, b4, 5, 5, c) drawfilloval (a4 - 90, b4, 5, 5, black) drawfilloval (a4 + 10, b4, 5, 5, black) %moves and draws 5th line a5 += 15 drawfilloval (a5, b5, 5, 5, c) drawfilloval (a5 - 90, b5, 5, 5, black) drawfilloval (a5 + 10, b5, 5, 5, black) %moves and draws 6th line a6 += 30 drawfilloval (a6, b6, 5, 5, c) drawfilloval (a6 - 90, b6, 5, 5, black) drawfilloval (a6 + 10, b6, 5, 5, black) if a > maxx + 90 then a := -10 elsif a2 > maxx + 90 then a2 := -10 elsif a3 > maxx + 90 then a3 := -10 elsif a4 > maxx + 90 then a4 := -10 elsif a5 > maxx + 90 then a5 := -10 elsif a6 > maxx + 90 then a6 := -10 end if end loop end if if win = true then cls drawfillbox (0, 0, maxx, maxy, black) Font.Draw ("You win!! Next LVL", maxx div 2 - 300, maxy div 2, font, brightgreen) var NextButton := GUI.CreateButton (100, 200, 0, "Next LVL", Game) var QuitButton := GUI.CreateButton (100, 100, 0, "QUIT", GUI.Quit) GUI.SetDefault (NextButton, true) level += 1 Delay -= 2 score += 10 score2 := score if score2 = 50 then score2 := 0 lives += 1 end if elsif win = false then cls drawfillbox (0, 0, maxx, maxy, black) Font.Draw ("You lose!! Try again", maxx div 2 - 300, maxy div 2, font, brightgreen) var TryButton := GUI.CreateButton (100, 200, 0, "TRY AGAIN", Game) var QuitButton := GUI.CreateButton (100, 100, 0, "QUIT", GUI.Quit) GUI.SetDefault (TryButton, true) score -= 5 lives -= 1 end if end Game delay (100) drawfillbox (0, 0, maxx, maxy, 7) colorback (black) color (white) loop put "Enter your Name: " .. get name : * if length (name) > 9 then put "That name is too long try again!" elsif length (name) < 2 then put "That name is too short try again!" end if exit when length (name) < 9 and length (name) > 2 end loop loop put "Sound on/off: " .. get answer if answer = "On" or answer = "on" then music := true elsif answer = "Off" or answer = "off" then music := false else put "On/Off" end if exit when answer = "On" or answer = "on" or answer = "Off" or answer = "off" end loop loop put "Soundtrack-game or own: " .. get answer if answer = "Game" or answer = "game" then cd := false elsif answer = "Own" or answer = "own" then cd := true put "Enter a cd to play from" put "Push the 'n' key to change songs" delay (1000) else put "On/Off" end if exit when answer = "Game" or answer = "game" or answer = "Own" or answer = "own" end loop colorback (blue) color (white) fork song Game loop exit when GUI.ProcessEvent end loop var fileNo : int %high scores open : fileNo, "High Scores", read, write, mod, seek assert fileNo > 0 cls drawfillbox (0, 0, maxx, maxy, 7) Font.Draw ("High Scores", 200, maxy - 50, font, brightgreen) colorback (black) color (white) locatexy (maxx div 2 - 300, maxy div 2 + 200) put "Name" : 10, "Level" : 10, "Score" : 10 locatexy (maxx div 2 - 300, maxy div 2 + 190) put "----" : 10, "-----" : 10, "-----" : 10 seek : fileNo, * write : fileNo, name, level, score locatexy (maxx div 2 - 300, maxy div 2 + 180) put name : 10, level : 5, score : 10 close : fileNo |
: |