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 / QuestionAboutPhysics-KindOf.

Author
Message
squids
21
Years of Service
User Offline
Joined: 1st May 2003
Location: United Kingdom
Posted: 1st Apr 2004 20:36
Hey people,

Before I write this post I would just like to mention that I have a lack of knowledge in the area of Physics and generally anything else which comes in the form of COS or SIN. I got an 'E' in Math's and well most of the things I need to know were never actually covered at school, at my level at least so I tend to get into a bit of a pickle when it comes to the more interesting things.

Well thats my whining and attempt at explaining myself out of the way ..I will continue!

I was just playing with a sprite trying to create the effect of a bouncing ball,. I have managed to create something which resembles the effect. However the code is bad.

I am using just two variables 'PositionY#' and 'Velocity#' - I am not sure where to use a gravity variable and even energy/gained/lost etc.

In short.. I need a little bit of help in the way I should go about making a simple bounce motion including effects of gravity, velocity and energy expenditure of the bounce and whatnot. I just keep getting in a mess when thinking about the physical side of things and then trying it in code. I either get a ball flying all over the screen or it will sit still etc etc,.

The code I started with should be below,.. eek. I noticed whilst looking at other code that most people use at least six million variables and lots of interesting gosub's. Also I had problems with getting the ball to settle once it should have stopped bouncing. My PositionY and Velocity variables were having a battle over the position of the sprite.

I solved the problem of the squiggly ball by adding a value to my ball's position :


I figured that out accidently whilst adding another sprite to bounce at a different speed. That is what led me to believe whatever I was doing was bad and wrong and that I should probably come and spam the forums with my apparently pointless life story on the matter! arf.diddle >.<

I think i'll shut up now. I hope someone can help me understand what I need to do to create an effective bouncing ball. Thanks very much for your time.

Regards
Ash.

```````
P.S - I havnt had much luck in finding a complete tutorial on the fundamentals of trigonometry and other such goodies. If anyone has a link or an idea where I can brush up/learn some general math stuff.

.Arf..
Maelstrom
20
Years of Service
User Offline
Joined: 24th Feb 2004
Location: United Kingdom
Posted: 1st Apr 2004 21:00
I think i must have had the same Teacher in school as you did then because i really struggle with trig also. You might(or not)find this link helpfull.

http://aleph0.clarku.edu/~djoyce/java/trig/
Nitro Methane
20
Years of Service
User Offline
Joined: 20th Jan 2004
Location: Anderson , SC
Posted: 1st Apr 2004 21:10
Try this link http://www.flipcode.com/geometry/index.shtml
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 1st Apr 2004 21:34 Edited at: 1st Apr 2004 21:39
My trig teacher retired after spring break, leaving us with a greek sub for the remainder of the year. Umm yea, most people either got a D or F. Luckily I got the D. Very baaad teacher. School offered free summer classes and to retake our final because so many people failed because of this guy.

I have an old DBC demo I made of the Nvidia meteor demo. In it, it has several particles which bounce around on a matrix until they die. I can't think of an easy way to explain it without looking at my code first. When I get home, I'll take a look at it and show you a brief example.

Just to help you get started here.
Lets say the maximum height of the first bounce is 10. On the second bounce, you'll want it to bounce not quite as high as before, right? Easiest way, multiply the old height by some number between 0 and 1. Let's say 0.8. So the height of the second bounce will reach 8.(10*0.8). Third bounce will be 6.4(8*0.8), fourth bounce will be 5.12, 4, 3.2, 2.6, 2, 1.6, 1.3, 1, 0.85, etc.... Now the number will never reach absolute zero, so you can check to see when that bounce height is less than 1. At that point, stop the bounce calculation.

"eureka" - Archimedes
squids
21
Years of Service
User Offline
Joined: 1st May 2003
Location: United Kingdom
Posted: 1st Apr 2004 21:36
Thanks

Maelstrom, Mustang I will start reading the sites over. They both seem very good.

**
Also, just whilst I think of this, does anyone have any information on Convert File>DATA submenu item? I gave it a whirl and I can only get text files working. I'm not sure if you should be able to convert other files. I remember someone use to keep their midi information in the DATA section.

"Access violation at address 00404983 in module 'editor.exe'. Read of address 01421000" ..01441000 ..and other such address values on other files.

*** Arrgh! Just one more question! I havnt had a lot of time the recently so I am totally out of wack! ..When I installed DarkBASIC(Pro) originally on my ex machine and on my new machine, every now and again I would be asked for the CD yet I havnt seen the message for ages and I just wrote a cruddy game. I am sure I have compiled enough for the message, whats going on? eeek.! (I havnt used a CD crack etc).

Sorry if im going on about a load of crap!

Many Thanks,
Ash.

.Arf..
squids
21
Years of Service
User Offline
Joined: 1st May 2003
Location: United Kingdom
Posted: 1st Apr 2004 21:38
Thanks Phaelax

I'm glad its not just me who got jipped in the math's department ..Meant in the nice way.

.Arf..
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 1st Apr 2004 21:41
If it's not asking for it, don't worry about it. Also, I edited my message above to get you a little info.

"eureka" - Archimedes
squids
21
Years of Service
User Offline
Joined: 1st May 2003
Location: United Kingdom
Posted: 1st Apr 2004 22:11 Edited at: 1st Apr 2004 22:12
Thanks Phaelax,

I had that general understanding when writing my bounce thingy, but now I actually understand what I was multiplying varibles by. If you get what I mean. Although its all quite simple, it sometimes takes a little jolt or just to view something at a slightly different angle,. its all good fun!

Thanks I finally spotted the Edit post: button,. I spent a while looking for that..

..dunno why I didint use it >.<

.Arf..
zircher
21
Years of Service
User Offline
Joined: 27th Dec 2002
Location: Oklahoma
Posted: 1st Apr 2004 22:30
sprite 1,320,PositionY#+0.999,1

A more elegant solution is to use the INT() function since the sprite command is expecting an integer value and not a float.

sprite 1, 320 int(positionY), 1
--
TAZ

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 1st Apr 2004 22:48
I think it casts to int automatically.

"eureka" - Archimedes

Login to post a reply

Server time is: 2024-11-11 10:11:34
Your offset time is: 2024-11-11 10:11:34