Monday, 10 June 2013

Sorry I've Been Away;Techinical Problems-Posts from June 4th -June 10th (explanation within)

Hello. It appears as though I have not been posting on this blog (which I have been) 

because it seems that my blog was not able to publish any of my posts; 

after I would write each post, it would say that it has been published but they were all just 

'drafts' that weren't actually published. I did not know that this was happening so when 

I went to read my blog on a different computer, it didn't not show any of the my posts since 

last week. I still have the drafts so I will post all drafts (June 4th-June10th ) now. Sorry for 

any inconvenience.

June 4th
Today, I have worked on getting my collisions intact, this is has taken me a very long time in perfecting but I have finally got the correct if statements in my code for the ball to recognize if it is hitting anything. So far, I have only created a delay when they interact because I am not sure what I should do; but since I have the collision, I can worry about that another day.Next steps are to create a timer and start thinking about new levels.
My code:
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
            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 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

June 5th
Today I have attempted to create a timer using a combination of intstring and also the the Time.Elapsed function. It appears that it the timer is not going steadily up and I've tried a number of ways. The one benefit is that it is drawing and being updated; the only problem is to understand if there is a correlation between the timer and the number of balls that is being drawn. I should have this solved by tomorrow and think about next steps and levels.
My code:
 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
            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 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
        %Timer
      %  var timeofaction : int := Time.Elapsed
        Timme := intstr (timeofaction, 1)
        Font.Draw (Timme, maxx div 1.2, maxy div 1.1, font1, 31)
        if timeofaction >= 35000
                then
            exit
        end if
    end for
June 6th
Today has been productive. I have completed my timer and have also thought of the level ahead; after 35 seconds of withstanding the first level, the balls will change in orientation moving up,down,left and right at different times. This should increase difficulty level by a lot so I have thought of giving the level only 25 seconds. This has been frutiful in terms of concepts and the actual code as well.
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
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 real
var Ball2YV : array 1 .. 100 of real
Ball2XV (1) := -1
Ball2YV (1) := 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
GameMenu
proc NextLevel
    drawfillbox (0, 0, maxx, maxy, white)
    Font.Draw ("NEXT LEVEL", maxx div 3, maxy div 2, font1, red)
    delay (500)
end NextLevel
loop
    drawfillbox (0, 0, maxx, maxy, 149)
    drawfillbox (BoxX1, BoxY1, BoxX2, BoxY2, Color)
    %drawfilloval (BallPlayerX, BallPlayerY, BallPlayerRadius, BallPlayerRadius, Color)
    %First Level
    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
            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 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
        %Timer
        var timeofaction : int := Time.Elapsed
        Timme := intstr (timeofaction, 1)
        Font.Draw (Timme, maxx div 1.2, maxy div 1.1, font1, 31)
        if timeofaction >= 35000
                then
            exit
        end if
    end for
June 7th
Today has been a fun day. I heard Mr.Van Rooyen talk about coded glitches and I have thought of adding an option where the box that you control will turn black and will automatically dodge the balls so you don't have to do anything. I have also coded into my game an option that that will let you turn into a circle as opposed to a box and every time your circle goes through one of the oncoming balls, the ball that the user is controlling will change. It is a fun little 'hack' but I will have to think about how the user will get the chance to make that decision.
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
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 real
var Ball2YV : array 1 .. 100 of real
Ball2XV (1) := -1
Ball2YV (1) := 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
GameMenu
proc NextLevel
    drawfillbox (0, 0, maxx, maxy, white)
    Font.Draw ("NEXT LEVEL", maxx div 3, maxy div 2, font1, red)
    delay (500)
end NextLevel
loop
    drawfillbox (0, 0, maxx, maxy, 149)
    drawfillbox (BoxX1, BoxY1, BoxX2, BoxY2, Color)
    %drawfilloval (BallPlayerX, BallPlayerY, BallPlayerRadius, BallPlayerRadius, Color)
    %First Level
    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
            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 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
        %Timer
        var timeofaction : int := Time.Elapsed
        Timme := intstr (timeofaction, 1)

        Font.Draw (Timme, maxx div 1.2, maxy div 1.1, font1, 31)

        if timeofaction >= 35000
                then
            exit
        end if
    end for
 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
    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_RIGHT_ARROW) and chars (KEY_UP_ARROW) and BallPlayerY + BallPlayerRadius <= maxy and BallPlayerX + BallPlayerRadius <= maxx and BoxY2 <= maxy and BoxX1 <= maxx
        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_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
June 8th
Today was not very productive, I have tried to create the second level in my 3 level game but it is much harder than I thought. I am adding two vectors to the balls moving and it is very confusing. I am sure that it is similar to pong with the x and y vectors; but finding the boundries and values etc.. are very confusing. I will have to work on this at home :
var BallRadius, Balldirx, Balldiry, NumBall : int
BallRadius := 9
Balldirx := -1
Balldiry := 1
NumBall := 1
var Ballx : array 1 .. 100 of int
var Bally : array 1 .. 100 of int
var Ballxv : array 1 .. 100 of int
var Ballyv : array 1 .. 100 of int
randint (Ballx (NumBall), 0, maxx)
randint (Bally (NumBall), 0, maxy)
Ballxv (1) := -1
Ballyv (1) := 1
loop
    for d : 1 .. NumBall
        delay (5)
        drawfilloval (Ballx (d), Bally (d), BallRadius, BallRadius, green)
        Ballx (d) := Ballx (d) + Ballxv (d)
        if Ballx (d) - 9 = 9 then
            Ballxv (d) := Ballxv (d) * -1
            Ballyv (d) := 1
        elsif Ballx (d) + 9 >= maxx - BallRadius
                then
            Ballxv (NumBall) := 1
          
            Ballyv (NumBall) := -1 * Ballyv (d)
        end if
        Bally (d) := Bally (d) + Ballyv (d)
        if Bally (d) >= maxy - BallRadius
                then
            Ballyv (d) := -1 * Ballyv (d)
        elsif Bally (d) <= BallRadius
                then
            Ballyv (d) := -1*Ballyv(d)
        end if

        View.Update
    
        end for
end loop
June 9th
Today has only been satisfactory, I have solved how to make one ball move with the 2 vectors with all including the boundry of both sides. I have started working on how to do more than one ball but to no avail, I will work on this at home as well. 
My code:var Balldirx, Balldiry, NumBall : int
NumBall := 1
var Ballx : array 1 .. 100 of int
var Bally : array 1 .. 100 of int
randint (Ballx (NumBall), 0, maxx)
randint (Bally (NumBall), 0, maxy)


Balldirx := -1
Balldiry := 1
loop
    for d : 1 .. NumBall
        drawfilloval (Ballx (d), Bally (d), 9, 9, green)
        Ballx (d) := Ballx (d) + Balldirx
        if Ballx (d) - 9 = 9 then
            Balldirx := Balldirx * -1
        elsif Ballx (d) + 9 >= maxx - 9
                then
            Balldirx := Balldirx * -1
            
        end if
        Bally (d) := Bally (d) + Balldiry
        if Bally (d) >= maxy - 9
                then
            Balldiry := -1 * Balldiry
        elsif Bally (d) <= 9
                then
            Balldiry := 1
        end if
        delay (1)
    end for
    View.Update
    cls
end loop
June 10th
I have made a lot of progress on the second level, but I am not quite there. I realized that I would have to make an array for ALL of the speeds of the balls. The problem I am having is that only when the first ball hits the wall a new one is being created. I also noticed is that they all take the same path of motion as the first ball so I will have to ask for some help on that. I will work on this at home as well.
My code:var Balldirx, Balldiry, NumBall : int
NumBall := 1
var Ballx : array 1 .. 100 of int
var Bally : array 1 .. 100 of int
randint (Ballx (NumBall), 0, maxx)
randint (Bally (NumBall), 0, maxy)


Balldirx := -1
Balldiry := 1
loop
    for d : 1 .. NumBall
        drawfilloval (Ballx (d), Bally (d), 9, 9, green)
        Ballx (d) := Ballx (d) + Balldirx
        if Ballx (d) - 9 = 9 then
            Balldirx := Balldirx * -1
        elsif Ballx (d) + 9 >= maxx - 9
                then
            Balldirx := Balldirx * -1
            NumBall := NumBall + 1
            randint (Ballx (NumBall), 0, maxx)
            randint (Bally (NumBall), 0, maxy)
        end if
        Bally (d) := Bally (d) + Balldiry
        if Bally (d) >= maxy - 9
                then
            Balldiry := -1 * Balldiry
        elsif Bally (d) <= 9
                then
            Balldiry := 1
        end if
        delay (1)
    end for
    View.Update
    cls
end loop


No comments:

Post a Comment