/moongirl

To get this branch, use:
bzr branch http://9ix.org/bzr/moongirl

« back to all changes in this revision

Viewing changes to gameObj.js

  • Committer: Josh C
  • Date: 2012-03-22 15:43:03 UTC
  • Revision ID: josh@9ix.org-20120322154303-o648ckp0eeuqork1
only apply friction on ground.  adjust some X speeds to account for that

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
            this.setVelocity(1, 17); // set accel + max vel
12
12
            this.setMaxVelocity(255,255); // just something big so we don't hit it
13
13
            this.gravity = 0.8;
14
 
            this.friction.x = 0.15;
 
14
            this.friction.x = 0.3;
15
15
 
16
16
            //camera should follow us
17
17
            me.game.viewport.follow(this.pos, me.game.viewport.AXIS.BOTH);
47
47
        update: function() {
48
48
            MAX_WALK_VEL = 3.7;
49
49
            JUMP_SPEED = 17;
50
 
            JETPACK_X_VEL = new me.Vector2d(14,17);
 
50
            JETPACK_X_VEL = new me.Vector2d(11,17);
51
51
            JETPACK_Y_VEL = 25;
52
52
 
53
53
            if (me.input.isKeyPressed('left')) {
113
113
 
114
114
            // apply gravity
115
115
            if (this.gravity) {
 
116
                // check if falling / jumping
 
117
                this.falling = (vel.y > 0);
 
118
                this.jumping = this.falling?false:this.jumping;
 
119
 
116
120
                // apply a constant gravity (if not on a ladder)
117
121
                if (!this.onladder)
118
122
                    this.addYVel(this.gravity * me.timer.tick, TERMINAL_VEL);
119
 
                
120
 
                // check if falling / jumping
121
 
                this.falling = (vel.y > 0);
122
 
                this.jumping = this.falling?false:this.jumping;
123
123
            }
124
124
            
125
125
            // apply friction
126
 
            if (this.friction.x)
127
 
                vel.x = me.utils.applyFriction(vel.x,this.friction.x);
128
 
            if (this.friction.y)
129
 
                vel.y = me.utils.applyFriction(vel.y,this.friction.y);
 
126
            if (!this.jumping && !this.falling) {
 
127
                if (this.friction.x)
 
128
                    vel.x = me.utils.applyFriction(vel.x,this.friction.x);
 
129
                if (this.friction.y)
 
130
                    vel.y = me.utils.applyFriction(vel.y,this.friction.y);
 
131
            }
130
132
            
131
133
            // cap velocity
132
134
            /*if (vel.y !=0)