Tarkan Genç
Tarkan Genç

Reputation: 21

How to put an moving image at Allegro

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?

Upvotes: 0

Views: 265

Answers (1)

danwardvs
danwardvs

Reputation: 68

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.

Upvotes: 2

Related Questions