Hello!
I have made my script and it is using allegro, The only thing that isn't working is moving the sprite. Why doesn't my sprite move?
Code:#include <allegro.h>
void myAllegroSetup()
{
allegro_init();
install_keyboard();
set_color_depth(32);
set_gfx_mode( GFX_AUTODETECT_WINDOWED, 600, 400, 0, 0);
}
void displayIntro()
{
BITMAP *introImage;
introImage = load_bitmap("open.bmp",NULL);
stretch_blit(introImage, screen, 0, 0, introImage->w, introImage->h, 0, 0, 600, 400); // Draws the stretched image onto the screen
textout_ex(screen, font, "Press any key to continue", 380, 380, makecol(255, 255, 255), -1);
readkey();
stretch_blit(introImage, screen, 0, 0, introImage->w, introImage->h, 0, 0, 600, 400); // Draws the stretched image onto the screen
textout_ex(screen, font, "How to play", 400, 220, makecol(255, 255, 255), -1);
textout_ex(screen, font, "___________", 400, 223, makecol(255, 255, 255), -1);
textout_ex(screen, font, " z = Talk/Action", 300, 247, makecol(255, 255, 255), -1);
textout_ex(screen, font, " x = Cancel", 300, 257, makecol(255, 255, 255), -1);
textout_ex(screen, font, "Arrow Keys = Move/Navigate Menus'", 300, 267, makecol(255, 255, 255), -1);
textout_ex(screen, font, "Press any key to continue", 380, 380, makecol(255, 255, 255), -1);
readkey();
}
void movePlayer(){
int playerX = 100;
int playerY = 100;
BITMAP *player;
player = load_bitmap("sprite/walk_none.bmp",NULL);
if( key[KEY_LEFT]){
playerX - 20;
draw_sprite( screen, player, playerX, playerY);
} else if( key[KEY_RIGHT]){
playerX + 20;
draw_sprite( screen, player, playerX, playerY);
} else if( key[KEY_UP]){
playerY + 20;
draw_sprite( screen, player, playerX, playerY);
} else if( key[KEY_DOWN]){
playerY - 20;
draw_sprite( screen, player, playerX, playerY);
}
}
}
int main(){
myAllegroSetup();
displayIntro();
movePlayer();
return 0;
}
END_OF_MAIN();