forked from newagebegins/BattleCity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ead43c6
commit 7b73738
Showing
65 changed files
with
201 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
describe("TankColor", function () { | ||
describe("#update", function () { | ||
var color; | ||
|
||
beforeEach(function () { | ||
color = new TankColor(); | ||
color.setColors([[0,1],[0,2],[1,2],[0,0]]); | ||
}); | ||
|
||
it("no hits", function () { | ||
expect(color.getColor()).toEqual(0); | ||
color.update(); | ||
expect(color.getColor()).toEqual(1); | ||
color.update(); | ||
expect(color.getColor()).toEqual(0); | ||
color.update(); | ||
expect(color.getColor()).toEqual(1); | ||
}); | ||
|
||
it("one hit", function () { | ||
color.hit(); | ||
expect(color.getColor()).toEqual(0); | ||
color.update(); | ||
expect(color.getColor()).toEqual(2); | ||
color.update(); | ||
expect(color.getColor()).toEqual(0); | ||
color.update(); | ||
expect(color.getColor()).toEqual(2); | ||
}); | ||
|
||
it("two hits", function () { | ||
color.hit(); | ||
color.hit(); | ||
expect(color.getColor()).toEqual(1); | ||
color.update(); | ||
expect(color.getColor()).toEqual(2); | ||
color.update(); | ||
expect(color.getColor()).toEqual(1); | ||
color.update(); | ||
expect(color.getColor()).toEqual(2); | ||
}); | ||
|
||
it("three hits", function () { | ||
color.hit(); | ||
color.hit(); | ||
color.hit(); | ||
expect(color.getColor()).toEqual(0); | ||
color.update(); | ||
expect(color.getColor()).toEqual(0); | ||
color.update(); | ||
expect(color.getColor()).toEqual(0); | ||
color.update(); | ||
expect(color.getColor()).toEqual(0); | ||
}); | ||
|
||
it("four hits", function () { | ||
color.hit(); | ||
color.hit(); | ||
color.hit(); | ||
color.hit(); | ||
expect(color.getColor()).toEqual(0); | ||
color.update(); | ||
expect(color.getColor()).toEqual(0); | ||
color.update(); | ||
expect(color.getColor()).toEqual(0); | ||
color.update(); | ||
expect(color.getColor()).toEqual(0); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
function TankColor() { | ||
this._colors = [[0,0]]; | ||
this._hit = 0; | ||
this._color = 0; | ||
} | ||
|
||
TankColor.prototype.setColors = function (colors) { | ||
this._colors = colors; | ||
}; | ||
|
||
TankColor.prototype.getColor = function () { | ||
return this._colors[this._hit][this._color]; | ||
}; | ||
|
||
TankColor.prototype.update = function () { | ||
this._color = this._color == 0 ? 1 : 0; | ||
}; | ||
|
||
TankColor.prototype.hit = function () { | ||
this._hit++; | ||
if (this._hit >= this._colors.length) { | ||
this._hit = this._colors.length - 1; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters