
-----------------------------------
xdanielx98
Thu Dec 20, 2007 9:28 am

Need help with my &quot;VolleyBall&quot; Game
-----------------------------------
Hi, this is my first attempt at making a game which incorporates simulated gravity and incorporates the balls relative position to an object to modify how the ball will react to the object, I have got it so that the ball will bounce off of the blobs correctly but every time I try to change the angle that the ball bounces at the ball just kinda goes crazy...

var width, height, XB, YB, xdir, ydir : int
var y, x : int
var theta2, tim3, velocity2 : real
var blobx1, bloby1, blobx2, bloby2 : int
var velocity, tim, tim2, theta, gravity, x2, y2, x3, y3 : real
var x1, y1 : int
var key : array char of boolean
var count : int
var jump : int
var serve, fserve : int
var pscore1, pscore2 : int
var timdir : int
timdir := 1
theta2 := 90
tim3 := 0
velocity2 := 2
x := 300
pscore1 := 0
pscore2 := 0
jump := 0
width := 50
height := 50
blobx1 := 150
bloby1 := 10
blobx2 := 490
bloby2 := 10
y := 200
randint (fserve, 1, 2)
tim := 0
tim2 := 0
theta := 90
gravity := 0.02
x2 := 1
y2 := 1
x3 := 1
y3 := 1
velocity := 2
xdir := 1
ydir := 1
YB := 200
View.Set ("offscreenonly")

%Blur Procedure to erase all objects with a fading design

procedure Blur (I, C : int)
    for B : 1 .. I
        drawline (Rand.Int (1, maxx), Rand.Int (1, maxy),
            Rand.Int (1, maxx), Rand.Int (1, maxy), C)
    end for
end Blur

loop

    %Deciding on which player will server and how the ball reacts to server

    if fserve = 1 then
        XB := round (x + velocity2 * tim3 * cosd (theta2)) - 150
        YB := round (y + velocity2 * tim3 * sind (theta2) - 0.5 * gravity * tim3 * tim3)
    elsif fserve = 2 then
        XB := round (x + velocity2 * tim3 * cosd (theta2)) + 190
        YB := round (y + velocity2 * tim3 * sind (theta2) - 0.5 * gravity * tim3 * tim3)
    end if

    %All drawings contained within tha program

    tim3 := tim3 + timdir
    count := 1
    Blur (100, brightblue)
    drawfill (30, 30, brightblue, brightblue)
    drawfillbox (0, 0, 640, 10, darkgray)
    drawfillbox (305, 10, 335, 100, black)
    drawfillarc (blobx1, bloby1, width, height, 0, 180, brightred)
    drawfillarc (blobx2, bloby2, width, height, 0, 180, brightgreen)
    drawfilloval (round (XB), round (YB), 10, 10, 14)
    View.Update
    Input.KeyDown (key)
    delay (10)

    %Causing ball to bounce into air by revercing timdir to the opposite of what it is.
    %Requires reversal to have tim continue to function in positive numbers effecting gravity properly

    if XB >= blobx1 - 10 and XB = blobx2 - 5 and XB  390 then
        blobx2 := blobx2 - 1
        %if key is "d" then it will cause the blob to go right
    elsif key ('d') and blobx2 < 590 then
        blobx2 := blobx2 + 1
    end if
    %if key is "w" then it will cause the blob to jump
    if key ('w') then
        jump := 3
    end if
    %x3 := blobx1
    if jump = 3 then

        if tim >= 50 then
            bloby1 := round (y3 + velocity * tim * sind (theta) - 0.5 * gravity * tim * tim)
            tim := tim + 1
        end if
        bloby2 := round (y2 + velocity * tim2 * sind (theta) - 0.5 * gravity * tim2 * tim2)
        tim2 := tim2 + 1
        drawfillarc (blobx1, bloby1, width, height, 0, 180, brightred)
        drawfillarc (blobx2, bloby2, width, height, 0, 180, brightgreen)
        if bloby2 = 201 then
        tim := 0
    end if
    if tim2 >= 201 then
        tim2 := 0
    end if

end loop


-----------------------------------
Zampano
Thu Dec 20, 2007 9:50 am

Re: Need help with my &quot;VolleyBall&quot; Game
-----------------------------------
Is this original? I feel that I have played this same game before in Turing with the same graphics, but I can't remember where.

-----------------------------------
Gackt
Thu Dec 20, 2007 9:58 am

Re: Need help with my &quot;VolleyBall&quot; Game
-----------------------------------
Is this original? I feel that I have played this same game before in Turing with the same graphics, but I can't remember where.

Actually, he got the idea from the game from the other one on here. XD

-----------------------------------
xdanielx98
Thu Dec 20, 2007 11:26 am

Re: Need help with my &quot;VolleyBall&quot; Game
-----------------------------------
yes, it is original, I got the idea from a game that had been posted on this site in the submition section, the game was called "Amazing Game" or something down those lines. I used the game to learn a lot of what I have put into this program except I wrote every line of it myself, I have to give credit to the original creator for the blur procedure though, I used practically the same code that was in the original game for the blur design... and as more proof that it is my own... my program doesnt work lol... the original program deffinately does

-----------------------------------
xdanielx98
Thu Dec 20, 2007 12:04 pm

Re: Need help with my &quot;VolleyBall&quot; Game
-----------------------------------
Here is a slightly revised version of my program... I removed some un necisary lines of code from the program but I still havent been able to get the ball moving on an angle based on its impact with the blob.
