Computer Science Canada Gravity Redone |
Author: | Zacebdal [ Sun Oct 22, 2006 7:03 pm ] | ||
Post subject: | Gravity Redone | ||
This is yet another attempt at a gravity program..again, any suggestions or comments are more than welcome and very much appreciated. Thanks.
|
Author: | Cervantes [ Sun Oct 22, 2006 9:17 pm ] | ||
Post subject: | |||
First, I suggest you use reals instead of ints and just round them before drawing. It's more precise that way. Second, your approach of multiplying / dividing by 2 is interesting, but still fundamentally wrong. Gravity doesn't work by doubling the speed of a falling object with every step of time. Rather, it increases the speed of a falling object, linearly. That means the speed of the falling object increases linearly with time. That means I'm adding a constant value to the speed of the falling object with each step of time. Here's my modifications on your code:
|
Author: | Nigrev [ Mon Dec 04, 2006 6:12 pm ] |
Post subject: | |
ah...yes vey good... now n00b question... what is purpose of put y? |
Author: | Cervantes [ Mon Dec 04, 2006 10:48 pm ] |
Post subject: | |
It was probably for debugging -- to see the value of a variable in real time. |
Author: | Nigrev [ Tue Dec 05, 2006 9:53 pm ] |
Post subject: | |
put y... it's not displayed on the window, but anyway... I need some explanation on some values for the variables. I'm trying to implement gravity on a program (2d scroller game) and so this is is the only way I can learn. I used some of this code to experiment, but it's screwing up my background pictures...whoops. Does this work with BSprites? The cls and View.Updates, it seems, needs to be in a certain location around the gravity mechanism, but that would mean fiddling with the module, or at least studying it. My head hurts. |
Author: | ericfourfour [ Tue Dec 05, 2006 10:43 pm ] | ||
Post subject: | |||
BSprites shouldn't be that hard to use. I've never used it but from what I understand it is just add the images, tell it when to switch images, and draw the images. Don't go giving yourself a headache over it. Libraries like BSprite are made so you don't have to worry about what it does on the inside (that means no need to study it). Not that there is anything wrong with studying it. The way I've always used View.Update and cls was like this.
|