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

8 years ago by zergote

My game has the following problems of collisions .

Entities ACTIVE COLLISION overlap with Entities FIXEDS COLLISIONS .

Fixeds entities when an active entity cluttering the flap .

The Player entity is an entity PASSIVE COLLISION transcends the barriers which are entities FIXEDS COLLISIONS.

PlayCTF

/><br />
<br />
Someone the same thing happened?<br />
<br />
Any solution?<br />
<br />
<br />
<pre>
WALL: FIXED ENTITY
</pre><br />
<pre class= ig.module( 'game.entities.wall' ) .requires('impact.entity') .defines(function() { EntityWall = ig.Entity.extend({ size: { x: 32, y: 32 }, name: "Wall", collides: ig.Entity.COLLIDES.FIXED, type: ig.Entity.TYPE.B, checkAgainst: ig.Entity.TYPE.BOTH, animSheet: new ig.AnimationSheet('media/tileset.png', 32, 32), zIndex: 1, init: function(x, y, settings) { this.parent(x, y, settings); this.addAnim('idle', 1, [9]); } }) } )
BOXMOVABLE: PASSIVE ENTITY

ig.module(
    'game.entities.boxmovable'
)
    .requires(
    'impact.entity'
    )
    .defines(function() {
        EntityBoxmovable = ig.Entity.extend({
            size: { x: 32, y: 32 },
            name: "Boxmovable",
            friction: { x: 999, y: 999 },
            collides: ig.Entity.COLLIDES.PASSIVE,
            type: ig.Entity.TYPE.B,
            checkAgainst: ig.Entity.TYPE.B,
            animSheet: new ig.AnimationSheet('media/tileset.png', 32, 32),
            zIndex: 1,
            init: function(x, y, settings) {
                this.parent(x, y, settings);
                this.addAnim('idle', 1, [4])
            }
        })
    })

PLAYER: ACTIVE ENTITY

ig.module('game.entities.player1')

    .requires(
    'impact.entity'
    )
    .defines(function() {

        EntityPlayer1 = ig.Entity.extend({

            collides: ig.Entity.COLLIDES.ACTIVE,
            type: ig.Entity.TYPE.A,
            checkAgainst: ig.Entity.TYPE.NONE,
            health: 3,
            maxHealth: 3,
            size: { x: 25, y: 25 },
            offset: { x: 8, y: 8 },
            maxVel: { x: 900, y: 900 },
            name: "Player1",
            velocity: 300,
            zIndex: 9,
            lastpressed: 'up',
            flag: false,
            idleposition: 0,
            cooling: 1,
            projectiles: 5,
            maxProjectiles: 5,

            animSheet: new ig.AnimationSheet('media/Player_a.png', 32, 32),
            init: function(x, y, settings) {
                this.parent(x, y, settings);
                // Add the animations
                this.addAnim('idle', 1, [0]);
                this.addAnim('down', 1, [1]);
                this.addAnim('left', 1, [3]);
                this.addAnim('right', 1, [2]);
                this.addAnim('up', 1, [0]);
            },
            restoreHealth: function() {
                this.health = 3;
            },
            update: function() {
                //player movement
                if (ig.input.state('up')) {
                    this.vel.y = -this.velocity;
                    this.currentAnim = this.anims.up;
                    this.lastpressed = 'up';
                    this.idleposition = 0;
                    this.addAnim('idle', 1, [this.idleposition]);
                }
                else if (ig.input.state('down')) {
                    this.vel.y = this.velocity;
                    this.currentAnim = this.anims.down;
                    this.lastpressed = 'down';
                    this.idleposition = 1;
                    this.addAnim('idle', 1, [this.idleposition]);
                }
                else if (ig.input.state('left')) {
                    this.vel.x = -this.velocity;
                    this.currentAnim = this.anims.left;
                    this.lastpressed = 'left';
                    this.idleposition = 3;
                    this.addAnim('idle', 1, [this.idleposition]);
                }
                else if (ig.input.state('right')) {
                    this.vel.x = this.velocity;
                    this.currentAnim = this.anims.right;
                    this.lastpressed = 'right';
                    this.idleposition = 2;
                    this.addAnim('idle', 1, [this.idleposition]);
                }
                else {
                    this.vel.y = 0;
                    this.vel.x = 0;
                    this.currentAnim = this.anims.idle;
                }
                if (ig.input.pressed('attack')) {
                    if (this.cooling > 0 && this.projectiles > 0) {
                        ig.game.spawnEntity('EntityProjectile1', this.pos.x + 13, this.pos.y + 13, { direction: this.lastpressed });
                        this.cooling--;
                        this.substractProjectile();
                    }
                }
                if (this.flag == true) {
                    this.addAnim('idle', 1, [this.idleposition + 4]);
                    this.addAnim('down', 1, [this.idleposition + 4]);
                    this.addAnim('left', 1, [this.idleposition + 4]);
                    this.addAnim('right', 1, [this.idleposition + 4]);
                    this.addAnim('up', 1, [this.idleposition + 4]);
                }
                else {
                    this.addAnim('idle', 1, [this.idleposition]);
                    this.addAnim('down', 1, [this.idleposition]);
                    this.addAnim('left', 1, [this.idleposition]);
                    this.addAnim('right', 1, [this.idleposition]);
                    this.addAnim('up', 1, [this.idleposition]);
                }
                this.parent();
            }
        });
    });

8 years ago by Joncom

I think your player should be ACTIVE so he can move boxes. And boxes should be PASSIVE so they can be moved. And walls should be FIXED so they never move.

8 years ago by zergote

Quote from Joncom
I think your player should be ACTIVE so he can move boxes. And boxes should be PASSIVE so they can be moved. And walls should be FIXED so they never move.


Joncom thanks for answering my friend. I tried with that configuration and the problem is not solved.

8 years ago by zergote

Any ideas guys?

8 years ago by Joncom

Instead of using a wall "entity", use the collision layer in Weltmeister. In other words, set wall tiles instead of entities. And in the collision layer, set those tiles to be solid/un-walkable.
Page 1 of 1
« first « previous next › last »