Yesterday I was working on the full game code with all levels incorporated; it works for the first two levels but not the third level. Next steps are to incorporate the last level successfully in, and add small details.
My code:View.Set ("graphics:1000;500,buttonbar,offscreenonly")
var BoxX1, BoxX2, BoxY1, BoxY2, BallRadius, move, BallRand, Color, font1, font2, font3, font4 : 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
font1 := Font.New ("Comic Sans:30:bold,underline")
font2 := Font.New ("Comic Sans:10:underline")
font3 := Font.New ("Comic Sans :30:bold")
font4 := Font.New ("Arial :20:bold")
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 t : int := 1
var CollisionCheck : real
procedure GameMenu %Creates Game Menu
loop
drawfillbox (0, 0, maxx, maxy, 103)
Font.Draw ("Welcome To The World's Hardest Game", maxx div 7, maxy div 2, font1, red)
Font.Draw ("To Start, Press 'S' ", maxx div 2, maxy div 4, font2, red)
Font.Draw ("To View Controls, Press 'C' ", maxx div 2, maxy div 6, font2, red)
get chars1
if chars1 = ('S')
then
exit
elsif chars1 = ('C')
then
drawfillbox (0, 0, maxx, maxy, 103)
Font.Draw ("Controls", maxx div 7, maxy div 1.13, font3, red)
Font.Draw ("The controls are rather simple: Use the cursor keys to move.", 100, 401, font2, red)
Font.Draw ("Avoid any bouncing balls as you will lose one of your 3 lives.", 100, 351, font2, red)
Font.Draw ("Reach The 'CheckPoint' and you will progress into harder levels.", 100, 301, font2, red)
Font.Draw ("If you progress far enough, you will gain the ability to shoot, at which point the 'SPACEBAR' will be the shoot button.", 100, 251, font2, red)
Font.Draw ("Good Luck and Have Fun!", 100, 201, font2, red)
Font.Draw ("To Start Press, 'S' ", maxx div 2.3, maxy div 13, font2, red)
View.Update
end if
get chars2
if chars2 = ('S')
then
exit
end if
end loop
end GameMenu
var Bulletx, Bullety : int
Bulletx := maxx div 2.05
Bullety := maxy div 9
GameMenu
proc NextLevel
Font.Draw ("NEXT LEVEL", maxx div 3, maxy div 2, font1, red)
%delay (5)
end NextLevel
proc Background
drawfillbox (0, 0, maxx, maxy, 149)
end Background
var Bulletshot : boolean := false
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
loop
%Background
drawfillbox (0, 0, maxx, maxy, 149)
drawfillbox (BoxX1, BoxY1, BoxX2, BoxY2, Color)
timeofaction := Time.Elapsed
Timme := intstr (timeofaction, 1)
Font.Draw (Timme, maxx div 1.2, maxy div 1.1, font1, 31)
%drawfilloval (BallPlayerX, BallPlayerY, BallPlayerRadius, BallPlayerRadius, Color)
%First Level
if timeofaction <= 35000 then
for d : 1 .. NumBall
drawfilloval (BallX (d), BallY (d), BallRadius, BallRadius, 31)
BallX (d) := BallX (d) + BallXV (d)
if BallX (d) = maxx - BallRadius
then
NumBall := NumBall + 1
BallXV (NumBall) := -1
t := t + 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
% delay (200)
end if
end for
elsif timeofaction > 35000 and timeofaction <= 55000
%Timer
% NextLevel
% exit
%% end if
% end for
% if Timer >= 35000
% then
% Background
then
for j : 1 .. NumBall2
drawfillbox (BoxX1, BoxY1, BoxX2, BoxY2, Color)
drawfilloval (Ball2X (j), Ball2Y (j), BallRadius, BallRadius, 31)
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
%delay (200)
end if
end for
Font.Draw (Timme, maxx div 1.2, maxy div 1.1, font1, 31)
% View.Update
elsif
timeofaction > 55000
then
Bulletshot := true
if Bulletshot = true
then
drawfillbox (BoxX1, BoxY1, BoxX2, BoxY2, Color)
drawfilloval ((BoxX1 + BoxX2) div 2, (BoxY1 + BoxY2) div 2, 4, 4, black)
Bullety := (BoxY1 + BoxY2) div 2
Bulletx := (BoxX1 + BoxX2) div 2
Font.Draw (Timme, maxx div 1.2, maxy div 1.1, font1, 31)
end if
View.Update
cls
%CONTROLS
Input.KeyDown (chars)
if chars (KEY_UP_ARROW) and BallPlayerY + BallPlayerRadius <= maxy and BoxY2 <= maxy
then
BoxY1 := BoxY1 + 1
BoxY2 := BoxY2 + 1
BallPlayerY := BallPlayerY + 1
elsif chars (KEY_DOWN_ARROW) and BallPlayerY - BallPlayerRadius >= 0 and BoxY1 >= 0
then
BallPlayerY := BallPlayerY - 1
BoxY1 := BoxY1 - 1
BoxY2 := BoxY2 - 1
elsif chars (KEY_RIGHT_ARROW) and BallPlayerX + BallPlayerRadius <= maxx and BoxX1 <= maxx
then
BoxX1 := BoxX1 + 1
BoxX2 := BoxX2 + 1
BallPlayerX := BallPlayerX + 1
elsif chars (KEY_LEFT_ARROW) and BallPlayerX - BallPlayerRadius >= 0 and BoxX2 >= 0
then
BallPlayerX := BallPlayerX - 1
BoxX2 := BoxX2 - 1
BoxX1 := BoxX1 - 1
end if
if chars (KEY_LEFT_ARROW) and chars (KEY_UP_ARROW) and BallPlayerX - BallPlayerRadius >= 0 and BallPlayerY + BallPlayerRadius <= maxy and BoxX2 >= 0 and BoxY2 <= maxy
then
BallPlayerX := BallPlayerX - 1
BallPlayerY := BallPlayerY + 1
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 BallPlayerY + BallPlayerRadius <= maxy and BallPlayerX + BallPlayerRadius <= maxx and BoxY2 <= maxy and BoxX1 <= maxx
then
BallPlayerX := BallPlayerX + 1
BallPlayerY := BallPlayerY + 1
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 BallPlayerX + BallPlayerRadius <= maxx and BallPlayerY - BallPlayerRadius >= 0 and BoxX1 <= maxx and BoxY1 >= 0
then
%delay (2)
BallPlayerX := BallPlayerX + 1
BallPlayerY := BallPlayerY - 1
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 BallPlayerY - BallPlayerRadius >= 0 and BallPlayerX - BallPlayerRadius >= 0 and BoxY1 >= 0 and BoxX2 >= 0
then
%delay (2)
BallPlayerX := BallPlayerX - 1
BallPlayerY := BallPlayerY - 1
BoxX2 := BoxX2 - 1
BoxX1 := BoxX1 - 1
BoxY1 := BoxY1 - 1
BoxY2 := BoxY2 - 1
end if
if
chars ('g')
then
Color := black
end if
if chars ('r')
then
Color := brightred
end if
end loop
No comments:
Post a Comment