Skip to content

Commit 368355b

Browse files
Yang Guphemavax
authored andcommitted
Increase fish number and make its change easier
To cater the powerful desktops, fish number is creased so that FPS won't hit the roof 60 and an algorithm is introduced to decide the numbers among small, medium and big fishes. Also to make future change of fish number easier, the relevant logic is moved from html to js.
1 parent aeadd6a commit 368355b

File tree

2 files changed

+53
-17
lines changed

2 files changed

+53
-17
lines changed

aquarium/aquarium.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,8 +249,8 @@
249249
<div class="clickable" id="setSetting6">20000</div>
250250
<div class="clickable" id="setSetting7">30000</div>
251251
<div class="clickable" id="setSetting8">40000</div>
252-
<div class="clickable" id="setSetting9">Change View</div>
253-
<div class="clickable" id="setSetting10">Advanced</div>
252+
<div class="clickable" id="setSettingChangeView">Change View</div>
253+
<div class="clickable" id="setSettingAdvanced">Advanced</div>
254254
<div class="clickable" id="options">Options...
255255
<div id="optionsContainer">
256256
</div>

aquarium/aquarium.js

Lines changed: 51 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -810,20 +810,12 @@ function advanceViewSettings() {
810810
* Sets the count
811811
*/
812812
function setSetting(elem, id) {
813-
switch (id) {
814-
case 10:
815-
break;
816-
case 9:
817-
advanceViewSettings();
818-
break;
819-
default:
820-
g_numSettingElements[id] = elem;
821-
setSettings({globals:{fishSetting:id}});
822-
for (var otherElem in g_numSettingElements) {
823-
g_numSettingElements[otherElem].style.color = "gray";
824-
}
825-
elem.style.color = "red";
813+
g_numSettingElements[id] = elem;
814+
setSettings({globals:{fishSetting:id}});
815+
for (var otherElem in g_numSettingElements) {
816+
g_numSettingElements[otherElem].style.color = "gray";
826817
}
818+
elem.style.color = "red";
827819
}
828820

829821
function getParameterByName(name) {
@@ -970,8 +962,48 @@ function initialize() {
970962
Log("--Setup Laser----------------------------------------");
971963
var laser = setupLaser();
972964

965+
var num = [1, 100, 500, 1000, 5000, 10000, 15000, 20000, 25000, 30000];
966+
var changeViewElem = document.getElementById("setSettingChangeView");
967+
var parentElem = changeViewElem.parentNode;
968+
for (var i = 0; i < num.length; ++i) {
969+
var div = document.createElement("div");
970+
div.className = "clickable";
971+
div.id = "setSetting" + i;
972+
div.innerHTML = num[i];
973+
parentElem.insertBefore(div, changeViewElem);
974+
}
975+
973976
for (var ff = 0; ff < g_fishTable.length; ++ff) {
974977
g_fishTable[ff].fishData = [];
978+
g_fishTable[ff].num = [];
979+
}
980+
981+
var type = ["Big", "Medium", "Small"];
982+
for (var i = 0; i < num.length; ++i) {
983+
var numLeft = num[i];
984+
for (var j = 0; j < type.length; ++j) {
985+
for (var ff = 0; ff < g_fishTable.length; ++ff) {
986+
var fishInfo = g_fishTable[ff];
987+
var fishName = fishInfo.name;
988+
if (!fishName.startsWith(type[j])) {
989+
continue;
990+
}
991+
var numType = numLeft;
992+
if (type[j] == "Big") {
993+
numType = Math.min(numLeft, num[i] < 100 ? 1 : 2);
994+
} else if (type[j] == "Medium") {
995+
if (num[i] < 1000) {
996+
numType = Math.min(numLeft, num[i] / 10 | 0);
997+
} else if (num[i] < 10000) {
998+
numType = Math.min(numLeft, 80);
999+
} else {
1000+
numType = Math.min(numLeft, 160);
1001+
}
1002+
}
1003+
numLeft = numLeft - numType;
1004+
fishInfo.num.push(numType);
1005+
}
1006+
}
9751007
}
9761008

9771009
var particleSystem = new tdl.particles.ParticleSystem(
@@ -1779,11 +1811,15 @@ function setupCountButtons() {
17791811
} else {
17801812
setSetting(document.getElementById("setSetting2"), 2);
17811813
}
1782-
setSetting(document.getElementById("setSetting9"), 9);
17831814
}
17841815

17851816
function initUIStuff() {
17861817
setupCountButtons();
1818+
var elem = document.getElementById("setSettingChangeView");
1819+
elem.onclick = function() {
1820+
advanceViewSettings();
1821+
};
1822+
advanceViewSettings();
17871823

17881824
if(setFishCount){
17891825
setSetting(document.getElementById("setSetting" + fishCountSetting), fishCountSetting);
@@ -1864,7 +1900,7 @@ $(function(){
18641900
g.net.fovFudge = 1;
18651901
}
18661902

1867-
$('#setSetting10').click(function() {
1903+
$('#setSettingAdvanced').click(function() {
18681904
$("#uiContainer").toggle('slow'); return false; });
18691905
$("#uiContainer").toggle();
18701906
$('#options').click(function() {

0 commit comments

Comments
 (0)