1 decade ago by Hareesun
Hey.
Basically I'm making a laser beam (sort of like that other post on here all those months ago) Only this laser changes direction (up, down, left, right) and uses collisionMap.trace to get to the wall of the direction it's facing.
This all works great, it's the Checking that doesn't work so good. It works fine when the laser is facing right, and down, but when it's facing up or left it doesn't. From what I can tell it's not working because when it's facing left or up it's actually in the negative sizes.
Bellow is a snippet of the code that im using to make laser entity's size what it needs to be. Thought it might demonstrate what im trying to do a little better. :)
Has anyone figured a way to work around this issue before? Whatever you've got might help. :) Thanks!
Basically I'm making a laser beam (sort of like that other post on here all those months ago) Only this laser changes direction (up, down, left, right) and uses collisionMap.trace to get to the wall of the direction it's facing.
This all works great, it's the Checking that doesn't work so good. It works fine when the laser is facing right, and down, but when it's facing up or left it doesn't. From what I can tell it's not working because when it's facing left or up it's actually in the negative sizes.
Bellow is a snippet of the code that im using to make laser entity's size what it needs to be. Thought it might demonstrate what im trying to do a little better. :)
this.trY = ig.game.collisionMap.trace(this.pos.x, this.pos.y, 0, ig.system.height, 4,4); this.trY2 = ig.game.collisionMap.trace(this.pos.x, this.pos.y, 0, ig.system.height*-1, 4,4); this.trX = ig.game.collisionMap.trace(this.pos.x, this.pos.y, ig.system.width, 0, 4,4); this.trX2 = ig.game.collisionMap.trace(this.pos.x, this.pos.y, ig.system.width*-1, 0, 4,4); if (this.direction == "up") { this.size = {x:16, y: this.trY2.pos.y - this.pos.y}; this.pos = {x:this.whatX-4, y:this.whatY}; } else if (this.direction == "down") { this.size = {x:16, y: this.trY.pos.y - this.pos.y + 4}; this.pos = {x:this.whatX-4, y:this.whatY+8}; } else if (this.direction == "left") { this.size = {x:this.trX2.pos.x - this.pos.x, y: 16}; this.pos = {x:this.whatX, y:this.whatY-4}; } else if (this.direction == "right") { this.size = {x:this.trX.pos.x - this.pos.x + 4, y: 16}; this.pos = {x:this.whatX+8, y:this.whatY-4}; }
Has anyone figured a way to work around this issue before? Whatever you've got might help. :) Thanks!