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 Robodude

I'm trying to think of a good way to come up with a laser entity that sort of works like the missile command rocket. For those of you unfamiliar with missile command, the players primary attack is a line that extends towards the mouse location from a fixed point.

Here is a sample of what I mean: http://js1k.com/2010-first/demo/680

Because I want to simulate a "slow" laser, I thought it would be nice to make a small entity (like size: {x: 3, y: 3}) and spawn them on input.state. This seems to work if the laser is really, really, slow, but if I try to speed it up, the entities move out faster then they are spawned, making the whole 'laser beam' illusion fall apart.

I really like this idea because if something gets in the way of the laser beam, it is interrupted automatically.

So that's my idea for achieving this effect, but since I'm new to ImpactJS I wanted to get some additional ideas for how to do this.

1 decade ago by StuartTresadern

Hi, Have you looked into drawing a line ?

spawn your small entity and record is starting position , move it at what ever speed you want and then in your draw code draw a line between the two points. This way you should be able to get the speeds you want (all looking the same) and you can still use the normal collision, if its only the tip of the laser you are interested in.

ig.system.context.strokeStyle = "red";
        ig.system.context.lineWidth = 1;
        ig.system.context.beginPath();
        ig.system.context.moveTo(lineStartX,lineStartY);

        ig.system.context.lineTo(lineFinishX,lineFinishY); // this entity position 

        ig.system.context.stroke();
        ig.system.context.closePath();

Dont forget when drawing on the canvas you will need to take the ig.game.screen x and y values into account. also you can use ig.system.getDrawPos.
Page 1 of 1
« first « previous next › last »