-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.html
114 lines (87 loc) · 3.03 KB
/
test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<html>
<head>
<script type="text/javascript">
console.log("--------BEGIN--------------");
class Map
{
constructor(height, width, spriteMap)
{
}
get Size()
{
}
get Map()
{
}
SetTileValue(x,y, val)
{
}
GetTileValue(x,y)
{
}
IsPositionBlocked(x,y)
{
}
BuildGrid(hight, width)
{
}
};
class Tank
{
constructor(map)
{
}
get Name()
{
}
get Score()
{
}
get Position()
{
}
set Position(pos)
{
}
Move(x,y)
{
}
};
//Unit Tests
var spriteMap = {
"R": {
"x":6,
"y":3,
"blocking": true,
"draw": function(x,y)
{
var rockX = Math.floor(Math.random()*(rockCellsHigh - 0 +1));
var rockY = Math.floor(Math.random()*(rockCellsWide - 0 +1));
drawSpriteFromSheetToCoords(rocksSheet, x, y, cellWidth, cellHeight, rockX, rockY, rockWidth, rockHeight);
}
}
};
var gameBoard = new Map(10,10, spriteMap);
var player1 = new Tank(gameBoard);
//If I give you new Asserts Put Them Between HERE
//And HERE
//Ensure the game grid is of the appropriate height and width and is reporting Size as it should.
console.assert(gameBoard.Size.width == 10 && gameBoard.Size.height == 10, "Map Does Not Report The Correct Size.");
//Set the value of x=5, y=5 in the game grid to "R" which should be a blocking tile as specified in the spriteMap.
gameBoard.SetTileValue(5,5,"R");
//Make sure that the value at X=5,Y=5 is R as it should be.
console.assert(gameBoard.GetTileValue(5,5) == "R", "Map Does Not Report Correct Value At Specified X,Y");
//Then, ensure that it reports Blocking as it should.
console.assert(gameBoard.IsPositionBlocked(5,5), "Map Does Not Indicate Blocked Tile Where It Should.");
//Move the player to position x=1,y=1
player1.Move(1,1);
//Make sure that the players position is updated to the new location and the player shows on the game grid at x=1, y=1
console.assert(player1.position.x == 1 && player1.position.y == 1 && gameBoard.GetTileValue(player1.position.x, player1.position.y) == "1", "Map Does Not Indicate Player At Specified Location");
//Make sure the player was MOVED to x=1, y=1 and the original tile is reset to 0
console.assert(gameBoard.GetTileValue(0,0) != "1", "Player should no longer be on this tile. Expected 0 here got 1.");
</script>
</head>
<body>
<h1> You Can Do It!!!!!</h1>
</body>
</html>