updates
parent
b87d8f6e1a
commit
964555a374
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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">
|
||||||
|
|
Loading…
Reference in New Issue