Can't figure why my object isn't moving-ALLEGRO5 library

Hello,
I've just started using allegro5. For beginning I'm trying to make a simple program that makes a rectangle move constantly in a chosen direction until other will be chosen by pressing the key(just like snake). But when I press any key it moves only once. Even when I press ESC it doesn't close the window but moves the rectangle up. It seems that my WHILE loops don't work properly and I can't figure out why. Thank You in advance for help !

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
  #include <allegro5/allegro.h>
#include <allegro5/allegro_primitives.h>
#include <conio.h>

using namespace std;

enum enumik
{
    dol,
    gora,
    lewo,
    prawo
};
int main()
{
    al_init();
    al_install_keyboard();
    al_init_primitives_addon();

const float FPS=60;

ALLEGRO_KEYBOARD_STATE klawiatura;
ALLEGRO_DISPLAY *display;
display=al_create_display(300,300);
al_set_window_title(display,"gunwo");
ALLEGRO_EVENT_QUEUE *kolejka;
kolejka=al_create_event_queue();
al_register_event_source(kolejka,al_get_display_event_source(display));
al_register_event_source(kolejka,al_get_keyboard_event_source());
ALLEGRO_EVENT zdarzenie;
ALLEGRO_TIMER *timer;
timer= al_create_timer(1.0 / FPS);
al_register_event_source(kolejka,al_get_timer_event_source(timer));
al_start_timer(timer);


int x=10;
int y=10;
int skok=5;
al_get_keyboard_state(&klawiatura);
enumik kierunek;


while(!al_key_down(&klawiatura,ALLEGRO_KEY_ESCAPE))
{
    al_get_next_event(kolejka,&zdarzenie);
    if (zdarzenie.type==ALLEGRO_EVENT_KEY_DOWN)
    {
      if(zdarzenie.keyboard.keycode==ALLEGRO_KEY_DOWN)
        kierunek=dol;

      if(zdarzenie.keyboard.keycode==ALLEGRO_KEY_UP)
        kierunek=gora;

      if(zdarzenie.keyboard.keycode==ALLEGRO_KEY_RIGHT)
        kierunek=prawo;

      if(zdarzenie.keyboard.keycode==ALLEGRO_KEY_LEFT)
        kierunek=lewo;


if (kierunek==dol)
    y+=skok;
if (kierunek==gora)
    y-=skok;
if (kierunek==prawo)
    x+=skok;
if (kierunek==lewo)
    x-=skok;

al_rest(0.2);
    }
    al_clear_to_color(al_map_rgb(100, 0, 0));
    al_draw_rectangle(x, y, x + 10, y + 10, al_map_rgb(44, 117, 255), 1);
    al_flip_display();

}


al_destroy_display(display);
al_destroy_event_queue(kolejka);
return 0;



}
No one even answers my question though i've asked it on few forums, is it because no one knows how to answer or isn't it clear enough? Help pls I'm new here ;P
I am not familiar with allegro at all, but I think the problem is that you close the if statement block on line 72 when it should be closed on line 60.
Thank You for answer but it doesn't fix my problem;(
Topic archived. No new replies allowed.