Hi,
So, im trying to create a physics engine from scratch, so I decided to start with a basic 1 dimensional bouncing object, here is what I have so far:
The object falls from height 100, does a crappy bounce to half the height then SHOULD bounce a third then quater etc, but it gets stuck around a fith and bounces up to 20 repeatedly... Also,it is 1:20 in the morning, so I haven't designed this even to slightly obey any physics laws....
If you have any improvement tips, they will be welcomed warmly! But for now, I NEED TO SLEEP!
L99
So, im trying to create a physics engine from scratch, so I decided to start with a basic 1 dimensional bouncing object, here is what I have so far:
#include <iostream> using namespace std; float speed = 1; int mult = 0; int height2; int div = 2; float createObject(float height) { height2 = height; while(height2 > 0) { speed = speed + mult; height2 = height2 - speed; mult++; cout << speed << " " << height2 << endl; } while(div < 10) { speed = 0; mult = 0; height2 = 0; while(height2 < height/div) { speed = speed + mult; height2 = height2 - speed; mult--; cout << speed << " " << height2 << endl; } speed = 0; mult = 0; while(height2 > 0) { speed = speed + mult; height2 = height2 - speed; mult++; cout << speed << " " << height2 << endl; } div++; } } int main() { createObject(100); }(Sorry if it doesn't compile on GCC/G++, I'm using sourceLair online...)
The object falls from height 100, does a crappy bounce to half the height then SHOULD bounce a third then quater etc, but it gets stuck around a fith and bounces up to 20 repeatedly... Also,it is 1:20 in the morning, so I haven't designed this even to slightly obey any physics laws....
If you have any improvement tips, they will be welcomed warmly! But for now, I NEED TO SLEEP!
L99