Laser Whip

This forum is currently in read-only mode.
0 favourites
From the Asset Store
A sound pack containing 132 laser gun sound effects, including mono and stereo versions of audio files.
  • For those played Raiden 2 or 3. Or Most Raiden series. You most like; seen this

    Subscribe to Construct videos now

    ( around 1:40)

    Subscribe to Construct videos now

    I want to do this laser whip. How would I got about do that?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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

  • Wow, wall of text. Thanks, I'll try it out.

  • 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

    click here to download

  • Doesn't work if I make the laser have an effect.

  • you can try putting the laser on it's own layer

    and applying a layer effect to that layer

  • 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.

  • 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?

  • What about pasting it to a canvas and using the canvas for collision? Haven't tried it, just theorizing.

  • deadeye

    It would work theoretically, but depending on game window size having a full screen canvas is never the best idea.

  • deadeye

    It would work theoretically, but depending on game window size having a full screen canvas is never the best idea.

    True, but the game shown in the video looks to be about SNES resolution, which isn't too big. Plus, you only need the canvas when you have the whip active, yeah? You can spawn/destroy it as needed.

    But if you can get a smooth looking chain of sprites then that's probably the most efficient way to go.

  • it's probably possible to make a chain of sprites and some distortion there to smooth it out if necessary without having the distortion change the collision much

    just to fix the connecting edges

    I don't know...I just haven't seen the smooth sprite chain done yet (or if I did, I didn't know it)

    may be misplaced skepticism

  • Quazi's blobber guy had a smooth chain of sprites for the hose on his nacho-cheese gun.

    At least, the original did. If I remember correctly the newest version uses distortions. Anyway, if your segments are short enough the chain won't look too blocky.

  • I stand corrected:

    http://dl.getdropbox.com/u/1013446/raiden2.cap

    edit: although I think maybe a cubic curve instead of a quadratic might look cooler, and crazier

    edit2: fixed cap, so now in start of layout you can choose the number of segments

    also, in the last version I had a -10 pixel offset leftover from cutting and pasting

  • my blobber uses a canvas, a small one, and the sprite for the tube is positioned and pasted using a loop

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)