External Exam Download Resources Web Applications Games Recycle Bin

improved car | gml

objCar Create

speeed = 0;
velocityX = 0;
velocityY = 0;
angularVelocity = 0;
turnSpeed = 0.25;

objCar Step

direction += angularVelocity;
angularVelocity = angularVelocity * 0.95;
image_angle = direction;
x += velocityX;
y += velocityY;
velocityX = velocityX * 0.9;
velocityY = velocityY * 0.9;
speeed = speeed * 0.95;

if keyboard_check(vk_up){
  speeed += 0.2;
  velocityX=cos(degtorad(direction))*speeed;
  velocityY=-sin(degtorad(direction))*speeed;
}

if keyboard_check(vk_left){
  angularVelocity += turnSpeed * speeed;
}

if keyboard_check(vk_right){
  angularVelocity -= turnSpeed * speeed;
}

angularVelocity = clamp(angularVelocity, -5, 5)