Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by LazerFriends

Hello, n00b question here. I'm building a 2d platformer, and have used a lot of the Jump N Run code as a base. However, I can't seem to get my Player entity to jump any higher than a tiny bit, no matter what value I change in the player.js file. How can I get it to jump higher?

http://bsmallbeck.com/impact/

(Press Spacebar to jump)

Here is my code for the player entity:

ig.module( 
	'game.entities.player' 
)
.requires(
	'impact.entity'
)
.defines(function(){
 
EntityPlayer = ig.Entity.extend({
    
    size: {x:36, y:72},
	
	type: ig.Entity.TYPE.A,
    checkAgainst: ig.Entity.TYPE.NONE,
    collides: ig.Entity.COLLIDES.PASSIVE,
    
    animSheet: new ig.AnimationSheet( 'media/player.png', 36, 72),
    
    flip: false,
    accelGround: 400,
	accelAir: 200,
	jump: 200,

    
    init: function( x, y, settings){
        this.parent(x,y,settings);
        
        this.addAnim( 'idle', 1, [0]);
		this.addAnim( 'run', .11, [1,2,3,4,5,6,7,8] );
		this.addAnim( 'jump', 1, [6] );
		this.addAnim( 'fall', 1, [6] );
    },
    
    update: function(){
		var accel = this.standing ? this.accelGround : this.accelAir;
        if( ig.input.state('forward')){
                this.vel.x = 250;
                this.flip = false;
                
        } else if( ig.input.state('back')){
                this.vel.x = -250;
                this.flip = true;
                
        } else {
                this.vel.x = 0;    
        }
	
		if( this.standing && ig.input.pressed('jump') ) {
			this.vel.y = -this.jump;
		}
	
    		if( this.vel.y < 0 ) {
			this.currentAnim = this.anims.jump;
		}
		else if( this.vel.y > 0 ) {
			this.currentAnim = this.anims.fall;
		}
		else if( this.vel.x != 0 ) {
			this.currentAnim = this.anims.run;
		}
		else {
			this.currentAnim = this.anims.idle;
		}
		
		this.currentAnim.flip.x = this.flip;
        
           this.parent();
    }
    
 });
 
    
});

1 decade ago by StuartTresadern

Double check your max velocity is not set to low http://impactjs.com/documentation/class-reference/entity#maxvel-x-maxvel-y

1 decade ago by LazerFriends

...yep, that was it. Thanks!
Page 1 of 1
« first « previous next › last »