Wie bewege ich einen Würfel?

1 Antwort

Vom Fragesteller als hilfreich ausgezeichnet
class Cube:
    def __init__(self):
        position = (0.0, 0.0, 0.0);
        velocity = (0.0, 0.0, 0.0);
        mass = 1.0;

    def update(self, dt, external_forces):
        velocity += dt * (external_forces / mass);
        position += dt * velocity;

cube = new Cube();
external_forces = (1.0, -9.81, 0.0);
cube.update(0.1, external_forces);
external_forces = (0.0, -9.81, 0.0);
last_time = now.time();
while(true):
    curr_time = now.time();
    dt = curr_time - last_time;
    cube.update(dt, external_forces);
    last_time = curr_time;