# Laser Whip

For questions about using Classic.

### » Sun Apr 26, 2009 1:28 am

For those played Raiden 2 or 3. Or Most Raiden series. You most like; seen this
http://www.youtube.com/watch?v=Vfvmt2okNAU ( around 1:40)

I want to do this laser whip. How would I got about do that?
B
11
S
3
G
8
Posts: 473
Reputation: 4,569

### » Sun Apr 26, 2009 2:22 am

make a segment of laser, like if you could cut a small square out of the raiden laser going straight upward
create a distort map for it, 1 across, however many segments you want down (try 10)

create 2 different sprites to use as a bezier control point and an endpoint (we'll call them sprite1, and sprite2)
make a bezier curve using the quadratic function (qarp)and the locations of the 2 sprites and the an imagepoint on the nose of your ship

if you need help understanding what you're doing a little better, read some of this wikipedia article, especially the little moving diagrams near the end
but for practical purposes what you will do
is set each segment of your distort map in this way
h=half the width of your laser

for 0 to NumberOfSegmentsOfDistortMap
set displacement (real) column(0)row(loopindex)
x to qarp(ship.imagepointx(nose)-h, sprite1.x-h, sprite2.x-h,1-loopindex/NumberofRowsindistortmap)
y to qarp(ship.imagepointy(nose)+h, sprite1.y+h, sprite2.y+h, sprite2.x-h,1-loopindex/NumberofRowsindistortmap)
set displacement (real) column(1)row(loopindex)
x to qarp(ship.imagepointx(nose)-h, sprite1.x-h, sprite2.x-h, sprite2.x-h,1-loopindex/NumberofRowsindistortmap)
y to qarp(ship.imagepointy(nose)+h, sprite1.y+h, sprite2.y+h, sprite2.x-h,1-loopindex/NumberofRowsindistortmap)

this will bend your sprite along a curve beginning at the nose of your ship
and ending at sprite2, and the curve will be guided by sprite1

always
set sprite1.x = ship.x, and sprite1.y = to ship.y + a number that makes the ray look cool
sprite 1 will be guiding the laser, so if you want it to lean toward y, subtly the way it does in raiden this is a good way to start
set sprite2.y = 0 (top of the screen), and sprite2.x to ship.x + a number that changes when you're moving to the right or left, you can decide exactly how you want this to look

you can also add small random values to either control point for a wobbly effect
use an instant bullet aimed at sprite2 to check for hits
once you hit an enemy ship, set sprite2's position to the position of the ship
and make sprite1 move drastically to the right or left as your ship does

if you need more details on any of the steps I can help you, but I can't post a cap just now
if you get this far, you may notice something a little different about the bending of the ribbon
because we're using parallel lines, the fix is simple, and takes only a minute, but might be confusing in the middle of this
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

### » Sun Apr 26, 2009 2:36 am

Wow, wall of text. Thanks, I'll try it out.
B
11
S
3
G
8
Posts: 473
Reputation: 4,569

### » Sun Apr 26, 2009 2:44 am

ok, here's a simple cap
example
I think you will be pleasantly surprised by how short it is
it sounds more complicated than it is
please examine it, and let me know what parts, if any you need help with

to test, drag and drop the ship and the two control points
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

### » Sun Apr 26, 2009 5:05 am

Doesn't work if I make the laser have an effect.
B
11
S
3
G
8
Posts: 473
Reputation: 4,569

### » Sun Apr 26, 2009 9:13 am

you can try putting the laser on it's own layer
and applying a layer effect to that layer
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

### » Mon Apr 27, 2009 7:05 pm

The problem with using distort map is that it doesnt support distorted collisions
: what you're left with is a collision box which is a ghost of the undistored object. I would recommend using a chain of sprites.
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

### » Mon Apr 27, 2009 7:31 pm

@ davioware
or maybe a chain of invisible sprites for collision detection?
I haven't tried the chain of sprites thing yet, does it come out looking smooth?
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

### » Mon Apr 27, 2009 7:46 pm

What about pasting it to a canvas and using the canvas for collision? Haven't tried it, just theorizing.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

### » Mon Apr 27, 2009 7:59 pm

It would work theoretically, but depending on game window size having a full screen canvas is never the best idea.
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Next

Return to Help & Support using Construct Classic

### Who is online

Users browsing this forum: No registered users and 0 guests