Allegro C++ Help

OK so im following this tutorial and i did everything he did and i get no errors but what happens is the player doesnt appear to move when i press the up down left right keys and when i grab the game window it shows that the player did move but it doesnt show it on screen, sometimes it works and sometimes it doesnt, what the hell? its starting to make me mad because i absolutley cannot figure this out, i followed his tutorials exactly. here is the code, can someone please tell me what i did wrong:

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
#include <allegro.h>
#include <fstream>
#include <iostream>
#include <string>
#define Down 0
#define Left 32
#define Right 64
#define Up 96


using namespace std;


int main()
{
 allegro_init();
 install_keyboard();
 install_mouse();
 set_color_depth(16);
 set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
 clear_to_color(screen, makecol(0, 0, 0));
 set_window_title("Game");
 BITMAP *Buffer = create_bitmap(640, 480);
 BITMAP *GrantCity = load_bitmap("Testmap.bmp", NULL);
 BITMAP *Player = load_bitmap("Player.bmp", NULL);
 bool done = false;
 int x, y;
 x = 0, y = 400;
 int ImageX = 32, ImageY = Down;
 
 while(done == false){
   if(key[KEY_ESC])
     done = true;
      
   if(key[KEY_RIGHT]){
     ImageY = Right;
     x += 5;
     }
   else if(key[KEY_LEFT]){
     ImageY = Left;
     x -= 5;
     }
   else if(key[KEY_DOWN]){
     ImageY = Down;
     y += 5;
     }
   else if(key[KEY_UP]){
     ImageY = Up;
     y -= 5;
     }

     
   if(!key [KEY_RIGHT] && !key [KEY_LEFT] && !key [KEY_UP] && !key [KEY_DOWN])
    ImageX = 32;
   else
    ImageX += 32;
   if(ImageX > 64)
    ImageX = 0;


      blit(GrantCity, Buffer, 0, 0, 0, 0, 640, 480);
      masked_blit(Player, Buffer, ImageX, ImageY, x, y, 32, 32);
      blit(Buffer, screen, 0, 0, 0, 0, 640, 480);
      //rest(40);
      //clear_bitmap(Buffer);
      }

 
  return 0; 
}
END_OF_MAIN()
I'm assuming allegro.h is some game library. I probably won't be able to help you much because I can't compile the code at the moment. However, lines 64 and 65 seem to be calling functions, so is there a reason you commented them out or is it just a mistake? If you copy/pasted this code and don't know what commenting is, remove the // from:

1
2
//rest(40);
//clear_bitmap(Buffer); 


Otherwise, sorry for treating you like a complete noob :P
Topic archived. No new replies allowed.