Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCatalin Mititiuc <webdevcat@proton.me>2024-07-15 18:04:39 -0700
committerCatalin Mititiuc <webdevcat@proton.me>2024-07-15 18:04:39 -0700
commitb4fee4fde92b631e7b57839c581124c443f16856 (patch)
tree2b7361a8cd0115f8d61cb47e1ee5afce40a25d70
parenta06d8b03259e372a812b7c5c7f0776952157fdd9 (diff)
WIP: add mech template counter
-rw-r--r--public/assets/images/counters.svg21
-rw-r--r--public/assets/images/mech_template.pngbin4072343 -> 28295 bytes
-rw-r--r--src/modules/gameboard.js96
3 files changed, 117 insertions, 0 deletions
diff --git a/public/assets/images/counters.svg b/public/assets/images/counters.svg
index e9b41a7..edabbdd 100644
--- a/public/assets/images/counters.svg
+++ b/public/assets/images/counters.svg
@@ -71,4 +71,25 @@
<polyline points="-2,-3.5 0,-5 2,-3.5"/>
</g>
</g>
+
+ <g id="mech-template">
+ <mask id="mech-template-mask">
+ <circle fill="white" r="36.5"/>
+ <rect x="-16.25" y="-18" width="34.5" height="36" fill="black"/>
+ </mask>
+ <g transform="rotate(0) translate(-2.25, 0)" style="pointer-events: none;">
+ <circle style="stroke: red; stroke-opacity: 0.5; pointer-events: none;" r="36.5"/>
+ <rect style="fill: red; fill-opacity: 0.5;" x="-16.25" y="5.75" width="34.5" height="12.25"/>
+ <rect style="fill: red; fill-opacity: 0.5;" x="-16.25" y="5.75" width="34.5" height="12.25" transform="scale(1 -1)"/>
+ <polyline points="-23,-3 -25,0 -23,3" style="stroke: black;"/>
+ <g mask="url(#mech-template-mask)" style="stroke: white; stroke-opacity: 0.5;">
+ <path d="M -4,0 L -32.55,-16.5 A 36.5 36.5 0 0 0 -32.55,16.5 Z"/>
+ <path d="M 4,0 L 32.55,-16.5 A 36.5 36.5 0 0 1 32.55,16.5 Z"/>
+ <path d="M 0,2.3 L -32.55,-16.5 A 36.5 36.5 0 0 1 0,-36.5 Z"/>
+ <path d="M 0,-2.3 L -32.55,16.5 A 36.5 36.5 0 0 0 0,36.5 Z"/>
+ <path d="M 0,2.3 L 32.55,-16.5 A 36.5 36.5 0 0 0 0,-36.5 Z"/>
+ <path d="M 0,-2.3 L 32.55,16.5 A 36.5 36.5 0 0 1 0,36.5 Z"/>
+ </g>
+ </g>
+ </g>
</svg>
diff --git a/public/assets/images/mech_template.png b/public/assets/images/mech_template.png
index 9d1737f..3dc462c 100644
--- a/public/assets/images/mech_template.png
+++ b/public/assets/images/mech_template.png
Binary files differ
diff --git a/src/modules/gameboard.js b/src/modules/gameboard.js
index be725b5..d8b43f8 100644
--- a/src/modules/gameboard.js
+++ b/src/modules/gameboard.js
@@ -295,6 +295,102 @@ export function start(el) {
// soldier.place(svg, soldier.createCounter(attacker, 'blazer'), getCell(0, 0, 0, 0));
// soldier.place(svg, soldier.createCounter(defender, 'rifle'), getCell(-1, 0, 1, 0));
+ const img = document.createElementNS("http://www.w3.org/2000/svg", 'image');
+ img.setAttribute('href', '/assets/images/mech_template.png');
+ img.setAttribute('width', '77');
+ img.setAttribute('height', '77');
+ img.setAttribute('transform', 'translate(-38.75, -38.5)');
+ img.style.pointerEvents = 'none';
+
+ const mech = document.createElementNS("http://www.w3.org/2000/svg", 'g');
+ mech.setAttribute('transform', 'rotate(0) translate(-2.25, 0)');
+ mech.style.pointerEvents = 'none';
+
+ const deadZone = document.createElementNS("http://www.w3.org/2000/svg", 'circle');
+ deadZone.style.stroke = 'red';
+ deadZone.style.strokeOpacity = 0.5;
+ deadZone.style.pointerEvents = 'none';
+ deadZone.setAttribute('r', '36.5');
+
+ const leftFoot = document.createElementNS("http://www.w3.org/2000/svg", 'rect');
+ leftFoot.style.fill = 'red';
+ leftFoot.style.fillOpacity = 0.5;
+ leftFoot.setAttribute('x', '-16.25');
+ leftFoot.setAttribute('y', '5.75');
+ leftFoot.setAttribute('width', '34.5');
+ leftFoot.setAttribute('height', '12.25');
+
+ const rightFoot = document.createElementNS("http://www.w3.org/2000/svg", 'rect');
+ rightFoot.style.fill = 'red';
+ rightFoot.style.fillOpacity = 0.5;
+ rightFoot.setAttribute('x', '-16.25');
+ rightFoot.setAttribute('y', '5.75');
+ rightFoot.setAttribute('width', '34.5');
+ rightFoot.setAttribute('height', '12.25');
+ rightFoot.setAttribute('transform', 'scale(1 -1)');
+
+ const forwardArc = document.createElementNS("http://www.w3.org/2000/svg", 'path');
+ forwardArc.setAttribute('d', 'M -4,0 L -32.55,-16.5 A 36.5 36.5 0 0 0 -32.55,16.5 Z');
+
+ const rearArc = document.createElementNS("http://www.w3.org/2000/svg", 'path');
+ rearArc.setAttribute('d', 'M 4,0 L 32.55,-16.5 A 36.5 36.5 0 0 1 32.55,16.5 Z');
+
+ const forwardRightArc = document.createElementNS("http://www.w3.org/2000/svg", 'path');
+ forwardRightArc.setAttribute('d', 'M 0,2.3 L -32.55,-16.5 A 36.5 36.5 0 0 1 0,-36.5 Z');
+
+ const forwardLeftArc = document.createElementNS("http://www.w3.org/2000/svg", 'path');
+ forwardLeftArc.setAttribute('d', 'M 0,-2.3 L -32.55,16.5 A 36.5 36.5 0 0 0 0,36.5 Z');
+
+ const rightArc = document.createElementNS("http://www.w3.org/2000/svg", 'path');
+ rightArc.setAttribute('d', 'M 0,2.3 L 32.55,-16.5 A 36.5 36.5 0 0 0 0,-36.5 Z');
+
+ const leftArc = document.createElementNS("http://www.w3.org/2000/svg", 'path');
+ leftArc.setAttribute('d', 'M 0,-2.3 L 32.55,16.5 A 36.5 36.5 0 0 1 0,36.5 Z');
+
+ const arcs = document.createElementNS("http://www.w3.org/2000/svg", 'g');
+ arcs.setAttribute('mask', 'url(#mech-template-mask)');
+ arcs.style.stroke = 'white';
+ arcs.style.strokeOpacity = 0.5;
+
+ const mask = document.createElementNS("http://www.w3.org/2000/svg", 'mask');
+ mask.id = 'mech-template-mask';
+
+ const visible = document.createElementNS("http://www.w3.org/2000/svg", 'circle');
+ visible.setAttribute('fill', 'white');
+ visible.setAttribute('r', '36.5');
+
+ const invisible = document.createElementNS("http://www.w3.org/2000/svg", 'rect');
+ invisible.setAttribute('x', '-16.25');
+ invisible.setAttribute('y', '-18');
+ invisible.setAttribute('width', '34.5');
+ invisible.setAttribute('height', '36');
+ invisible.setAttribute('fill', 'black');
+
+ const arrow = document.createElementNS("http://www.w3.org/2000/svg", 'polyline');
+ arrow.setAttribute('points', '-23,-3 -25,0 -23,3');
+ arrow.style.stroke = 'black';
+
+ mask.append(visible);
+ mask.append(invisible);
+
+ //mech.append(img);
+ mech.append(deadZone);
+ mech.append(leftFoot);
+ mech.append(rightFoot);
+ mech.append(arrow);
+ arcs.append(forwardArc);
+ arcs.append(rearArc);
+ arcs.append(forwardRightArc);
+ arcs.append(forwardLeftArc);
+ arcs.append(rightArc);
+ arcs.append(leftArc);
+ mech.append(arcs);
+
+ const cell = getCell(-1, 1, 0, 0);
+
+ cell.append(mask);
+ cell.append(mech);
+ console.log(cell);
///////////
Observable.subscribe('select', select);