| 
%Sun Fighters! V1.5
 %"Last updated ", (theDayYouReadThis - theDatelastEdited), " days ago by Drew Martell"
 
 %VARIABLES
 var var1, var2, c1, c2, sun, back, ground, face, cnt, sx, sy, line, sunx, suny, file, score1, score2, size, x : int
 score1 := 0
 score2 := 0
 cnt := 0
 var timeElapsed, scoreS1, scoreS2, speedS, msg, bestTime : string
 var ch : char
 var timer := Font.New ("@Terminal:10")
 var rec := "Sun Fighter's Best Time.rec"
 var ballx1, bally1, ballx2, bally2, vx1, vy1, vx2, vy2, gravity, speed, subSpeed : real
 var keys : array char of boolean
 
 open : file, rec, put, mod
 close : file
 File.Status (rec, size, x, x)
 if (size = 0) then
 open : file, rec, put, mod
 put : file, "0"
 close : file
 end if
 
 procedure Reset
 open : file, rec, get
 get : file, msg
 close : file
 bestTime := msg
 cnt := 0
 c1 := yellow
 c2 := 11
 sun := brightred
 back := black
 ground := back + 1
 face := black
 line := 50
 ballx1 := line + maxx - 100
 bally1 := line
 ballx2 := line + maxx - 150
 bally2 := line
 vx1 := 5
 vy1 := 10
 vx2 := 5
 vy2 := 10
 gravity := .25
 sunx := 100
 suny := 100
 sx := 1
 sy := 1
 speed := 15
 subSpeed := .01
 end Reset
 
 procedure Pause
 View.Update
 Input.Flush
 delay (500)
 Input.Flush
 Input.Pause
 end Pause
 
 procedure Intro
 Reset
 View.Set ("title:Sun Fighters, nocursor")
 var title := Font.New ("@Terminal:40")
 drawfillbox (0, 0, maxx, maxy, blue)
 Font.Draw ("Sun Fighters!!!", 160, 280, title, brightred)
 colourback (blue)
 colour (white)
 locate (12, 14)
 put "This is a 1 or 2 player game in which you must dodge the"
 locate (13, 20)
 put "red hot sun from melting your ass. Have fun!"
 locate (16, 38)
 put "--------------"
 locate (17, 38)
 put "// CONTROLS //"
 locate (18, 38)
 put "--------------"
 locate (21, 10)
 colour (yellow)
 put "1P:   Left arrow key moves left    Right arrow key moves right"
 locate (22, 10)
 colour (11)
 put "2P:        'a' moves left               'd' moves right"
 drawbox (50, 30, maxx - 50, maxy - 30, white)
 locate (maxrow, 22)
 colour (brightgreen)
 put "Press 1 or 2 for the ammount of players"
 View.Update
 Input.Flush
 delay (500)
 Input.Flush
 ch := getchar
 if ~ ((ch = '1') or (ch = '2')) then
 Intro
 end if
 end Intro
 
 procedure Save
 bestTime := msg
 open : file, rec, get
 get : file, msg
 close : file
 if (strint (timeElapsed)) > (strint (msg)) then
 open : file, rec, put, mod
 put : file, timeElapsed
 close : file
 end if
 end Save
 
 procedure Player1
 drawfilloval (round (ballx1), round (bally1), 10, 10, c1)     %body
 drawoval (round (ballx1), round (bally1), 10, 10, face)     %body outline
 drawfilloval (round (ballx1) - 3, round (bally1) + 2, 1, 1, face)     %left eye
 drawfilloval (round (ballx1) + 3, round (bally1) + 2, 1, 1, face)     %right eye
 drawfillarc (round (ballx1), round (bally1) - 2, 2, 4, 180, 360, face)     %smile
 end Player1
 
 procedure Player2
 drawfilloval (round (ballx2), round (bally2), 10, 10, c2)     %body
 drawoval (round (ballx2), round (bally2), 10, 10, face)     %body outline
 drawfilloval (round (ballx2) - 3, round (bally2) + 2, 1, 1, face)     %left eye
 drawfilloval (round (ballx2) + 3, round (bally2) + 2, 1, 1, face)     %right eye
 drawfillarc (round (ballx2), round (bally2) - 2, 2, 4, 180, 360, face)     %smile
 end Player2
 
 procedure Sun
 drawfilloval (round (sunx), round (suny), 100, 100, sun)     %sun body
 drawfilloval (round (sunx) - 40, round (suny) + 30, 10, 10, face)     %left eye
 drawfilloval (round (sunx) + 40, round (suny) + 30, 10, 10, face)     %right eye
 drawfillarc (round (sunx), round (suny) - 2, 80, 80, 180, 360, face)     %smile
 drawoval (round (sunx), round (suny), 100, 100, face)     %sun outline
 end Sun
 
 proc Main
 View.Set ("offscreenonly")
 Reset
 loop
 scoreS1 := intstr (score1)
 scoreS2 := intstr (score2)
 timeElapsed := intstr (cnt div 50)
 speedS := realstr (speed, 0)
 cnt += 1
 
 %Painting
 drawfillbox (0, 0, maxx, maxy, back)     %background
 drawfillbox (0, 0, maxx, line, ground)     %floor
 Font.Draw ("Player 1: " + scoreS1, 10, 20, timer, c1)
 Font.Draw ("Player 2: " + scoreS2, 110, 20, timer, c2)
 Font.Draw ("TIME:" + timeElapsed, maxx - 170, 20, timer, sun)
 Font.Draw ("BEST:" + bestTime, maxx - 100, 20, timer, black)
 Font.Draw ("SPEED:" + speedS, (maxx div 2) - 50, 20, timer, back)
 Player1
 Player2
 Sun
 
 %Variables changing
 ballx1 += vx1
 bally1 += vy1
 ballx2 += vx2
 bally2 += vy2
 sunx += sx
 suny += sy
 vy1 -= gravity
 vy2 -= gravity
 
 %Boundaries
 if vy1 = -10 then
 vy1 := 10 - gravity
 end if
 if vy2 = -10 then
 vy2 := 10 - gravity
 end if
 
 if ballx1 + 15 >= maxx then
 ballx1 -= 1
 vx1 *= -1
 end if
 if ballx2 + 15 >= maxx then
 ballx2 -= 1
 vx2 *= -1
 end if
 
 if ballx1 <= 0 then
 ballx1 += 1
 vx1 *= -1
 end if
 if ballx2 <= 0 then
 ballx2 += 1
 vx2 *= -1
 end if
 
 if suny = 100 or suny = maxy - 100 then
 sy := -sy
 elsif (sunx = 100) or (sunx = maxx - 100) then
 sx := -sx
 end if
 
 %Controlls
 Input.KeyDown (keys)
 if keys (KEY_RIGHT_ARROW) then
 vx1 += 1
 speed -= subSpeed
 end if
 if keys (KEY_LEFT_ARROW) then
 vx1 -= 1
 speed -= subSpeed
 end if
 
 if (ch = '2') then
 if keys ('d') then
 vx2 += 1
 speed -= subSpeed
 end if
 if keys ('a') then
 vx2 -= 1
 speed -= subSpeed
 end if
 end if
 
 %Player/Player collision
 if (whatdotcolour (round (ballx1), round (bally1)) = c2) then
 end if
 if (whatdotcolour (round (ballx2), round (bally2)) = c1) then
 end if
 
 %Sun collision detection
 colourback (back)
 colour (white)
 locate (3, 23)
 if (ch = '2') then
 if (whatdotcolour (round (ballx2), round (bally2)) = sun) then
 put "Player 1 Wins! Press any key to continue..."
 score1 += 1
 Save
 Pause
 Intro
 end if
 end if
 if (whatdotcolour (round (ballx1), round (bally1)) = sun) then
 put "Player 2 Wins! Press any key to continue..."
 score2 += 1
 Save
 Pause
 Intro
 end if
 View.Update
 delay (round (speed))
 speed -= .0025
 end loop
 end Main
 
 Intro
 Main
 
 |