My Code :var Name : string
put "Please enter your name (7 characters or less) : " ..
get Name
View.Set ("graphics:1000;500,buttonbar,offscreenonly")
var BoxX1, BoxX2, BoxY1, BoxY2, BallRadius, move, BallRand, Color, font1, font2, font5, font3, font4, font6, font0, font10, font11 : int
var BallPlayerX, BallPlayerY, BallPlayerRadius : int
BallPlayerX := maxx div 2
BallPlayerY := maxy div 10
BallPlayerRadius := 4
var chars : array char of boolean
var Timme : string
var chars1, chars2 : char
var Timer : int := 35
var timee : int := 0
var StringTimer : string
BoxX1 := maxx div 2
BoxX2 := maxx div 2.1
BoxY1 := maxy div 10
BoxY2 := maxy div 8
BallRadius := 12
move := 1
BallRand := Rand.Int (10, 1000)
Color := brightred
font0 := Font.New ("Comic Sans :45:bold,underline")
font1 := Font.New ("Batang:30:bold,underline")
font2 := Font.New ("Comic Sans:10:bold,underline")
font10 := Font.New ("Bookman Old Style :12")
font3 := Font.New ("Comic Sans :30:bold")
font11 := Font.New ("Comic Sans :30:bold,underline")
font4 := Font.New ("Comic Sans:20:bold,underline")
font5 := Font.New ("Comic Sans:10:bold")
font6 := Font.New ("Iskoola Pota:15:bold,underline")
BallRadius := 12
var BallX : array 1 .. 100 of int % Array of 10 Balls for x position
var BallY : array 1 .. 100 of int % Array of 10 Balls, for y position
var Ball2X : array 1 .. 100 of int
var Ball2Y : array 1 .. 100 of int
var NumBall : int := 1
var NumBall2 : int := 1
var timeofaction : int := Time.Elapsed
randint (BallX (NumBall), 0, maxx) %X Position
randint (BallY (NumBall), 0, maxy) %Y Position
randint (Ball2X (NumBall2), 0, maxx) %X Position for second level
randint (Ball2Y (NumBall2), 0, maxy) %Y Position for second level
var BallXV : array 1 .. 100 of int
BallXV (1) := -1
var Ball2XV : array 1 .. 100 of int
var Ball2YV : array 1 .. 100 of int
Ball2XV (1) := -1
Ball2YV (1) := 1
var LifeCounter : int := 3
var CollisionCheck : real
var ColorBall : int := 31
var Box1c, Box2c, Box3c : int
Box1c := 12
Box2c := 12
Box3c := 12
var Box1c2, Box2c2, Box3c2 : int
Box1c2 := 12
Box2c2 := 12
Box3c2 := 12
var Box1c3, Box2c3, Box3c3 : int
Box1c3 := 12
Box2c3 := 12
Box3c3 := 12
var GameLost : boolean := true
var ColorText3 : int := 12
var ColorText1 : int := 12
var ColorText2 : int := 12
proc Controls
loop
var MouseX, MouseY, Click : int
drawfillbox (0, 0, maxx, maxy, 79)
Font.Draw ("Controls", maxx div 7, maxy div 1.13, font11, red)
Font.Draw ("The controls are rather simple: Use the cursor keys to move.", 100, 401, font10, red)
Font.Draw ("Avoid any bouncing balls as you will lose one of your 3 lives If you are hit, you will be placed in the middle of the screen.", 100, 351, font10, red)
Font.Draw ("Reach The prescribed amount of time for each level and you will progress into harder levels.", 100, 301, font10, red)
Font.Draw ("If you progress into the third level, you will gain the ability to shoot, at which point the 'S' will be the shoot button.", 100, 251, font10, red)
Font.Draw ("After you lose, you must exit the game for the rules are as such.", 100, 201, font10, red)
Font.Draw ("Hint : If you wish to cheat , press and hold 'G' for immunity.", 100, 151, font10, red)
Font.Draw (" Start ", maxx div 2.3, maxy div 13, font10, ColorText3)
Draw.Box (maxx div 2.3 - 10, maxy div 13 - 10, maxx div 2, maxy div 11 + 15, white)
Mouse.Where (MouseX, MouseY, Click)
if MouseY <= 51 and 37 <= MouseY and MouseX <= 471 and MouseX >= 438 then
ColorText3 := blue
else
ColorText3 := 12
View.Update
end if
if ColorText3 = blue and Click = 1
then
exit
end if
View.Update
cls
end loop
end Controls
procedure GameMenu %Creates Game Menu
loop
var MouseX, MouseY, Click : int
drawfillbox (0, 0, maxx, maxy, 99)
Font.Draw ("One Chance to Survive.", maxx div 4.7, maxy div 2, font1, red)
Draw.Box (maxx div 4.7 - 20, maxy div 2 - 20, maxx div 1.35 + 20, maxy div 1.75 + 20, white)
Font.Draw ("Start ", maxx div 2, maxy div 4, font6, ColorText1)
Draw.Box (maxx div 2 - 10, maxy div 4 - 10, maxx div 1.8, maxy div 3.6, white)
Font.Draw ("To View Controls", maxx div 2, maxy div 6, font6, ColorText2)
Draw.Box (maxx div 2 - 10, maxy div 6 - 10, maxx div 1.5, maxy div 4.5, white)
Mouse.Where (MouseX, MouseY, Click)
if MouseY <= 109 and 76 <= MouseY and MouseX <= 661 and MouseX >= 497 then
ColorText2 := blue
else
ColorText2 := 12
end if
if Click = 1 and ColorText2 = 12
then
exit
end if
if MouseY <= 142 and 119 <= MouseY and MouseX <= 552 and MouseX >= 497 then
ColorText1 := blue
else
ColorText1 := 12
end if
if Click = 1 and ColorText1 = 12 then
Controls
exit
end if
View.Update
cls
end loop
end GameMenu
var Bulletx, Bullety : int
Bulletx := maxx div 2.05
Bullety := maxy div 9
GameMenu
var reset : boolean := true
var LifeCounter3 : int := 3
%proc Background
% drawfillbox (0, 0, maxx, maxy, 149)
%end Background
var Bulletshot : boolean := false
var Balldirx : flexible array 1 .. 1000 of int
var Balldiry : flexible array 1 .. 1000 of int
Balldirx (1) := -1
Balldiry (1) := 1
var Ballx : flexible array 1 .. 1000 of int
var Bally : flexible array 1 .. 1000 of int
randint (Ballx (NumBall2), 0, maxx)
randint (Bally (NumBall2), 0, maxy)
var NumBall3 : int := 1
var BeginCounter : int := 1
proc Starting
drawfillbox (0, 0, maxx, maxy, 149)
drawfillbox (BoxX1, BoxY1, BoxX2, BoxY2, Color)
Font.Draw ("Score: ", maxx div 1.17, maxy div 1.05, font6, 31)
Font.Draw (" 0", maxx div 1.09, maxy div 1.05, font6, 31)
Font.Draw ("Lives", 30, maxy div 1.05, font2, 31)
Font.Draw (" :", 30, maxy div 1.05, font5, 31)
% Font.Draw ("Player : ", 180, maxy div 1.1, font1, 31)
Font.Draw (Name, maxx div 1.09, maxy div 1.1, font6, 31)
Draw.Box (10, maxy div 1.12, 140, maxy, white)
drawfillbox (85, 475, 95, 480, 12) %1st
drawfillbox (105, 475, 115, 480, 12) %2nd
drawfillbox (125, 475, 135, 480, 12) %3rd
Font.Draw ("3.. ", 200, maxy div 1.1, font3, white)
View.Update
delay (150)
Font.Draw (".. 2..", 300, maxy div 1.1, font3, white)
View.Update
delay (150)
Font.Draw (".. 1..", 400, maxy div 1.1, font3, white)
View.Update
delay (150)
Font.Draw (".. Go! ", 500, maxy div 1.1, font3, white)
View.Update
delay (150)
View.Update
BeginCounter := BeginCounter + 1
end Starting
var LifeCounter2 : int := 3
proc Background1
drawfillbox (0, 0, maxx, maxy, 149)
drawfillbox (BoxX1, BoxY1, BoxX2, BoxY2, Color)
Font.Draw ("Score: ", maxx div 1.17, maxy div 1.05, font6, 31)
Font.Draw ("Lives", 30, maxy div 1.05, font2, 31)
Font.Draw (" :", 30, maxy div 1.05, font5, 31)
Font.Draw (Name, maxx div 1.09, maxy div 1.1, font6, 31)
Draw.Box (10, maxy div 1.12, 140, maxy, white)
drawfillbox (85, 475, 95, 480, Box1c) %1st
drawfillbox (105, 475, 115, 480, Box2c) %2nd
drawfillbox (125, 475, 135, 480, Box3c) %3rd
end Background1
var HighScore : int
var MouseX, MouseY, Click : int
var Level1, Level2, Level3 : boolean
Level1 := true
Level2 := false
Level3 := false
var resetgame : boolean := true
var resetgame1 : boolean := true
loop
Background1
if BeginCounter = 1 then
Starting
end if
timeofaction := Time.Elapsed
Timme := intstr (timeofaction, 1)
Font.Draw (Timme, maxx div 1.09, maxy div 1.05, font6, 31)
%drawfilloval (BallPlayerX, BallPlayerY, BallPlayerRadius, BallPlayerRadius, Color)
%First Level
if timeofaction <= 35000 then
for d : 1 .. NumBall
drawfilloval (BallX (d), BallY (d), BallRadius, BallRadius, ColorBall)
BallX (d) := BallX (d) + BallXV (d)
if BallX (d) = maxx - BallRadius
then
NumBall := NumBall + 1
BallXV (NumBall) := -1
randint (BallX (NumBall), 0, maxx) %X Position
randint (BallY (NumBall), 0, maxy) %Y Position
BallXV (d) := -1
elsif
BallX (d) = BallRadius
then
BallXV (d) := 1
end if
if NumBall = 35
then
NumBall := 34
end if
if Color = brightred and BoxX2 <= BallX (d) + BallRadius and BoxX1 >= BallX (d) - BallRadius and BoxY1 <= BallY (d) + BallRadius and BoxY2 >= BallY (d) - BallRadius
then
drawfillbox (BoxX1, BoxY1, BoxX2, BoxY2, 12)
BoxX1 := maxx div 2
BoxX2 := maxx div 2.1
BoxY1 := maxy div 10
BoxY2 := maxy div 8
delay (200)
LifeCounter := LifeCounter - 1
if LifeCounter = 2
then
Box3c := 149
end if
if LifeCounter = 1
then
Box2c := 149
end if
if LifeCounter = 0
then
Box1c := 149
end if
end if
end for
if LifeCounter <= 0
then
GameLost := false
% reset := false
HighScore := timeofaction
end if
elsif timeofaction > 35000 and timeofaction <= 55000 and BeginCounter = 2
then
Starting
Level2 := true
elsif timeofaction > 35000 and timeofaction <= 55000
then
%NextLevel
if Level2 = true then
drawfillbox (85, 475, 95, 480, Box1c2) %1st
drawfillbox (105, 475, 115, 480, Box2c2) %2nd
drawfillbox (125, 475, 135, 480, Box3c2) %3rd
for j : 1 .. NumBall2
drawfillbox (BoxX1, BoxY1, BoxX2, BoxY2, Color)
drawfilloval (Ball2X (j), Ball2Y (j), BallRadius, BallRadius, ColorBall)
Ball2X (j) := Ball2X (j) + Ball2XV (j)
if Ball2X (j) - BallRadius = BallRadius
then
Ball2XV (j) := Ball2XV (j) * -1
elsif Ball2X (j) + BallRadius >= maxx - BallRadius
then
Ball2XV (j) := Ball2XV (j) * -1
NumBall2 := NumBall2 + 1
randint (Ball2X (NumBall2), 0, maxx) %X Position
randint (Ball2Y (NumBall2), 0, maxy) %Y Position
Ball2YV (NumBall2) := 1
Ball2XV (NumBall2) := -1
end if
Ball2Y (j) := Ball2Y (j) + Ball2YV (j)
if Ball2Y (j) = maxy - BallRadius
then
Ball2YV (j) := -1 * Ball2YV (j)
elsif Ball2Y (j) <= BallRadius
then
Ball2YV (j) := 1
end if
if NumBall2 = 35
then
NumBall2 := 34
end if
if Color = brightred and BoxX2 <= Ball2X (j) + BallRadius and BoxX1 >= Ball2X (j) - BallRadius and BoxY1 <= Ball2Y (j) + BallRadius and BoxY2 >= Ball2Y (j) - BallRadius
then
drawfillbox (BoxX1, BoxY1, BoxX2, BoxY2, 12)
BoxX1 := maxx div 2
BoxX2 := maxx div 2.1
BoxY1 := maxy div 10
BoxY2 := maxy div 8
delay (200)
LifeCounter2 := LifeCounter2 - 1
if LifeCounter2 = 2
then
Box3c2 := 149
drawfillbox (125, 475, 135, 480, Box3c)
end if
if LifeCounter2 = 1
then
Box2c2 := 149
drawfillbox (105, 475, 115, 480, Box2c)
end if
if LifeCounter2 = 0
then
Box1c2 := 149
drawfillbox (85, 475, 95, 480, Box1c)
end if
end if
end for
if LifeCounter2 <= 0
then
GameLost := false
reset := false
HighScore := timeofaction
end if
% View.Update
end if
elsif
%Last level
timeofaction > 55000
then
if BeginCounter = 3
then
Starting
end if
drawfillbox (85, 475, 95, 480, Box1c3) %1st
drawfillbox (105, 475, 115, 480, Box2c3) %2nd
drawfillbox (125, 475, 135, 480, Box3c3) %3rd
%NumBall2 := 1
for e : 1 .. NumBall3
drawfillbox (BoxX1, BoxY1, BoxX2, BoxY2, Color)
drawfilloval (Ball2X (e), Ball2Y (e), BallRadius, BallRadius, ColorBall)
Ball2X (e) := Ball2X (e) + Ball2XV (e)
if Ball2X (e) - BallRadius = BallRadius
then
Ball2XV (e) := Ball2XV (e) * -1
elsif Ball2X (e) + BallRadius >= maxx - BallRadius
then
Ball2XV (e) := Ball2XV (e) * -1
NumBall3 := NumBall3 + 1
randint (Ball2X (NumBall3), 0, maxx) %X Position
randint (Ball2Y (NumBall3), 0, maxy) %Y Position
Ball2YV (NumBall3) := 1
Ball2XV (NumBall3) := -1
end if
Ball2Y (e) := Ball2Y (e) + Ball2YV (e)
if Ball2Y (e) = maxy - BallRadius
then
Ball2YV (e) := -1 * Ball2YV (e)
elsif Ball2Y (e) <= BallRadius
then
Ball2YV (e) := 1
end if
if NumBall3 = 35
then
NumBall3 := 34
end if
if Color = brightred and BoxX2 <= Ball2X (e) + BallRadius and BoxX1 >= Ball2X (e) - BallRadius and BoxY1 <= Ball2Y (e) + BallRadius and BoxY2 >= Ball2Y (e) - BallRadius
then
delay (20)
drawfillbox (BoxX1, BoxY1, BoxX2, BoxY2, 12)
BoxX1 := maxx div 2
BoxX2 := maxx div 2.1
BoxY1 := maxy div 10
BoxY2 := maxy div 8
LifeCounter3 := LifeCounter3 - 1
if LifeCounter3 = 2
then
Box3c3 := 149
drawfillbox (125, 475, 135, 480, Box3c3) %3rd
end if
if LifeCounter3 = 1
then
Box2c3 := 149
drawfillbox (105, 475, 115, 480, Box2c3) %2nd
end if
if LifeCounter3 = 0
then
Box1c3 := 149
drawfillbox (85, 475, 95, 480, Box1c3) %1st
end if
end if
end for
if LifeCounter3 <= 0
then
GameLost := false
% reset := false
HighScore := timeofaction
end if
drawfillbox (BoxX1, BoxY1, BoxX2, BoxY2, brightred)
drawfilloval ((BoxX1 + BoxX2) div 2, (BoxY1 + BoxY2) div 2, 4, 4, black)
Bullety := (BoxY1 + BoxY2) div 2
Bulletx := (BoxX1 + BoxX2) div 2
View.Update
%cls
end if
% View.Update
% cls
%CONTROLS
Input.KeyDown (chars)
if chars (KEY_UP_ARROW) and BoxY2 <= maxy
then
BoxY1 := BoxY1 + 1
BoxY2 := BoxY2 + 1
elsif chars (KEY_DOWN_ARROW) and BoxY1 >= 0
then
BoxY1 := BoxY1 - 1
BoxY2 := BoxY2 - 1
elsif chars (KEY_RIGHT_ARROW) and BoxX1 <= maxx
then
BoxX1 := BoxX1 + 1
BoxX2 := BoxX2 + 1
elsif chars (KEY_LEFT_ARROW) and BoxX2 >= 0
then
BoxX2 := BoxX2 - 1
BoxX1 := BoxX1 - 1
end if
if chars (KEY_LEFT_ARROW) and chars (KEY_UP_ARROW) and BoxX2 >= 0 and BoxY2 <= maxy
then
BoxX2 := BoxX2 - 1
BoxX1 := BoxX1 - 1
BoxY1 := BoxY1 + 1
BoxY2 := BoxY2 + 1
end if
if chars (KEY_RIGHT_ARROW) and chars (KEY_UP_ARROW) and BoxY2 <= maxy and BoxX1 <= maxx
then
BoxX2 := BoxX2 + 1
BoxX1 := BoxX1 + 1
BoxY1 := BoxY1 + 1
BoxY2 := BoxY2 + 1
end if
if chars (KEY_RIGHT_ARROW) and chars (KEY_DOWN_ARROW) and BoxX1 <= maxx and BoxY1 >= 0
then
%delay (2)
BoxX2 := BoxX2 + 1
BoxX1 := BoxX1 + 1
BoxY1 := BoxY1 - 1
BoxY2 := BoxY2 - 1
end if
if chars (KEY_LEFT_ARROW) and chars (KEY_DOWN_ARROW) and BoxY1 >= 0 and BoxX2 >= 0
then
%delay (2)
BoxX2 := BoxX2 - 1
BoxX1 := BoxX1 - 1
BoxY1 := BoxY1 - 1
BoxY2 := BoxY2 - 1
end if
if
chars ('g')
then
drawarc ((BoxX1 + BoxX2) div 2, (BoxY1 + BoxY2) div 2, 16, 16, 0, 360, white)
Color := black
View.Update
else
Color := brightred
end if
if chars ('s')
then
% Font.Draw (Timme, maxx div 1.09, maxy div 1.05, font6, 31)
% Background1
View.Update
loop
%cls
Background1
if LifeCounter = 3 then
drawfillbox (125, 475, 135, 480, 12)
drawfillbox (105, 475, 115, 480, 12)
drawfillbox (85, 475, 95, 480, 12)
elsif LifeCounter = 2 then
drawfillbox (105, 475, 115, 480, 12)
drawfillbox (85, 475, 95, 480, 12)
elsif LifeCounter = 1 then
drawfillbox (85, 475, 95, 480, 12)
end if
Font.Draw (Timme, maxx div 1.09, maxy div 1.05, font6, 31)
drawfilloval (Bulletx, Bullety, 4, 4, black)
Bullety := Bullety + 1
if Bullety = maxy - 4
then
ColorBall := 31
exit
end if
% View.Update
drawfillbox (BoxX1, BoxY1, BoxX2, BoxY2, 12)
for e : 1 .. NumBall3
drawfillbox (BoxX1, BoxY1, BoxX2, BoxY2, brightred)
drawfilloval (Ball2X (e), Ball2Y (e), BallRadius, BallRadius, ColorBall)
Ball2X (e) := Ball2X (e) + Ball2XV (e)
if Ball2X (e) - BallRadius = BallRadius
then
Ball2XV (e) := Ball2XV (e) * -1
elsif Ball2X (e) + BallRadius >= maxx - BallRadius
then
Ball2XV (e) := Ball2XV (e) * -1
NumBall3 := NumBall3 + 1
randint (Ball2X (NumBall3), 0, maxx) %X Position
randint (Ball2Y (NumBall3), 0, maxy) %Y Position
Ball2YV (NumBall3) := 1
Ball2XV (NumBall3) := -1
end if
Ball2Y (e) := Ball2Y (e) + Ball2YV (e)
if Ball2Y (e) = maxy - BallRadius
then
Ball2YV (e) := -1 * Ball2YV (e)
elsif Ball2Y (e) <= BallRadius
then
Ball2YV (e) := 1
end if
if NumBall3 = 35
then
NumBall3 := 34
end if
if Color = brightred and BoxX2 <= Ball2X (e) + BallRadius and BoxX1 >= Ball2X (e) - BallRadius and BoxY1 <= Ball2Y (e) + BallRadius and BoxY2 >= Ball2Y (e) - BallRadius
then
delay (20)
drawfillbox (BoxX1, BoxY1, BoxX2, BoxY2, 12)
BoxX1 := maxx div 2
BoxX2 := maxx div 2.1
BoxY1 := maxy div 10
BoxY2 := maxy div 8
LifeCounter3 := LifeCounter3 - 1
if LifeCounter3 = 2
then
drawfillbox (125, 475, 135, 480, 149)
end if
if LifeCounter3 = 1
then
drawfillbox (105, 475, 115, 480, 149)
end if
if LifeCounter3 = 0
then
drawfillbox (85, 475, 95, 480, 149)
end if
end if
if Math.Distance (Ball2X (e), Ball2Y (e), Bulletx, Bullety) <= 2 * BallRadius - 8
then
delay (100)
ColorBall := 12
end if
end for
if LifeCounter3 <= 0
then
GameLost := false
% reset := false
HighScore := timeofaction
end if
%View.Update
Input.KeyDown (chars)
if chars (KEY_UP_ARROW) and BoxY2 <= maxy
then
BoxY1 := BoxY1 + 1
BoxY2 := BoxY2 + 1
elsif chars (KEY_DOWN_ARROW) and BoxY1 >= 0
then
BoxY1 := BoxY1 - 1
BoxY2 := BoxY2 - 1
elsif chars (KEY_RIGHT_ARROW) and BoxX1 <= maxx
then
BoxX1 := BoxX1 + 1
BoxX2 := BoxX2 + 1
elsif chars (KEY_LEFT_ARROW) and BoxX2 >= 0
then
BoxX2 := BoxX2 - 1
BoxX1 := BoxX1 - 1
end if
if chars (KEY_LEFT_ARROW) and chars (KEY_UP_ARROW) and BoxX2 >= 0 and BoxY2 <= maxy
then
BoxX2 := BoxX2 - 1
BoxX1 := BoxX1 - 1
BoxY1 := BoxY1 + 1
BoxY2 := BoxY2 + 1
end if
if chars (KEY_RIGHT_ARROW) and chars (KEY_UP_ARROW) and BoxY2 <= maxy and BoxX1 <= maxx
then
BoxX2 := BoxX2 + 1
BoxX1 := BoxX1 + 1
BoxY1 := BoxY1 + 1
BoxY2 := BoxY2 + 1
end if
if chars (KEY_RIGHT_ARROW) and chars (KEY_DOWN_ARROW) and BoxX1 <= maxx and BoxY1 >= 0
then
BoxX2 := BoxX2 + 1
BoxX1 := BoxX1 + 1
BoxY1 := BoxY1 - 1
BoxY2 := BoxY2 - 1
end if
if chars (KEY_LEFT_ARROW) and chars (KEY_DOWN_ARROW) and BoxY1 >= 0 and BoxX2 >= 0
then
BoxX2 := BoxX2 - 1
BoxX1 := BoxX1 - 1
BoxY1 := BoxY1 - 1
BoxY2 := BoxY2 - 1
end if
if
chars ('g')
then
Color := black
drawarc ((maxx div 2 + maxx div 2.1) div 2, (maxy div 10 + maxy div 8) div 2, 12, 12, 0, 360, white)
end if
if chars ('r')
then
Color := brightred
end if
View.Update
cls
end loop
cls
end if
View.Update
cls
if GameLost = false
then
loop
var HighScoreString := intstr (HighScore, 1)
var colormenu : int := white
drawfillbox (0, 0, maxx, maxy, 54)
Font.Draw ("Your Score was : ", maxx div 3, maxy div 1.5, font11, white)
Font.Draw (HighScoreString, maxx div 2.2, maxy div 2, font11, white)
View.Update
cls
end loop
View.Update
cls
end if
end loop