Newb in training: Speed of player

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
Pennywise
Chaos Rift Cool Newbie
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

Newb in training: Speed of player

Post 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.
User avatar
Bakkon
Chaos Rift Junior
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

Post 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.
User avatar
Pennywise
Chaos Rift Cool Newbie
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

Post 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.
User avatar
Pickzell
Chaos Rift Junior
Chaos Rift Junior
Posts: 233
Joined: Sat May 16, 2009 10:21 am

Re: Newb in training: Speed of player

Post 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.
I'm an altogether bad-natured Cupid.
User avatar
Bakkon
Chaos Rift Junior
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

Post 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
User avatar
Pennywise
Chaos Rift Cool Newbie
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

Post by Pennywise »

Thanks for all your help.
Post Reply