How do I calculate my laser beam

Get help using Construct 2

Post » Sat Dec 06, 2014 3:10 am

ok this might be a little difficult to explain but here goes.

its for a 2D side scrolling shoot em up with a fake z axis ( like streets of rage)

basically ive got a like a laser cannon on tracks that shoots a constant beam of lightning every (x) number of seconds when fully charged.

the tracks them self's are the z axis position and the turret on top rotates towards the player in a constant beam when firing

my problem is i need a formula / function that calculates when the bean should stop (beam should not go below the y of the tracks) but move from infront of the player to behind on the same fake z axis ( y axis of tracks) unless told to.

in a nut shell i need a function that works out the longest length of a 90 degree triangle every tick while the cannon is firing.

no point in adding a capx as it would just be the laser cannon that can rotate the turret.
But i can if needed draw a diagram of what im looking for.

I know the maths to work it out but having trouble converting the maths into a function that works it out.

really hope that makes sense.
B
7
S
1
Posts: 20
Reputation: 450

Post » Sun Dec 07, 2014 9:53 pm

found a better way to explain what i mean.

basicly need a function that calculates the hypotenuse of a triangle every tick while in shoot mode.
B
7
S
1
Posts: 20
Reputation: 450

Post » Sun Dec 07, 2014 11:23 pm

You could use the distance() function or use the pythogerian theorem to find the hypotonuse.
Hypotenuse = sqrt(x^2 + y^2)
B
92
S
32
G
107
Posts: 5,274
Reputation: 69,959

Post » Mon Dec 08, 2014 2:53 am

@R0J0hound thank you very very much. will try my best to implement this and post a capx for others to see ;) thanks again ;)
B
7
S
1
Posts: 20
Reputation: 450


Return to How do I....?

Who is online

Users browsing this forum: Fenix18 and 12 guests