我与文件进行比较,但我的理解是+
表示添加和-
符号删除。新文件有拼写错误:
if (KEY_STATUS.spacr) {
为什么它由-
表示。它应该是+
,对吗?当我运行diff -u game_new.js game_old.js
时:
--- game_new.js 2018-06-12 02:03:32.000000000 -0700
+++ game_old.js 2018-06-12 02:03:22.000000000 -0700
@@ -4,9 +4,9 @@
//
KEY_CODES = {
- 13: 'enter',
32: 'space',
37: 'left',
+ 38: 'up',
39: 'right',
40: 'down',
70: 'f',
@@ -392,7 +392,7 @@
this.vel.rot = 0;
}
- if (KEY_STATUS.spacr) {
+ if (KEY_STATUS.up) {
var rad = ((this.rot-90) * Math.PI)/180;
this.acc.x = 0.5 * Math.cos(rad);
this.acc.y = 0.5 * Math.sin(rad);
@@ -406,7 +406,7 @@
if (this.delayBeforeBullet > 0) {
this.delayBeforeBullet -= delta;
}
- if (KEY_STATUS.enter) {
+ if (KEY_STATUS.space) {
if (this.delayBeforeBullet <= 0) {
this.delayBeforeBullet = 10;
for (var i = 0; i < this.bullets.length; i++) {
@@ -919,7 +919,7 @@
waiting: function () {
Text.renderText(ipad ? 'Touch Sreen to Start' : 'Press Space to Start', 36, Game.canvasWidth/2 - 270, Game.canvasHeight/2);
if (KEY_STATUS.space || window.gameStart) {
- KEY_STATUS.space = false; // hack so we don't move right away
+ KEY_STATUS.space = false; // hack so we don't shoot right away
window.gameStart = false;
this.state = 'start';
}
答案 0 :(得分:1)
我相信你跑的时候:
diff -u game_new.js game_old.js
来自左侧上的文件的更改被解释为源,并标有减号,而来自右侧的文件的更改是被视为目的地,并标有加号。
如果您希望显示-
和+
标签,请按相反的顺序运行diff
文件:
diff -u game_old.js game_new.js