diff --git a/gates/gate.js b/gates/gate.js
index deb143c..7ac7578 100644
--- a/gates/gate.js
+++ b/gates/gate.js
@@ -1,10 +1,43 @@
class Gate {
- constructor(type) {
- switch (type) {
- case 'logic':
- break;
- default:
- break;
+ constructor(x, y, type) {
+ this.x = x;
+ this.y = y;
+ this.types = new Types(type);
+ this.selected = false;
+
+ this.inputs = [];
+ this.outputs = [];
+ for(var i = 0; i < this.types.type.inputs; i++){
+ //TODO calculate postions for ankors based on this.x and this.y
+ this.inputs.push(new Ankor(this.x - 10, this.y));
+ }
+ for(var i = 0; i < this.types.type.outputs; i++){
+ //TODO calculate postions for ankors based on this.x and this.y
+ this.outputs.push(new Ankor(this.x + 10, this.y));
}
}
+
+ draw() {
+ //todo draw gate and ankors and use type to resolve image
+
+ }
+
+ calculate() {
+ //todo calculate outputs based on inputs and function and add exception for light and switch if type.state
+
+ }
+
+ returnOnAnkor(x, y) {
+ this.inputs.forEach(ankor => {
+ if(x == ankor.x && y == ankor.y){
+ return ankor;
+ }
+ });
+ this.outputs.forEach(ankor => {
+ if(x == ankor.x && y == ankor.y){
+ return ankor;
+ }
+ });
+ return false;
+ }
}
\ No newline at end of file
diff --git a/index.html b/index.html
index 4a8f2b5..c64c0c8 100644
--- a/index.html
+++ b/index.html
@@ -1,5 +1,11 @@
+
+
+
+
+
+
diff --git a/sketch.js b/sketch.js
index 8aaddd1..e1bb7d4 100644
--- a/sketch.js
+++ b/sketch.js
@@ -14,6 +14,8 @@ function preload() {
function setup() {
createCanvas(displayWidth, displayHeight);
+ var gate = new Gate(1, 2, "light");
+ console.log(gate)
}
function draw() {