Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 that volleyball game that dude wanted...
Index -> Programming, Turing -> Turing Submissions
Goto page Previous  1, 2, 3  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Cervantes




PostPosted: Mon Jan 12, 2004 5:38 pm   Post subject: (No subject)

gah I can't do it Sad
Sponsor
Sponsor
Sponsor
sponsor
DanShadow




PostPosted: Mon Jan 12, 2004 7:58 pm   Post subject: (No subject)

That is nice! I never let the opponent have the ball, I hopped over the net, grabbed the ball, and spiked it down by going on top of it, lol. But that is seriously a great game!
agent_orange444




PostPosted: Thu Jan 22, 2004 6:35 pm   Post subject: (No subject)

Nice job on the game. Bye the way the correct name is slime volleyball. It does need a bit of minor tweaking though.
kalin




PostPosted: Thu Jan 22, 2004 6:47 pm   Post subject: (No subject)

cool. I like it
Cervantes




PostPosted: Thu Jan 22, 2004 7:06 pm   Post subject: (No subject)

Homer the thing is you can do what you said about changing the velocity and resetting startx and starty and all but you can't change the angle to what it should be because in order to do that, you have to know its current angle (right before it hits the wall).
Cervantes




PostPosted: Thu Jan 22, 2004 8:03 pm   Post subject: (No subject)

ahah I did it! well it still bounces slightly wierd... maybe I can iron that out... but here's my version of Homer's game

code:
View.Set ("position:centre;centre,graphics:640;500,offscreenonly")
colorback (black)
cls
var score1 : int := 0
var score2 : int := 0
var time2 := 0

var chars : array char of boolean
type projectile_t :
    record
        startx, starty, x, xp, y, yp, angle, weight, velocity : real
    end record

type player_t :
    record
        x, y, w, v, t : real
    end record

var projectile_1 : projectile_t
var player_1 : player_t
var player_2 : player_t

player_1.x := 100
player_1.y := 100
player_1.v := 50
player_1.w := 10
player_1.t := 0

player_2.x := maxx - 100
player_2.y := 100
player_2.v := 50
player_2.w := 10
player_2.t := 0

projectile_1.startx := 100
projectile_1.starty := 140
projectile_1.x := 100
projectile_1.y := 140
projectile_1.velocity := 90
projectile_1.angle := 90
projectile_1.weight := 15
var time1 := 0.0
var bjump_1 := false
var bjump_2 := false

var currentangle : real
var slope : real
var bounceangle : real

procedure Projectile (var obj : projectile_t, t : real)
    obj.x := (obj.velocity * cosd (obj.angle) * t) + obj.startx
    obj.y := (obj.velocity * sind (obj.angle) * t - (obj.weight) * t ** 2 / 2) + obj.starty
end Projectile

procedure Jump (var obj : player_t)
    obj.y := (obj.v * sind (90) * obj.t - (obj.w) * obj.t ** 2 / 2) + 100
    obj.t += .1
end Jump

procedure ResetP (var obj : projectile_t, sx, sy, v, a, w : real)
    projectile_1.startx := sx
    projectile_1.starty := sy
    projectile_1.velocity := v
    projectile_1.angle := a
    projectile_1.weight := w
end ResetP
color (10)
loop
    %if round (projectile_1.velocity) > 1 then
    if projectile_1.starty > 110 then
        time1 += .105
    else
        if projectile_1.x < 320 then
            score2 += 1
        elsif projectile_1.x > 320 then
            score1 += 1
        end if
        player_1.x := 100
        player_1.y := 100
        player_1.v := 50
        player_1.w := 10
        player_1.t := 0
        player_2.x := maxx - 100
        player_2.y := 100
        player_2.v := 50
        player_2.w := 10
        player_2.t := 0
        projectile_1.startx := 100
        projectile_1.starty := 140
        projectile_1.velocity := 90
        projectile_1.angle := 90
        projectile_1.weight := 15
        time1 := 0.0
        delay (200)
    end if
    %end if
    projectile_1.xp := projectile_1.x
    projectile_1.yp := projectile_1.y
    Projectile (projectile_1, time1)
    if projectile_1.y not= projectile_1.yp and projectile_1.x not= projectile_1.xp then
        slope := (projectile_1.y - projectile_1.yp) / (projectile_1.x - projectile_1.xp)
        currentangle := arctand (slope)
        bounceangle := -currentangle
        locate (3, 2)
        put "Angle : ", currentangle
    end if

    if projectile_1.y < 105 then     %Ball hits ground
        ResetP (projectile_1, projectile_1.x, projectile_1.y, round (projectile_1.velocity / 2), projectile_1.angle, projectile_1.weight)
        time1 := 0
    end if

    if projectile_1.x < 1 then     %Ball hits left wall
        ResetP (projectile_1, projectile_1.x, projectile_1.y, round (projectile_1.velocity / 1.3), bounceangle, projectile_1.weight)
        time1 := 0
    end if
    if projectile_1.x > 639 then     %Ball hits right wall
        ResetP (projectile_1, projectile_1.x, projectile_1.y, round (projectile_1.velocity / 1.3), bounceangle, projectile_1.weight)
        projectile_1.angle += 180
        time1 := 0
    end if

    if projectile_1.y < 160 then     %ball lower than top of net
        if projectile_1.x > 310 and projectile_1.x < 320 then     %Ball hits left side of net
            ResetP (projectile_1, projectile_1.x, projectile_1.y, round (projectile_1.velocity), bounceangle, projectile_1.weight)
            time1 := 0
        end if

        if projectile_1.x < 330 and projectile_1.x > 320 then     %Ball hits right side of net
            ResetP (projectile_1, projectile_1.x, projectile_1.y, round (projectile_1.velocity), bounceangle, projectile_1.weight)
            projectile_1.angle += 180
            time1 := 0
        end if
    end if

    if Math.Distance (player_1.x, player_1.y, projectile_1.x, projectile_1.y) < 40 then     %Bouncing ball off Player 1
        if projectile_1.x not= player_1.x then
            locate (1, 1)
            if arctand ((projectile_1.y - player_1.y) / (projectile_1.x - player_1.x)) < 0 then
                ResetP (projectile_1, projectile_1.x, projectile_1.y, round (projectile_1.velocity), 180 + arctand ((projectile_1.y - player_1.y) / (projectile_1.x - player_1.x)),
                    projectile_1.weight)
            else
                ResetP (projectile_1, projectile_1.x, projectile_1.y, round (projectile_1.velocity), arctand ((projectile_1.y - player_1.y) / (projectile_1.x - player_1.x)), projectile_1.weight)
            end if
        else
            ResetP (projectile_1, projectile_1.x, projectile_1.y, round (projectile_1.velocity), 90, projectile_1.weight)
        end if
        time1 := 0
    end if

    if Math.Distance (player_2.x, player_2.y, projectile_1.x, projectile_1.y) < 40 then     %Bouncing ball off Player 2
        if projectile_1.x not= player_2.x then
            locate (1, 1)
            if arctand ((projectile_1.y - player_2.y) / (projectile_1.x - player_2.x)) < 0 then
                ResetP (projectile_1, projectile_1.x, projectile_1.y, round (projectile_1.velocity), 180 + arctand ((projectile_1.y - player_2.y) / (projectile_1.x - player_2.x)),
                    projectile_1.weight)
            else
                ResetP (projectile_1, projectile_1.x, projectile_1.y, round (projectile_1.velocity), arctand ((projectile_1.y - player_2.y) / (projectile_1.x - player_2.x)), projectile_1.weight)
            end if
        else
            ResetP (projectile_1, projectile_1.x, projectile_1.y, round (projectile_1.velocity), 90, projectile_1.weight)
        end if
        time1 := 0
    end if
    %%%%Player Boundaries%%%
    if player_1.x < 30 then     %Player 1 Wall
        player_1.x := 30
    end if
    if player_1.x > 290 then     %Player 1 Net
        player_1.x := 290
    end if
    if player_2.x < 350 then     %Player 2 Net
        player_2.x := 350
    end if
    if player_2.x > 610 then     %Player 2 Wall
        player_2.x := 610
    end if

    if bjump_1 then     %Jumping of Player 1
        Jump (player_1)
        if player_1.y < 100 then
            bjump_1 := false
            player_1.t := 0
            player_1.y := 100
        end if
    end if

    if bjump_2 then     %Jumping of Player 2
        Jump (player_2)
        if player_2.y < 100 then
            bjump_2 := false
            player_2.t := 0
            player_2.y := 100
        end if
    end if

    Input.KeyDown (chars)
    %Player1 Controls
    if chars ('w') then
        bjump_1 := true
    end if
    if chars ('a') then
        player_1.x -= 3
    end if
    if chars ('d') then
        player_1.x += 3
    end if
    %Player2 Controls
    if chars (KEY_UP_ARROW) then
        bjump_2 := true
    end if
    if chars (KEY_LEFT_ARROW) then
        player_2.x -= 3
    end if
    if chars (KEY_RIGHT_ARROW) then
        player_2.x += 3
    end if

    drawline (320, 100, 320, 150, yellow)     % net
    drawfilloval (round (player_1.x), round (player_1.y), 30, 30, 9)     % player 1
    drawfilloval (round (player_2.x), round (player_2.y), 30, 30, 42)     % player 2
    drawfillbox (0, 0, 640, 100, 10)     %ground
    drawfilloval (round (projectile_1.x), round (projectile_1.y), 10, 10, 12)     %ball
    View.Update
    delay (10)
    drawfilloval (round (player_1.x), round (player_1.y), 30, 30, black)     %Player 1 Previously
    drawfilloval (round (player_2.x), round (player_2.y), 30, 30, black)     %Player 2 Previously
    drawfilloval (round (projectile_1.x), round (projectile_1.y), 10, 10, black)     % Ball Previously
    drawline (320, 100, 320, 150, brightred)     %Bright red of net
    /*var mx, my, mbutton : int
     Mouse.Where (mx, my, mbutton)
     locate (1, 1)
     put mx, " - ", my*/
    locate (1, 2)
    put "Score : ", score1
    locate (1, maxcol - 10)
    put "Score : ", score2
end loop


Cheers
Homer_simpson




PostPosted: Fri Jan 23, 2004 1:23 am   Post subject: (No subject)

Cervantes wrote:
Homer the thing is you can do what you said about changing the velocity and resetting startx and starty and all but you can't change the angle to what it should be because in order to do that, you have to know its current angle (right before it hits the wall).


well u can get the angle on collision by: calculating the tangent to the curve at the last second of the collision...
Cervantes




PostPosted: Fri Jan 23, 2004 1:39 pm   Post subject: (No subject)

yeah that's basically what I did.. only using arctand gives me a result with 90 being up and -90 being down... slightly different, still works though.
Sponsor
Sponsor
Sponsor
sponsor
valor




PostPosted: Wed Mar 24, 2004 10:38 pm   Post subject: (No subject)

cool. it has a few glitches in it that could probably be fixed if you put time into it but it is pretty nice umm im just wondering what does the score go up to? because i got like around 40
WhatAmIDoing




PostPosted: Thu Mar 25, 2004 12:24 pm   Post subject: (No subject)

Cervantes what version of turing did you use because when i tried to run it i got Distance is not in the export list of math.
shorthair




PostPosted: Thu Mar 25, 2004 4:25 pm   Post subject: (No subject)

leave old topic old , go ahead and look at em and get the files , BUT dont post in them , there are enoug hactive posts to post in , its irritation to see old posts come back up
Cervantes




PostPosted: Thu Mar 25, 2004 5:06 pm   Post subject: (No subject)

indeed Laughing two months old Razz

I'm using Turing 4.0.5. You get that error because Math.Distance is not in anything before 4.0.3. You can fix it easily enough by making a variable called distance and using the distance formula.
the_short1




PostPosted: Fri Mar 26, 2004 6:00 pm   Post subject: (No subject)

the first thing everyone should do in a program is do:

View.Set ("graphics:size;size,title:some name,nobuttonbar") <<i always see that dam button bar and i hate it...


ERR.... nice game tho.... needs a little polishing... but its cool...... mind you.... if i want a wicked AI ill play that onling versionl.... i found urs a little too ez...
valor




PostPosted: Thu Apr 01, 2004 9:55 pm   Post subject: (No subject)

thats pretty sweet. shouldnt be able to go through the net though Razz
beard0




PostPosted: Fri May 28, 2004 1:30 pm   Post subject: (No subject)

for earlier versions of turing:
code:
function MathDistance (x, y, x1, y1 : real) : int
    result round (sqrt ((x1 - x) ** 2 + (y1 - y) ** 2))
end MathDistance

put that in at the begining and replace all occurences of Math.Distance with MathDistance
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 2 of 3  [ 32 Posts ]
Goto page Previous  1, 2, 3  Next
Jump to:   


Style:  
Search: