1 decade ago by Bum
You can check out what I have here.
As you can see the speed for moving and jumping is ideal for me right now. (Maybe even a bit slower). However the friction is really annoying. I do not like a lot of drag before the bum comes to a complete stop. Also when moving to the right then instantly moving to the left, the bum keeps going right until the velocity shifts to the left. I want an instant switch over.
Another thing I'm having difficulties with is the slope. I want to be able to run up it and down it without dropping or sliding off. As you can see, you can't run up the slope and when you touch the slope anyway, you slide down. Not ideal.
My last question is if there is a way to force a background to only tile horizontally instead of tiling in all directions.
Thanks!
Here's player code:
As you can see the speed for moving and jumping is ideal for me right now. (Maybe even a bit slower). However the friction is really annoying. I do not like a lot of drag before the bum comes to a complete stop. Also when moving to the right then instantly moving to the left, the bum keeps going right until the velocity shifts to the left. I want an instant switch over.
Another thing I'm having difficulties with is the slope. I want to be able to run up it and down it without dropping or sliding off. As you can see, you can't run up the slope and when you touch the slope anyway, you slide down. Not ideal.
My last question is if there is a way to force a background to only tile horizontally instead of tiling in all directions.
Thanks!
Here's player code:
ig.module( 'game.entities.player' ) .requires( 'impact.entity' ) .defines(function(){ EntityPlayer = ig.Entity.extend({ // The players (collision) size is a bit smaller than the animation // frames, so we have to move the collision box a bit (offset) size: {x: 10, y:30}, maxVel: {x: 200, y: 500}, friction: {x: 400, y: 0}, gravityFactor: 5, type: ig.Entity.TYPE.A, // Player friendly group checkAgainst: ig.Entity.TYPE.NONE, collides: ig.Entity.COLLIDES.PASSIVE, animSheet: new ig.AnimationSheet( 'media/player.png', 32, 32 ), // These are our own properties. They are not defined in the base // ig.Entity class. We just use them internally for the Player accelGround: 400, accelAir: 400, jump: 400, health: 10, flip: false, init: function( x, y, settings ) { this.parent( x, y, settings ); // Add the animations this.addAnim( 'idle', 0.09, [0] ); this.addAnim( 'run', 0.09, [15,16,17,18,19,20] ); this.addAnim( 'jump', 0.09, [60,61,62,63,64,65], true ); this.addAnim( 'fall', 0.09, [75,76,77,78], true ); }, update: function() { // move left or right var accel = this.standing ? this.accelGround : this.accelAir; if( ig.input.state('left') ) { this.accel.x = -accel; this.flip = true; this.offset.x = 8; } else if( ig.input.state('right') ) { this.accel.x = accel; this.flip = false; this.offset.x = -8; } else { this.accel.x = 0; } // jump if( this.standing && ig.input.pressed('jump') ) { this.vel.y = -this.jump; } // set the current animation, based on the player's speed if( this.vel.y < 0 && !this.standing) { this.currentAnim = this.anims.jump; } else if( this.vel.y > 0 && !this.standing) { this.currentAnim = this.anims.fall; } else if( this.vel.x != 0 && (ig.input.state('left') || ig.input.state('right') )) { this.currentAnim = this.anims.run; } else { this.currentAnim = this.anims.idle; } this.currentAnim.flip.x = this.flip; // move! this.parent(); } }); });