Asteroids - How to accelerate in the correct direc

Hi

Im very new to making games, and Im trying to do an asteriods type game. I currently can make my ship rotate left and right using the left and right keys, but I now want it to accelerate in the direction that the ship is facing when ‘up’ is pressed. Can anyone help?

Thanks in advance to anyone who replies…

Andy

Well I assume you have your direction stored as a vector2f(x,y)

So do this

for every tick
if(speed <maxSpeed)
speed += acceleration

position += direction *speed