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

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

The problems (well, besides the complete lack of indentation) are twofold:
1) is that you don't time your code. Read the FAQ.
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. :P

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.

Thread #590360. Printed from Allegro.cc