Skip to content
This repository has been archived by the owner on Feb 19, 2019. It is now read-only.

一点改进建议 #9

Closed
ylkangpeter opened this issue Dec 2, 2018 · 1 comment
Closed

一点改进建议 #9

ylkangpeter opened this issue Dec 2, 2018 · 1 comment

Comments

@ylkangpeter
Copy link

目前车是预估60+秒会完成然后结算,但由于是不同的线程,在性能有差别的时候有影响。比如我是二星z4,跑几轮就会乱。考虑放在同步块里?

{

......

	// 按加速
	run()
	// 跑完之后
	afterRun(times);

}

function run() {
	var startTime = new Date().getTime()
	// 定时点击氮气
	while (!raceDone(startTime)) {
		robot.click(height * 4 / 5, width / 2);
		var now = new Date().getTime();
		sleep(1000)
	}
	toastLog("用时:" + (new Date().getTime() - startTime) / 1000)
}

function raceDone(startTime) {
	// 3秒采样一次
	var now = new Date().getTime();
	if (now > startTime + 3000) {
		var img = captureScreen();
		var goldenPoint = images.pixel(img, profile.goldenPoint.x, profile.goldenPoint.y);
		if (colors.equals(goldenPoint, "#c3fb12")) {
			toastLog("比赛结束")
			return true;
		}
	}
	return false;
}
@zlsq
Copy link
Owner

zlsq commented Dec 7, 2018

我觉得不会出现乱的情况啊, 我这个倒计时是按照最高性能的车跑得, 就算车性能比较低, 会在结束前弹出log "跑完了", 但不影响整体结果的

@zlsq zlsq closed this as completed Dec 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants