0

I am making a 2d star wars game with allegro4 and I want to add a space ship image which is able to move(with keyboard up,down,right,left).

I can't find the fuction about that.Can you help me?

  • Allegro does not have a specific function to move an image based on key movements. That is your job to do. Allegro knows how to draw the stuff. It is up to you to decide what the stuff does and how it interacts. – rlam12 Aug 18 '17 at 16:11

1 Answers1

2

There's the if(key[KEY_UP]), if(key[KEY_DOWN]),ect, functions that can read keypresses in Allegro 4. It's up to you to move the sprite based on that. You can do something like

if(key[KEY_UP]){
    player_y+=10;
}
draw_bitmap(bitmap,character_sprite,player_x,player_y);

That will move the character sprite up when the up key is pressed.

danwardvs
  • 53
  • 1
  • 8