I cant see the physikal movement
Max S

Hi

first of all, sorry for my bad English. I try my best^^.

i wont to write a very simple code, that could calculate a physic variable with a function.

this is the simplest version of the code:

```int fall(int *h) {
int g = 9;
int t = 10;

if (h > 0) {
*h = (g / 2 * (t * t));
}
}
```

this is a very simple kind to calculate it!! but first i wont to try if its work trough given consts and after it I will change the code so, that it could calculate the time and the high by itself

but its very simple, thers a picture wich should fall down, but if i run the code, the ball is on the ground.
i think i need timer or extra operators for the movement, which reduce the fps. But i think everybody who worked with graphics movement, know what i mean.

piccolo
```int fall(int &h) {
int g = 9;
int t = 10;

if (h > 0) {
h *= (g / 2 * (t * t));
}
}
```

or

```int fall(int &h) {
int g = 9;
int t = 10;

if (h > 0) {
h = h*(g / 2 * (t * t));
}
}
```

Max S

no this istn what i mean

look this is the code

 1 int fall(int *h) { 2 3 int g = 9; 4 int t = 10; 5 6 if (h > 0) { 7 *h = (g / 2 * (t * t)); 8 } 9 } 10 11 int main(int argc, char *argv[]) 12 { 13 allegro_init(); 14 install_keyboard(); 15 16 set_graphic_mode(); 17 if (set_graphic_mode <= 0) { 18 allegro_message("Unable to set graphic mode!"); 19 exit(0); 20 } 21 22 int x = 0; 23 int y = 0; 24 25 BITMAP *bild = load_bitmap("bild.bmp" , NULL); 26 27 while (!key[KEY_ESC]) 28 { 29 acquire_screen(); 30 clear(screen); 31 fall(&y); //y get the value of h 32 blit(bild,screen, 0, 0, x, y, bild->w, bild->h); 33 release_screen(); 34 readkey(); 35 36 destroy_bitmap(my_pic); 37 38 } 39 }END_OF_MAIN()

if i start it
the picture is imediatly at the ground, whithout that i can see how its falls

gnolam

My god man, learn to use indentation!

The problems (well, besides the complete lack of indentation) are twofold:
2) t starts at 10, making h start at 450, which, depending on the graphics mode you've set, may be outside the screen.

Oh, and I know capitalization exists in German, so please use it in English as well.

Max S

Ok Ok sorry, but Im in stress here.

Ok i try it.
And if i get a problem, I will knew whom I have to ask ^^

Onewing
Quote:

t starts at 10, making h start at 450, which, depending on the graphics mode you've set, may be outside the screen.

I think it'd be 500, since he's using ints. Or is it 400? I can never remember if integer division rounds up or down.

@Max S: Timer logic will help maintain the proper speed on varying computers. You also need to understand the logic of a game loop. You only need to do a portion of your "fall" function each loop. You can add a float value to multiply the final calculation to make it only do 10% of the calculation per game loop. There are methods, I'm just rambling about some food-for-thoughts.

Max S

At the beginn I sad that this is just a simple version of the code.
When it's done, the funktion calculate the h und how long it needs to fall, by it self.

But first i will try to make this counter work, this is the harder part for me.

Kauhiz
Quote:

I think it'd be 500, since he's using ints. Or is it 400? I can never remember if integer division rounds up or down.

Doesn't round at all. It just chops the decimal part off. So 400.

Onewing
Quote:

Doesn't round at all.

You guys and your technical accuracy. Bah, VB6.0 I believe did some form of rounding and I just carried the concept.