I am trying to get the speed variable to change the speed of the ball, but when I set the dx and dy variables to the speed, they don't update after you lose a life. When I set dx and dy to the value of Xspeed and Yspeed, the speed doesn't change when you change difficulty.
I've tried setting the value of dx and dy to Xspeed and Yspeed because I thought it might keep the value instead of refreshing it, but it just doesn't change it when I want it to.
Full link to the code, https://codepen.io/Jacob-Bruce/pen/mQgbXa
// ball movement - change variables to change speed
var Xspeed = 2
var Yspeed = -2
var dx = Xspeed;
var dy = Yspeed;
function hardMode() {
   lives = 1;
   Xspeed = 7;
   Yspeed = -7;
   redraw();
}
I want the speed to be able to be changed with the difficulty buttons, and it to stay the same speed until you either die or change difficulty. Right now, it either changes speed once and doesn't at all.
