Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / bounce function?

Author
Message
Jadelion
21
Years of Service
User Offline
Joined: 14th Jan 2003
Location:
Posted: 15th Feb 2003 00:40
Ok, so everything worked fine untill I decided to convert some of my IF statments to functions. so this is what i did

I had code that looked like this
if y_position = 0 then y_direction = 0-y_direction
and I tryed to make it into a function that looks like this

Witch Bomber
21
Years of Service
User Offline
Joined: 25th Jan 2003
Location: Scotland
Posted: 15th Feb 2003 00:50


Those of you who think you know everything are annoying to those of us who do.
Jadelion
21
Years of Service
User Offline
Joined: 14th Jan 2003
Location:
Posted: 15th Feb 2003 06:09
actually I had it that way, i just typed it wrong but it still dosent work the ball just skids along the top wall I'll post the whole code so you can see.





Mike Inel
21
Years of Service
User Offline
Joined: 14th Feb 2003
Location: Sa upuan ko po...
Posted: 15th Feb 2003 12:37
........ Very complicated... I'm not used to it, Dang.

Witch Bomber
21
Years of Service
User Offline
Joined: 25th Jan 2003
Location: Scotland
Posted: 15th Feb 2003 23:40
What's the line A = ballydirection for?

Those of you who think you know everything are annoying to those of us who do.
Witch Bomber
21
Years of Service
User Offline
Joined: 25th Jan 2003
Location: Scotland
Posted: 15th Feb 2003 23:57
I don't use functions but your function uses the function a which would be affected by the variable A(db is not case sensitive). After negating the y direction you save the negative as A. The next loop it then negates a to give you a y direction the same as at the start.(If you understand that, because I barely do) Delete the line A = ballydirection

Those of you who think you know everything are annoying to those of us who do.
Witch Bomber
21
Years of Service
User Offline
Joined: 25th Jan 2003
Location: Scotland
Posted: 16th Feb 2003 00:00
I have not run your program but I would hypothesise that it would go up 5 one loop then down 5 the next then up 5 the next etc...

This would explain it skidding along the top.

Those of you who think you know everything are annoying to those of us who do.
Flashing Blade
22
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 16th Feb 2003 00:24
radius too small:

Witch Bomber
21
Years of Service
User Offline
Joined: 25th Jan 2003
Location: Scotland
Posted: 16th Feb 2003 01:18
Radius too small wouldn't cause that type of problem.

Those of you who think you know everything are annoying to those of us who do.
Jadelion
21
Years of Service
User Offline
Joined: 14th Jan 2003
Location:
Posted: 16th Feb 2003 04:51
nope, still fails (with the A line commented out and changeing the radius has no effect)
like I said the code works if I just use IF staments like I did for the rest of the walls but it would save a lot of lines of code if I could get teh function working because then all the collisions could be routed through that one function.
Flashing Blade
22
Years of Service
User Offline
Joined: 19th Oct 2002
Location: United Kingdom
Posted: 16th Feb 2003 12:10
sorry see what u mean now - i thought problem was that ball stuck to bat(which it does on my computer)
Your problem is this:
You want to use function to reverse ballydirection, which function bounce() does succesfully but the return value you assign to variable A insted of variable ballydirection.

change this code:


to this:
if bally <0+radius
bally = 0+radius
ballydirection=bounce(ballydirection)
endif
Jadelion
21
Years of Service
User Offline
Joined: 14th Jan 2003
Location:
Posted: 16th Feb 2003 23:13
Thanks Flashingblade, that worked. I was starting to worry that mabey no one actually used functions.

Login to post a reply

Server time is: 2024-11-24 02:03:46
Your offset time is: 2024-11-24 02:03:46