Im making simple 2D space shooter with use of html5 and JavaScript.
The idea is simple, shoot down as many aliens as you can.
I made it to the point where I have player which can move and rotate, but I want the player to move in the angle, like 80s Asteroids (you set angle then press forward key and ship goes forward in that angle)
my movement now is simple:
up = y -= speed * delta time
down y += speed * delta time
left x -= speed * delta time
right x += speed * delta time
my rotation is made like this:
ctx.save();
ctx.translate(this.x + this.w / 2, this.y + this.h / 2);
ctx.rotate(this.angle);
Draw.Rect(ctx,this.w /2 * (-1),this.h / 2 * (-1),this.w,this.h,"red",1);//context,x,y,w,h,color,opacity
ctx.restore();
angle:
if(keys.e)this.angle += 0.1;
if(keys.q)this.angle -= 0.1;
