master
Niggeroni 2022-11-11 17:36:38 +01:00
parent b87d8f6e1a
commit 964555a374
3 changed files with 47 additions and 6 deletions

View File

@ -1,10 +1,43 @@
class Gate { class Gate {
constructor(type) { constructor(x, y, type) {
switch (type) { this.x = x;
case 'logic': this.y = y;
break; this.types = new Types(type);
default: this.selected = false;
break;
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;
} }
} }

View File

@ -1,5 +1,11 @@
<script src="p5.min.js"></script> <script src="p5.min.js"></script>
<script src="sketch.js"></script> <script src="sketch.js"></script>
<script src="gates/gate.js"></script>
<script src="gates/ankor/ankor.js"></script>
<script src="gates/type/types.js"></script>
<script src="gates/type/types/light.js"></script>
<script src="gates/type/types/not.js"></script>
<script src="gates/type/types/switch.js"></script>
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">

View File

@ -14,6 +14,8 @@ function preload() {
function setup() { function setup() {
createCanvas(displayWidth, displayHeight); createCanvas(displayWidth, displayHeight);
var gate = new Gate(1, 2, "light");
console.log(gate)
} }
function draw() { function draw() {