Skip to content

Commit

Permalink
reorganizing files, refactoring, updating libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
collinhover committed Oct 30, 2012
1 parent 038512d commit 29a60ea
Show file tree
Hide file tree
Showing 85 changed files with 1,044 additions and 742 deletions.
File renamed without changes.
24 changes: 0 additions & 24 deletions TODO.md

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
10 changes: 5 additions & 5 deletions src/web/index.html
Expand Up @@ -54,12 +54,12 @@

<!-- LESS -->
<link rel="stylesheet/less" type="text/css" href="css/styles.less">
<script src="js/lib/less-1.3.0.min.js" type="text/javascript"></script>
<script src="js/lib/less-1.3.1.min.js" type="text/javascript"></script>

<!-- CSS -->

<!-- setup javascript only -->
<script src="js/lib/modernizr.2.5.3.min.js"></script>
<script src="js/lib/modernizr-2.6.2.min.js"></script>

<!-- Prompt IE 6 users to install Chrome Frame. Remove this if you want to support IE 6.
chromium.org/developers/how-tos/chrome-frame-getting-started -->
Expand Down Expand Up @@ -856,13 +856,13 @@ <h3>Puzzle Map <small>click on the colored shapes to customize the object you've
<div id="puzzleActiveMapGrid" class="well container-center grid-gutterless">
<div class="row">
<a href="#" class="span1">
<img src="asset/texture/dirt_128.jpg" alt="" class="iconk">
<img src="asset/dirt_128.jpg" alt="" class="iconk">
</a>
<a href="#" class="span1">
<img src="asset/texture/dirt_128.jpg" alt="" class="iconk">
<img src="asset/dirt_128.jpg" alt="" class="iconk">
</a>
<a href="#" class="span1">
<img src="asset/texture/dirt_128.jpg" alt="" class="iconk">
<img src="asset/dirt_128.jpg" alt="" class="iconk">
</a>
</div>
</div>
Expand Down
19 changes: 5 additions & 14 deletions src/web/js/kaiopua/Kaiopua.js
Expand Up @@ -16,9 +16,7 @@ var KAIOPUA = (function (main) {
shared.originLink = window.location.pathname.toString();

shared.pathToIcons = 'img/';
shared.pathToAssets = 'asset/';
shared.pathToModels = shared.pathToAssets + 'model/';
shared.pathToTextures = shared.pathToAssets + 'texture/';
shared.pathToAsset = 'asset/';

shared.frameRateMax = 60;
shared.frameRateMin = 20;
Expand Down Expand Up @@ -106,9 +104,7 @@ var KAIOPUA = (function (main) {
"js/kaiopua/sections/Launcher.js"
],
assetsGameExtras = [
"js/kaiopua/sections/Intro.js",
"js/kaiopua/core/Player.js",
{ path: "asset/model/Hero.js", type: 'model' }
"js/kaiopua/sections/Intro.js"
];

/*===================================================
Expand Down Expand Up @@ -566,16 +562,10 @@ var KAIOPUA = (function (main) {
=====================================================*/

function init_ready ( intro, p ) {
function init_ready ( intro ) {
console.log('GAME: ready');

_Intro = intro;
_Player = p;

shared.player = new _Player.Instance( {
geometry: "asset/model/Hero.js"
} );
shared.player.controllable = true;

$( '#buttonStart' ).on( 'tap', start );
$( '#buttonExitGame' ).on( 'tap', stop );
Expand Down Expand Up @@ -2652,7 +2642,8 @@ var KAIOPUA = (function (main) {

function asset_path_cascade( path ) {

var cascade,
var i, l,
cascade,
part,
dotIndex;

Expand Down
10 changes: 5 additions & 5 deletions src/web/js/kaiopua/Kaiopua_DEPRECATED.js
Expand Up @@ -96,11 +96,11 @@ var KAIOPUA = (function (main) {
// shared
shared.pointers = [];
shared.originLink = window.location.pathname.toString();
shared.pathToAssets = 'asset/';
shared.pathToModules = shared.pathToAssets + 'modules/';
shared.pathToModels = shared.pathToAssets + 'model/';
shared.pathToIcons = shared.pathToAssets + 'icons/';
shared.pathToTextures = shared.pathToAssets + 'texture/';
shared.pathToAsset = 'asset/';
shared.pathToModules = shared.pathToAsset + 'modules/';
shared.pathToModels = shared.pathToAsset + 'model/';
shared.pathToIcons = shared.pathToAsset + 'icons/';
shared.pathToAsset = shared.pathToAsset + 'texture/';

shared.frameRateMax = 60;
shared.frameRateMin = 20;
Expand Down
94 changes: 57 additions & 37 deletions src/web/js/kaiopua/core/Character.js
Expand Up @@ -161,12 +161,12 @@

tweenShow = _ObjectHelper.tween( this.material, { opacity: 1 }, {
start: false,
time: durationPerTween
duration: durationPerTween
} );

tweenHide = _ObjectHelper.tween( this.material, { opacity: stats.invulnerabilityOpacityMin }, {
start: false,
time: durationPerTween
duration: durationPerTween
} );

tweenHide.chain( tweenShow.chain( tweenHide ) ).start();
Expand All @@ -176,7 +176,7 @@
else {

_ObjectHelper.tween( this.material, { opacity: 1 }, {
time: durationPerTween,
duration: durationPerTween,
onComplete: function () {

me.material.transparent = false;
Expand Down Expand Up @@ -328,7 +328,7 @@
var state = this.state,
stats = this.options.stats;
console.log( this, ' trying to hurt for ', damage, ', invulnerable? ', state.invulnerable );
if ( state.invulnerable !== true && state.dead !== true ) {
if ( state.invulnerable !== true && state.dead !== true && main.is_number( damage ) && damage > 0 ) {

this.health -= damage;

Expand All @@ -347,6 +347,8 @@

}

return true;

}

}
Expand Down Expand Up @@ -400,7 +402,7 @@
this.material.transparent = true;

_ObjectHelper.tween( this.material, { opacity: 0 }, {
time: durations.decay,
duration: durations.decay,
delay: durations.decayDelay,
onComplete: function () {

Expand Down Expand Up @@ -670,7 +672,7 @@
velocityGravityForceDelta,
velocityMovement,
velocityMovementForceDelta,
velocityMovementForceLength,
velocityMovementForceRotatedLength,
velocityMovementDamping,
dragCoefficient,
terminalVelocity,
Expand Down Expand Up @@ -778,7 +780,6 @@
jumpMoveDamping = jump.moveDamping;

velocityMovement = rigidBody.velocityMovement;
velocityMovementForce = velocityMovement.force;
velocityMovementForceDelta = velocityMovement.forceDelta;
velocityGravity = rigidBody.velocityGravity;
velocityGravityForceDelta = velocityGravity.forceDelta;
Expand All @@ -790,6 +791,28 @@

jump.timeAfterNotGrounded += timeDelta;

// air control

if ( grounded === false && jump.timeAfterNotGrounded >= jumpTimeAfterNotGroundedMax ) {

if ( typeof jump.movementChangeLayer === 'undefined' ) {

jump.movementChangeLayer = _ObjectHelper.temporary_change( velocityMovement, {
damping: new THREE.Vector3( jumpMoveDamping, jumpMoveDamping, jumpMoveDamping ),
speedDelta: new THREE.Vector3( jumpAirControl, jumpAirControl, jumpAirControl )
} );

}

}
else if ( typeof jump.movementChangeLayer !== 'undefined' ) {

_ObjectHelper.revert_change( velocityMovement, jump.movementChangeLayer );

jump.movementChangeLayer = undefined;

}

// if falling but not jumping

if ( jump.active === false && jump.timeAfterNotGrounded >= jumpTimeAfterNotGroundedMax && grounded === false ) {
Expand Down Expand Up @@ -841,11 +864,6 @@

velocityGravity.reset();

jump.movementChangeLayer = _ObjectHelper.temporary_change( velocityMovement, {
damping: new THREE.Vector3( jumpMoveDamping, jumpMoveDamping, jumpMoveDamping ),
speedDelta: new THREE.Vector3( jumpAirControl, jumpAirControl, jumpAirControl )
} );

}

// play jump
Expand Down Expand Up @@ -878,8 +896,6 @@

if ( grounded === true && jump.active !== false ) {

_ObjectHelper.revert_change( velocityMovement, jump.movementChangeLayer );

this.stop_jumping();

if ( jump.timeAfterNotGrounded >= jumpTimeAfterNotGroundedMax ) {
Expand All @@ -904,58 +920,62 @@

// movement

velocityMovementForceDelta.copy( moveDir );

if ( state.movingHorizontal && jump.active === true ) {
if ( sliding !== true ) {

velocityMovementForceDelta.z += jumpSpeedStart * jump.moveSpeedMod;
moveDir.multiplyScalar( moveSpeed );

}

velocityMovementForceDelta.multiplyScalar( moveSpeed );

// moving backwards?

if ( velocityMovementForceDelta.z < 0 ) {
if ( state.movingHorizontal && jump.active === true ) {

moveDir.z += jumpSpeedStart * jump.moveSpeedMod;

}

state.movingBack = true;
velocityMovementForceDelta.addSelf( moveDir );

}
else if ( velocityMovementForceDelta.z > 0 ) {
// moving backwards?

state.movingBack = false;
if ( moveDir.z < 0 ) {

state.movingBack = true;

}
else if ( moveDir.z > 0 ) {

state.movingBack = false;

}

}

// get movement force

velocityMovementForceLength = velocityMovement.force.length() / timeDeltaMod;

// walk/run/idle

if ( jump.active === false && grounded === true ) {

// get movement force

velocityMovementForceRotatedLength = velocityMovement.forceRotated.length() / timeDeltaMod;

// walk / run cycles

if ( velocityMovementForceLength > 0 || sliding === true ) {
if ( velocityMovementForceRotatedLength > 0 || sliding === true ) {

// get approximate terminal velocity based on acceleration (moveVec) and damping
// helps morphs play faster if character is moving faster, or slower if moving slower
// TODO: move equation into physics module
// TODO: account for really low damping (0.95+)

velocityMovementDamping = velocityMovement.damping.z;
dragCoefficient = ( 0.33758 * Math.pow( velocityMovementDamping, 2 ) ) + ( -0.67116 * velocityMovementDamping ) + 0.33419;

terminalVelocity = Math.round( Math.sqrt( ( 2 * Math.abs( velocityMovement.force.z * 0.5 ) ) / dragCoefficient ) ) * 0.5;
playSpeedModifier = terminalVelocity / Math.round( velocityMovementForceLength );
playSpeedModifier = terminalVelocity / Math.round( velocityMovementForceRotatedLength );

if ( main.is_number( playSpeedModifier ) !== true ) {

playSpeedModifier = 1;

}

if ( velocityMovementForceLength >= move.runThreshold ) {
if ( velocityMovementForceRotatedLength >= move.runThreshold ) {

this.morphs.play( 'run', { duration: durations.run * playSpeedModifier, loop: true, solo: true, durationClear: durations.clearSolo, reverse: state.movingBack } );

Expand Down

0 comments on commit 29a60ea

Please sign in to comment.