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 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:
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();
    }
  });
});

1 decade ago by Joncom

Are you still having this problem and want help?
If so, then zip up the whole game but exclude the /lib/impact folder.
Then upload it to http://upea.se and share the link here.

1 decade ago by redsq

Hi, @Joncom!
Sorry for the late reply.
Yeah, sure, here it is

1 decade ago by Joncom

You want the player to be able to move blocks around smoothly. However, if you look at the collides value for player and block, both are set to ACTIVE. This means they both have equal ability to push entities (each other) around. That&039;s why it looks jittery right now. Perhaps try setting block to #PASSIVE instead so it doesn't resist the player's advances so much...

1 decade ago by redsq

@Joncom, If I set it to PASSIVE, blocks would not collide with others blocks, only with a player, and they will be stacked.

1 decade ago by Joncom

Perhaps try making your blocks LITE then instead.

I believe since LITE is weaker than ACTIVE, the player can push the blocks around, but it&039;s stronger than #PASSIVE so you should still see the blocks stacking.
Page 1 of 1
« first « previous next › last »