1 decade ago by redsq
Hi there! I have started making a game, with a moving blocks. And I've got a problem.
Here is a video with demonstrating of that problem.
You can see, that blocks doesn't moves smoothly, and starting stacking sometimes. How to fix it? Here is a code:
Here is a video with demonstrating of that problem.
You can see, that blocks doesn't moves smoothly, and starting stacking sometimes. How to fix it? Here is a code:
player.js:
ig.module(
'game.entities.player'
)
.requires(
'impact.entity'
)
.defines(function() {
EntityPlayer = ig.Entity.extend({
collides: ig.Entity.COLLIDES.ACTIVE,
type: ig.Entity.TYPE.A,
checkAgainst: ig.Entity.TYPE.B,
size: {
x: 16,
y: 24
},
maxVel: {x: 100, y: 100},
animSheet: new ig.AnimationSheet('media/test.png', 16, 24),
init: function(x, y, settings) {
this.parent(x, y, settings);
this.addAnim('idle', 0.1, [0]);
},
update: function() {
if(ig.input.state('left')) {
this.vel.x = -50;
} else if(ig.input.state('right')) {
this.vel.x = 50;
} else {
this.vel.x = 0;
}
if(ig.input.pressed('up') && this.standing) {
this.vel.y = -98;
}
this.parent();
},
draw: function() {
this.parent();
}
});
});
block.js:
ig.module(
'game.entities.block'
)
.requires(
'impact.entity'
)
.defines(function() {
EntityBlock = ig.Entity.extend({
collides: ig.Entity.COLLIDES.ACTIVE,
type: ig.Entity.TYPE.B,
checkAgainst: ig.Entity.TYPE.A,
animSheet: new ig.AnimationSheet('media/testBlock.png', 16, 16),
maxVel: {x: 0, y: 100},
init: function(x, y, settings) {
this.parent(x, y, settings);
this.addAnim('idle', 0.1, [0]);
},
update: function() {
this.parent();
}
});
});
