diff --git a/docs/assets/js/constants.js b/docs/assets/js/constants.js new file mode 100644 index 0000000..5ed3701 --- /dev/null +++ b/docs/assets/js/constants.js @@ -0,0 +1,5 @@ +var constants = { + testOrganizer: { + EXAMPLE_DELETE_ME_LATER : 1277336 + } +}; \ No newline at end of file diff --git a/docs/assets/js/index.js b/docs/assets/js/index.js index 9caaf0e..b85d54e 100644 --- a/docs/assets/js/index.js +++ b/docs/assets/js/index.js @@ -1,4 +1,3 @@ - // Handle starting the pre-load animation var page_preloader = new Preloader(); page_preloader.show(true); @@ -11,8 +10,38 @@ audio = [ "" ]; -function update() { +var globalStates = { + titleScreen:0, + starting:1, + playing:2, + paused:3, + end:4 +}; +var globalState = globalStates.titleScreen; +function update() { + switch(globalState) { + // title screen + case globalStates.titleScreen: + + break; + // starting + case globalStates.starting: + + break; + // playing + case globalStates.playing: + + break; + // paused + case globalStates.paused: + + break; + // end + case globalStates.end: + + break; + } } function input() { diff --git a/docs/assets/js/utils.js b/docs/assets/js/utils.js new file mode 100644 index 0000000..c134261 --- /dev/null +++ b/docs/assets/js/utils.js @@ -0,0 +1,41 @@ +// clamps a value between min and max +function clamp(value, min, max) { + return Math.min(max, Math.max(min, value)); +} + +// linear interpolation towards somewhere +function lerp(start, end, amt) { return (1 - amt) * start + amt * end; } + +// returns a new value with friction applied +function friction(value, amount) { + if (value > 0) { value -= amount; } + if (value < 0) { value += amount; } + if (Math.abs(value) < amount * 2) { value = 0; } + return value; +} + +var tau = Math.PI * 2; +var pi = Math.PI; +// returns a new angle that gets closer to the target angle +function turn(cur, target, speed) { + if (target < 0) { target = tau + target; } + if ((cur % tau) > target) { + if ((cur % tau) - target > pi) { + cur += speed; + } else { + cur -= speed; + } + } else { + if (target - (cur % tau) > pi) { + cur -= speed; + } else { + cur += speed; + } + } + if (Math.abs(cur - target) < speed * 1.1) { + cur = target; + } + if (cur > tau) { cur = cur - tau; } + if (cur < 0) { cur = tau + cur; } + return cur; +} \ No newline at end of file diff --git a/docs/index.html b/docs/index.html index 1c3e9f9..ebac9fb 100644 --- a/docs/index.html +++ b/docs/index.html @@ -21,6 +21,8 @@
+ + diff --git a/programmingGuide.md b/programmingGuide.md new file mode 100644 index 0000000..f91a35f --- /dev/null +++ b/programmingGuide.md @@ -0,0 +1,17 @@ +# guide for how we should program + +## states + +every separate of the game (title, transition, paused, etc.) should have a separate spot in a main switch statement, and have a separate folder where all code relating to that state should be + +## magic numbers + +no magic numbers, numbers that potentially might need to be changed should be a constant in constants.js + +## comments + +I don't care how you comment, just make sure we can all understand your code + +## source control + +Work on your own branch, which should be named what you are working on. Master should always be working \ No newline at end of file