Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Bouncing a ball off a semi-circle ??
Author Message
CITC

Posted: Tue Jan 06, 2004 8:41 pm   Post subject: Bouncing a ball off a semi-circle ??

Hi everyone, first before I ask my question I'd like to say what an AMAZING site this is... truly INCREDIBLE!!!!!!!!!

k, with that being said, I'd like to make a turing version of a game I found on www.addictinggames.com called Slime Volleyball. If you haven't played it you can check it out here
http://tartarus.uwa.edu.au/%7Ewedgey/slime1/
the biggest problem I have with making this game is that in the game the players are semi-circles (slimes) and the ball bounces off of these semi circles, reflecting appropriately. I've thought and thought about this, but can't figure out how to do it. Anyone know how?

CITC

Maverick

Posted: Tue Jan 06, 2004 8:47 pm   Post subject: (No subject)

Slime volleyball kinda sux, you shuld make slime soccer.
I think I know where to get the code for that bouncing thing.
I'll post in a day or two.
AsianSensation

Posted: Tue Jan 06, 2004 9:10 pm   Post subject: (No subject)

you kinda have to know a bit of physics or at least some math to be able to do this. Tell me what you know about projectiles or parabolas so I can help you out.
shorthair

Posted: Wed Jan 07, 2004 11:51 am   Post subject: (No subject)

the cheesy way out if you dont know alot about math and physics, is to make arbitraraly mabye 10 different angles so if the ballx = slimex or ballx = slimex + 10 then ........ make your angles , but asian is right there is a proprer way to do it
CITC

Posted: Wed Jan 07, 2004 5:00 pm   Post subject: (No subject)

hehe Slime soccer was good too. fortunately if i make slime volleyball i can fairly easily change it to slime soccer

as for the math bit, I'm really good at math and physics, but I'm only in Grade 10 (I've taken Gr 10 science but Gr 10 math is next semester). don't know anything about projectiles or parabalas but tell me and I'll see if i can pick it up.
if i can't, I can go with shorthair's suggestion

oh yeah also I found the code for that game too but it was in Java and totally confused me
Homer_simpson

Posted: Wed Jan 07, 2004 8:40 pm   Post subject: (No subject)

that's not a bad game... i kinda like the idea...it's creative and everything, it's actually a good idea to hand in something like that for yer fp...

Any way if u wanna learn to do that... check out my tutorial on projectile physics... basically all u need is the velocity and the angle the ball hit's the player at...
Homer_simpson

Posted: Wed Jan 07, 2004 10:01 pm   Post subject: (No subject)

in fact i liked the simplicity of the idea so much... i'll give u something to start with...
 code: View.Set ("offscreenonly") colorback (black) cls var time2 := 0 function distance (x1, y1, x2, y2 : real) : real     result (((x1 - x2) ** 2 + (y1 - y2) ** 2) ** .5) end distance var chars : array char of boolean type projectile_t :     record         startx, starty, x, y, 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 player_1.x := 100 player_1.y := 100 player_1.v := 50 player_1.w := 10 player_1.t := 0 projectile_1.startx := 100 projectile_1.starty := 140 projectile_1.velocity := 80 projectile_1.angle := 90 projectile_1.weight := 10 var time1 := 0.0 var bjump_1 := false 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         time1 += .1     else         player_1.x := 100         player_1.y := 100         player_1.v := 50         player_1.w := 10         player_1.t := 0         projectile_1.startx := 100         projectile_1.starty := 140         projectile_1.velocity := 80         projectile_1.angle := 90         projectile_1.weight := 10         time1 := 0.0         locate (10, 10)         put "eeeshta!"         cls         delay (200)     end if     Projectile (projectile_1, time1)     if projectile_1.y < 105 then         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         ResetP (projectile_1, projectile_1.x, projectile_1.y, round (projectile_1.velocity / 1.3), projectile_1.angle - 90, projectile_1.weight)         time1 := 0     end if     if projectile_1.x > 639 then         ResetP (projectile_1, projectile_1.x, projectile_1.y, round (projectile_1.velocity / 1.3), projectile_1.angle + 90, projectile_1.weight)         time1 := 0     end if     if projectile_1.y < 210 then         if projectile_1.x > 310 and projectile_1.x < 320 then             ResetP (projectile_1, projectile_1.x, projectile_1.y, round (projectile_1.velocity), projectile_1.angle - 90, projectile_1.weight)             time1 := 0         end if         if projectile_1.x < 330 and projectile_1.x > 320 then             ResetP (projectile_1, projectile_1.x, projectile_1.y, round (projectile_1.velocity), projectile_1.angle + 90, projectile_1.weight)             time1 := 0         end if     end if     if distance (player_1.x, player_1.y, projectile_1.x, projectile_1.y) < 40 then         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 bjump_1 then         Jump (player_1)         if player_1.y < 100 then             bjump_1 := false             player_1.t := 0             player_1.y := 100         end if     end if     Input.KeyDown (chars)     if chars ('w') then         bjump_1 := true     end if     if chars ('a') then         player_1.x -= 1     end if     if chars ('d') then         player_1.x += 1     end if     drawline (320, 100, 320, 200, yellow)     drawfilloval (round (player_1.x), round (player_1.y), 30, 30, 9)     drawfillbox (0, 0, 640, 100, 10)     drawfilloval (round (projectile_1.x), round (projectile_1.y), 10, 10, 12)     View.Update     delay (10)     drawfilloval (round (player_1.x), round (player_1.y), 30, 30, black)     drawfilloval (round (projectile_1.x), round (projectile_1.y), 10, 10, black)     drawline (320, 100, 320, 200, black) end loop
CITC

Posted: Thu Jan 08, 2004 7:53 pm   Post subject: (No subject)

wow thanks for that code! I haven't read through much of it yet but from running it in turing it looks like there isn't much else to do.

did you just make this now or was this a slightly altered part of your tutorial that you mentioned? Also, where can I look at this tutorial?

Homer_simpson

Posted: Fri Jan 09, 2004 12:16 am   Post subject: (No subject)

CITC

Posted: Sat Jan 10, 2004 11:36 am   Post subject: (No subject)

I've been working on the game and I've added the second player and made the ball bounce off him the same as it does off player 1.

the thing I don't get is why does the ball bounce oddly off of the walls and net? It bounces as though it had either a topspin or a backspin (its not just reflected, it will sometimes shoot quickly down or other times shoot pretty horizontally across the screen). I've been playing around with it but can't find any way to fix it.
CITC

Posted: Sat Jan 10, 2004 12:40 pm   Post subject: (No subject)

oh and theres one other kinda quirky thing.. sometimes the ball goes inside the slimes and bounces around for a half second or so building up velocity, then shoots out in some wierd direction.

I think I might be able to fix these things if I could understand the ResetP procedure. What are sx,sy,v,a, and w. I understand what they stand for, but when were they created and what are their values?
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 11 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: