Permalink
Browse files

added manual controls

  • Loading branch information...
JRileyH committed May 8, 2017
1 parent 0b31fac commit 5b9d7f9b046cb7314f8b40d6cece1a7f4376f5df
Showing with 182 additions and 12 deletions.
  1. BIN favicon.ico
  2. +130 −4 index.html
  3. +52 −8 src/app.js
View
BIN +547 KB favicon.ico
Binary file not shown.
View
@@ -1,6 +1,7 @@
<html>
<head>
<title>Biopod</title>
<link rel="icon" type="image/ico" href="/favicon.ico">
</head>
<body>
@@ -10,10 +11,135 @@ <h1>Welcome to your Biopod</h1>
<p>Feel free to fork the source on <a href="https://github.com/Sleepy-Fish/BioPods">Github</a> and see more projects at <a href="http://sleepy.fish">Sleepy.Fish</a></p>
<canvas id="GameWindow" width="1500" height="450" style="outline:1px solid black"></canvas>
<br>
<button type="button" onclick="newPlant()">New</button>
<button type="button" onclick="storeJson()">Store</button>
<button type="button" onclick="loadJson()">Load</button>
<span>(Only applies to first tree at the moment)</span>
<table border="1">
<tr>
<td>
<h3>Tree One</h3>
<table>
<tr>
<td>Leaf Length: </td>
<td><input type="number" id="leafLength1" value="20"/></td>
</tr>
<tr>
<td>Leaf Sharepness: </td>
<td><input type="number" id="leafSharpness1" value="2"/></td>
</tr>
<tr>
<td>Leaf Width: </td>
<td><input type="number" id="leafWidth1" value="40"/></td>
</tr>
<tr>
<td>Segment Length: </td>
<td><input type="number" id="segmentLength1" value="10"/></td>
</tr>
<tr>
<td>Trunk Width: </td>
<td><input type="number" id="trunkWidth1" value="10"/></td>
</tr>
<tr>
<td>Growth Rate: </td>
<td><input type="number" id="growthRate1" value="0.03"/></td>
</tr>
<tr>
<td>Branch Rate: </td>
<td><input type="number" id="branchRate1" value="0.1"/></td>
</tr>
<tr>
<td>Max Meristem: </td>
<td><input type="number" id="maxMeristem1" value="10"/></td>
</tr>
</table>
<hr>
<button type="button" onclick="newPlant(1)">Reset</button>
<button type="button" onclick="storeJson(1)">Store</button>
<button type="button" onclick="loadJson(1)">Load</button>
</td>
<td>
<h3>Tree Two</h3>
<table>
<tr>
<td>Leaf Length: </td>
<td><input type="number" id="leafLength2" value="60"/></td>
</tr>
<tr>
<td>Leaf Sharepness: </td>
<td><input type="number" id="leafSharpness2" value="2.2"/></td>
</tr>
<tr>
<td>Leaf Width: </td>
<td><input type="number" id="leafWidth2" value="20"/></td>
</tr>
<tr>
<td>Segment Length: </td>
<td><input type="number" id="segmentLength2" value="8"/></td>
</tr>
<tr>
<td>Trunk Width: </td>
<td><input type="number" id="trunkWidth2" value="15"/></td>
</tr>
<tr>
<td>Growth Rate: </td>
<td><input type="number" id="growthRate2" value="0.02"/></td>
</tr>
<tr>
<td>Branch Rate: </td>
<td><input type="number" id="branchRate2" value="0.1"/></td>
</tr>
<tr>
<td>Max Meristem: </td>
<td><input type="number" id="maxMeristem2" value="20"/></td>
</tr>
</table>
<hr>
<button type="button" onclick="newPlant(2)">Reset</button>
<button type="button" onclick="storeJson(2)">Store</button>
<button type="button" onclick="loadJson(2)">Load</button>
</td>
<td>
<h3>Tree Three</h3>
<table>
<tr>
<td>Leaf Length: </td>
<td><input type="number" id="leafLength3" value="15"/></td>
</tr>
<tr>
<td>Leaf Sharepness: </td>
<td><input type="number" id="leafSharpness3" value="1"/></td>
</tr>
<tr>
<td>Leaf Width: </td>
<td><input type="number" id="leafWidth3" value="60"/></td>
</tr>
<tr>
<td>Segment Length: </td>
<td><input type="number" id="segmentLength3" value="20"/></td>
</tr>
<tr>
<td>Trunk Width: </td>
<td><input type="number" id="trunkWidth3" value="5"/></td>
</tr>
<tr>
<td>Growth Rate: </td>
<td><input type="number" id="growthRate3" value="0.06"/></td>
</tr>
<tr>
<td>Branch Rate: </td>
<td><input type="number" id="branchRate3" value="0.3"/></td>
</tr>
<tr>
<td>Max Meristem: </td>
<td><input type="number" id="maxMeristem3" value="15"/></td>
</tr>
</table>
<hr>
<button type="button" onclick="newPlant(3)">Reset</button>
<button type="button" onclick="storeJson(3)">Store</button>
<button type="button" onclick="loadJson(3)">Load</button>
</td>
</tr>
</table>
</body>
<script>
window.gameInfo = {
View
@@ -66,18 +66,62 @@ gameInfo.RENDER = function(){
toolbox.render(ctx)
}
window.newPlant = function(){
global.plant1 = new Plant(plantProps1);
window.newPlant = function(n){
var newProps = {
new: true,
leafLength: parseInt(document.getElementById('leafLength'+n).value),
leafSharpness: parseInt(document.getElementById('leafSharpness'+n).value),
leafWidth: parseInt(document.getElementById('leafWidth'+n).value),
segmentLength: parseInt(document.getElementById('segmentLength'+n).value),
trunkWidth: parseInt(document.getElementById('trunkWidth'+n).value),
growthRate: parseFloat(document.getElementById('growthRate'+n).value),
branchRate: parseFloat(document.getElementById('branchRate'+n).value),
maxMeristem: parseInt(document.getElementById('maxMeristem'+n).value),
}
switch(n){
case 1:
newProps.pos = new Geom.Point(250,400);
global.plant1 = new Plant(newProps);
break;
case 2:
newProps.pos = new Geom.Point(700,400);
global.plant2 = new Plant(newProps);
break;
case 3:
newProps.pos = new Geom.Point(1250,400);
global.plant3 = new Plant(newProps);
break;
}
}
window.storeJson = function(){
localStorage.setItem("plant", JSON.stringify(plant1.jsonify()));
window.storeJson = function(n){
switch(n){
case 1:
localStorage.setItem("plant"+n, JSON.stringify(plant1.jsonify()));
break;
case 2:
localStorage.setItem("plant"+n, JSON.stringify(plant2.jsonify()));
break;
case 3:
localStorage.setItem("plant"+n, JSON.stringify(plant3.jsonify()));
break;
}
}
window.loadJson = function(){
var pulled = JSON.parse(localStorage.getItem("plant"));
window.loadJson = function(n){
var pulled = JSON.parse(localStorage.getItem("plant"+n));
if(pulled){
global.plant1 = new Plant(pulled);
switch(n){
case 1:
global.plant1 = new Plant(pulled);
break;
case 2:
global.plant2 = new Plant(pulled);
break;
case 3:
global.plant3 = new Plant(pulled);
break;
}
}else{
alert("No plant stored");
alert("No plant "+n+" stored");
}
}

0 comments on commit 5b9d7f9

Please sign in to comment.