Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Barqawiz committed Oct 1, 2024
2 parents c5b9239 + 68071d9 commit e27af0a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions resource/eyes.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,18 @@ function draw(timestamp) {

ctx.clearRect(0, 0, canvas.width, canvas.height);

// update lookAngle globally for both eyes
// update lookAngle globally
if (isLookingAround && !lookPause) {
lookAngle += 0.05 * lookDirection; // increased speed
if (Math.abs(lookAngle) > Math.PI / 4) { // limit angle to ±45 degrees
// speed
lookAngle += 0.01 * lookDirection;
if (Math.abs(lookAngle) > Math.PI / 4) {
// limit angle to ±45 degrees
lookPause = true;
setTimeout(() => {
lookPause = false;
lookDirection *= -1; // change direction after pause
}, 500); // shorter pause for smoother movement
// change direction after pause
lookDirection *= -1;
}, 500 /*shorter pause for smoother movement*/);
}
}

Expand Down

0 comments on commit e27af0a

Please sign in to comment.