瀏覽代碼

L'aspect des tubes est plus joli

master
Figg 9 月之前
父節點
當前提交
f948aa8e36
共有 1 個檔案被更改,包括 22 行新增5 行删除
  1. 22
    5
      js/drawer.js

+ 22
- 5
js/drawer.js 查看文件

@@ -20,8 +20,8 @@ class Drawer
20 20
 	
21 21
 	draw(game)
22 22
 	{
23
-		background('orange');
24
-		
23
+		clear();
24
+
25 25
 		this.drawTubes(this.padding, this.padding+this.scale, game);
26 26
 	}
27 27
 
@@ -46,15 +46,32 @@ class Drawer
46 46
 		let tubeLevels = tube.height();
47 47
 		
48 48
 		y += (tubeLevels-1) * this.scale;
49
+		strokeWeight(2);
49 50
 		
50 51
 		for(let i = 0; i < tubeLevels; i++)
51 52
 		{
52
-			color = tube.getColorAtLevel(i);
53
+			let layerY = y - i * this.scale;
54
+
55
+			let color = tube.getColorAtLevel(i);
53 56
 			color == null ? noFill() : fill(color);
54 57
 			
55
-			if (i >= 0)
58
+			if (i > 0)
56 59
 			{
57
-				rect(x, y - i * this.scale, this.scale);
60
+				noStroke();
61
+				rect(x, layerY, this.scale);
62
+				stroke('black');
63
+				line(x, layerY, x, layerY + this.scale);
64
+				line(x + this.scale, layerY, x + this.scale, layerY + this.scale);
65
+			}
66
+			else
67
+			{
68
+				noStroke();
69
+				rect(x, layerY, this.scale, this.scale/2);
70
+				stroke('black');
71
+				line(x, layerY, x, layerY + this.scale/2);
72
+				line(x + this.scale, layerY, x + this.scale, layerY + this.scale/2);
73
+
74
+				arc(x + this.scale/2, layerY + this.scale/2, this.scale, this.scale, 0, PI);
58 75
 			}
59 76
 		}
60 77
 	}

Loading…
取消
儲存