/moongirl

To get this branch, use:
bzr branch /bzr/moongirl

« back to all changes in this revision

Viewing changes to gameObj.js

  • Committer: Josh C
  • Date: 2012-03-22 15:07:35 UTC
  • Revision ID: josh@9ix.org-20120322150735-pzgj1y4jzcsm7y62
add friction, change X velocities to fight friction

Show diffs side-by-side

added added

removed removed

5
5
            // superclass constructor?
6
6
            this.parent(x, y, settings);
7
7
 
 
8
            this.debugtimer = 0.0;
 
9
 
8
10
            // walking, jumping speed:
9
 
            this.setVelocity(4, 17); // set accel + max vel
 
11
            this.setVelocity(1, 17); // set accel + max vel
10
12
            this.setMaxVelocity(255,255); // just something big so we don't hit it
11
13
            this.gravity = 0.8;
 
14
            this.friction.x = 0.15;
12
15
 
13
16
            //camera should follow us
14
17
            me.game.viewport.follow(this.pos, me.game.viewport.AXIS.BOTH);
42
45
 
43
46
        // input
44
47
        update: function() {
45
 
            MAX_WALK_VEL = 2;
 
48
            MAX_WALK_VEL = 3.7;
46
49
            JUMP_SPEED = 17;
47
 
            JETPACK_X_VEL = new me.Vector2d(10,17);
 
50
            JETPACK_X_VEL = new me.Vector2d(14,17);
48
51
            JETPACK_Y_VEL = 25;
49
52
 
50
53
            if (me.input.isKeyPressed('left')) {
55
58
                this.addXVel(this.accel.x * me.timer.tick, MAX_WALK_VEL);
56
59
            } else {
57
60
                //stop immediately??
58
 
                this.vel.x = 0;
 
61
                //this.vel.x = 0;
59
62
            }
60
63
 
61
64
            if (me.input.isKeyPressed('jump')) {
83
86
            // messy method.  will need to replace eventually.
84
87
            this.updateMovement();
85
88
 
 
89
            /* this.debugtimer += me.timer.tick;
 
90
            if (this.debugtimer > 100) {
 
91
                dbg = "XVel: " + this.vel.x;
 
92
                dbg += "<br>me.timer.tick: " + me.timer.tick;
 
93
 
 
94
                dbgEl = document.getElementById('debug');
 
95
                //dbgEl.replaceChild(document.createTextNode(dbg), dbgEl.firstChild);
 
96
                dbgEl.innerHTML = dbg;
 
97
 
 
98
                this.debugtimer = 0.0;
 
99
                } */
 
100
 
86
101
            // "update animation if necessary"
87
102
            if (this.vel.x != 0 || this.vel.y != 0) {
88
103
                this.parent(this); // this has to be the real work