Page 1 of 1

Newb in training: Speed of player

Posted: Tue Sep 22, 2009 4:17 pm
by Pennywise
Hi forums :D
I am pretty new to C++ and wondering how you set the speed of a character sprite in Allegro.
I can't find any Allegro books, and I can't find any online tutorials on Allegro which cover the speed of the character that you control with the keyboard.

Sorry if I don't make sense to some people... i'm still finding my way around C++ and Allegro.

Re: Newb in training: Speed of player

Posted: Tue Sep 22, 2009 4:21 pm
by Bakkon
This probably should have been posted in your other thread so you don't clog up the forums.

Just make a class for your player.

Code: Select all

class Player
{
     Sprite player;
     float positionX;
     float positionY;
     float speedX;
     float speedY;
}
Then have your arrow keys manipulate the Player's speed variables and when you update, adjust the position by the speed.

Re: Newb in training: Speed of player

Posted: Tue Sep 22, 2009 4:33 pm
by Pennywise
Sorry about that, I'm new to forums in general.

Sorry if im asking much but could you give me an example of how I would write the code for the player input.
Thanks.

Re: Newb in training: Speed of player

Posted: Tue Sep 22, 2009 4:40 pm
by Pickzell
Forum Rules: Read before posting! wrote:This forum is here for those wishing to learn. This is not a replacement for Google. This is not us doing your homework for you. This is not for us spending hours to do what you're too lazy to do yourself. This is for those willing and able to learn.
I've broken these rules 20 times now at least, don't worry :p

I'll probably come off somewhat douchebaggy on this, but you could easily google this and you wouldn't have to wait for someone to reply to you. Then if you don't understand it come on here and ask.

Re: Newb in training: Speed of player

Posted: Tue Sep 22, 2009 4:51 pm
by Bakkon
Pennywise wrote: Sorry if im asking much but could you give me an example of how I would write the code for the player input.
Thanks.
I've only used SDL, not Allegro, so I don't know. You should watch Rachel's videos.

http://www.youtube.com/view_play_list?p ... 6F495BD17E

Re: Newb in training: Speed of player

Posted: Wed Sep 23, 2009 11:56 am
by Pennywise
Thanks for all your help.