Skip to content
This repository was archived by the owner on Oct 19, 2025. It is now read-only.

Commit c36f33c

Browse files
committed
Adds an outside wall to the arena and makes the wall and lines fade slightly between two colors
1 parent 9aa06bb commit c36f33c

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

Client/js/drawGameBoard.js

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,22 @@
1+
var _wallColorSpeed = .1;
2+
var _wallColorPercent = 0;
3+
var _wallColorDirection = _wallColorSpeed;
4+
15
function drawGameBoard(context)
26
{
7+
_wallColorPercent += _wallColorDirection;
8+
if (_wallColorPercent > 1)
9+
{
10+
_wallColorPercent = 1;
11+
_wallColorDirection = -_wallColorSpeed;
12+
}
13+
else if (_wallColorPercent < 0)
14+
{
15+
_wallColorPercent = 0;
16+
_wallColorDirection = _wallColorSpeed;
17+
}
18+
var wcp = _wallColorPercent;
19+
320
context.save();
421
context.globalAlpha = 1;
522
context.globalCompositeOperation = "source-over";
@@ -10,16 +27,14 @@ function drawGameBoard(context)
1027
context.closePath();
1128
context.fill();
1229

13-
context.strokeStyle = "#eeeeee";
14-
context.lineWidth = 3;
15-
context.stroke();
16-
1730
context.globalCompositeOperation = "source-atop";
18-
1931
context.fillStyle = "#000000";
2032
context.fillRect(0,0, 800, 800);
21-
22-
context.strokeStyle = "#001111";
33+
34+
var lc1 = {r:0,g:30,b:30};
35+
var lc2 = {r:0,g:20,b:20};
36+
context.strokeStyle = "rgb("+Math.ceil(tween(lc1.r, lc2.r, wcp))+","+Math.ceil(tween(lc1.g, lc2.g, wcp))+","+Math.ceil(tween(lc1.b,lc2.b,wcp))+")";
37+
context.lineWidth = 3;
2338
for (var i=0;i< 20;i++)
2439
{
2540
var d = i*(800/20);
@@ -34,6 +49,21 @@ function drawGameBoard(context)
3449
context.closePath();
3550
context.stroke();
3651
}
52+
53+
//Todo refactor this function so that it has it's own private space for variables
54+
var wc1 = {r:120,g:160,b:160};
55+
var wc2 = {r:120,g:255,b:255};
56+
context.strokeStyle = "rgb("+Math.ceil(tween(wc1.r, wc2.r, wcp))+","+Math.ceil(tween(wc1.g, wc2.g, wcp))+","+Math.ceil(tween(wc1.b,wc2.b,wcp))+")";
57+
context.lineWidth = 5;
58+
context.beginPath();
59+
context.arc(400, 400, 398, 0, Math.PI *2, true);
60+
context.closePath();
61+
context.stroke();
3762

3863
context.restore();
64+
}
65+
66+
function tween(value1, value2, percent)
67+
{
68+
return (value1 * percent) + (value2 * (1-percent));
3969
}

Client/js/play.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ function play_init()
6262

6363
var backgroundCanvasHelper = new CanvasHelper({
6464
onDraw:drawGameBoard,
65-
FPS:0.1,
65+
FPS:1,
6666
offscreenSize:
6767
{
6868
width:800,

0 commit comments

Comments
 (0)