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.
Newb in training: Speed of player
Moderator: Coders of Rage
- Bakkon
- Chaos Rift Junior
- Posts: 384
- Joined: Wed May 20, 2009 2:38 pm
- Programming Language of Choice: C++
- Location: Indiana
Re: Newb in training: Speed of player
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.
Then have your arrow keys manipulate the Player's speed variables and when you update, adjust the position by the speed.
Just make a class for your player.
Code: Select all
class Player
{
Sprite player;
float positionX;
float positionY;
float speedX;
float speedY;
}
- Pennywise
- Chaos Rift Cool Newbie
- Posts: 55
- Joined: Tue Sep 22, 2009 1:36 pm
- Favorite Gaming Platforms: Megadrive(Genesis), Dreamcast, SNES, Nintendo 64
- Programming Language of Choice: C, C++ and Java
- Location: England
Re: Newb in training: Speed of player
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.
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
I've broken these rules 20 times now at least, don't worry :pForum 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'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.
I'm an altogether bad-natured Cupid.
- Bakkon
- Chaos Rift Junior
- Posts: 384
- Joined: Wed May 20, 2009 2:38 pm
- Programming Language of Choice: C++
- Location: Indiana
Re: Newb in training: Speed of player
I've only used SDL, not Allegro, so I don't know. You should watch Rachel's videos.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.
http://www.youtube.com/view_play_list?p ... 6F495BD17E
- Pennywise
- Chaos Rift Cool Newbie
- Posts: 55
- Joined: Tue Sep 22, 2009 1:36 pm
- Favorite Gaming Platforms: Megadrive(Genesis), Dreamcast, SNES, Nintendo 64
- Programming Language of Choice: C, C++ and Java
- Location: England
Re: Newb in training: Speed of player
Thanks for all your help.