Commit d64bc800 authored by Tt's avatar Tt

perf: 提高鱼的移动速度以增强游戏体验

parent e3bc91dc
...@@ -994,7 +994,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -994,7 +994,7 @@ export class PlayComponent implements OnInit, OnDestroy {
// 计算鱼从右侧游到左侧所需的时间(毫秒) // 计算鱼从右侧游到左侧所需的时间(毫秒)
// 假设鱼的速度为1像素/帧,帧率约为60fps,则速度约为60像素/秒 // 假设鱼的速度为1像素/帧,帧率约为60fps,则速度约为60像素/秒
// 屏幕宽度加上鱼的宽度,再除以速度,得到鱼游过整个屏幕的时间 // 屏幕宽度加上鱼的宽度,再除以速度,得到鱼游过整个屏幕的时间
const fishSpeed = 1; // 鱼的移动速度 const fishSpeed = 2; // 鱼的移动速度
const fishWidth = 374 * this.g_mapScale * (type === 'small' ? 0.7 : 1); // 估计的鱼宽度 const fishWidth = 374 * this.g_mapScale * (type === 'small' ? 0.7 : 1); // 估计的鱼宽度
const screenWidth = this.g_canvasWidth + fishWidth * 0; // 屏幕宽度加上鱼的宽度 const screenWidth = this.g_canvasWidth + fishWidth * 0; // 屏幕宽度加上鱼的宽度
const fishCrossingTime = (screenWidth / fishSpeed) * (1000 / 60); // 鱼游过屏幕所需的时间(毫秒) const fishCrossingTime = (screenWidth / fishSpeed) * (1000 / 60); // 鱼游过屏幕所需的时间(毫秒)
...@@ -1044,7 +1044,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -1044,7 +1044,7 @@ export class PlayComponent implements OnInit, OnDestroy {
console.log('Is correct:', isCorrect); console.log('Is correct:', isCorrect);
// 保存鱼的原始速度,用于后续恢复 // 保存鱼的原始速度,用于后续恢复
const originalSpeed = fish.speed || 0.3; const originalSpeed = fish.speed || 2;
// 点击后立即停止鱼的运动 // 点击后立即停止鱼的运动
fish.speed = 0; fish.speed = 0;
...@@ -2974,7 +2974,7 @@ export class PlayComponent implements OnInit, OnDestroy { ...@@ -2974,7 +2974,7 @@ export class PlayComponent implements OnInit, OnDestroy {
fish.ref.y = (this.currentFishIndex % 2 == 0 ? 400 : 300) * this.g_mapScale; // Math.random() * (this.g_canvasHeight * 0.35) + this.g_canvasHeight * 0.25; // 在屏幕中间区域随机高度 fish.ref.y = (this.currentFishIndex % 2 == 0 ? 400 : 300) * this.g_mapScale; // Math.random() * (this.g_canvasHeight * 0.35) + this.g_canvasHeight * 0.25; // 在屏幕中间区域随机高度
// 设置鱼的游动速度 // 设置鱼的游动速度
fish.speed = 1; fish.speed = 2;
// 确保鱼已添加到渲染队列中 // 确保鱼已添加到渲染队列中
// createFish 方法中已经调用了 render 方法,但为了确保,这里再次检查 // createFish 方法中已经调用了 render 方法,但为了确保,这里再次检查
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment