1 decade ago by Dhoombaby
Hello,
i am new to impactjs...i have read books of html5 game development. but at some point i couldn't understand the logic. In jumpnrun game below is some code for enemy. If he is near an edge then reverse the direction...but i am not getting what this code exactly does??? can anyone help me to understand it ??
if( !ig.game.collisionMap.getTile(
this.pos.x + (this.flip ? +4 : this.size.x -4),
this.pos.y + this.size.y+1
)
) {
console.log('in if....');
this.flip = !this.flip;
// We have to move the offset.x around a bit when going
// in reverse direction, otherwise the blob's hitbox will
// be at the tail end.
this.offset.x = this.flip ? 0 : 24;
}
i am new to impactjs...i have read books of html5 game development. but at some point i couldn't understand the logic. In jumpnrun game below is some code for enemy. If he is near an edge then reverse the direction...but i am not getting what this code exactly does??? can anyone help me to understand it ??
if( !ig.game.collisionMap.getTile(
this.pos.x + (this.flip ? +4 : this.size.x -4),
this.pos.y + this.size.y+1
)
) {
console.log('in if....');
this.flip = !this.flip;
// We have to move the offset.x around a bit when going
// in reverse direction, otherwise the blob's hitbox will
// be at the tail end.
this.offset.x = this.flip ? 0 : 24;
}