User Tag List

Results 1 to 5 of 5

Thread: Straight beam which colides with objects

  1. #1
    No Products Registered

    Join Date
    Dec 2006
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Straight beam which colides with objects

    So as you can maybe guess from the title I'm still trying to make a shooter.

    •I want to make my ship shoot a straight beam; which when it collides with an enemy, stops.
    Like so:

    Oh, and in my games case, the beam only ever needs to be facing up-screen, just like in the image.

    I was hoping that it would be possible to use at least one line of pixels instead of just using a 1 colour fill (which I really wouldn't want to do).

    I don't actually know how this would go in theory. I was trying my hand at "shooting" lines of 1 pixel high and 20 pixel wide sprites, but that's not working at all. I'm doing it wrong. :blush:
    I can't figure out how to make the beam grow and diminish in length whilst it's hitting obstacles.

    I did search for similar topics and found one, but the answer shown resulted in a single colour beam, which I want to avoid if possible.

  2. #2
    No Products Registered

    Join Date
    Feb 2008
    Location
    uk
    Posts
    367
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Straight beam which colides with objects

    uhhmmm, ive seen one where you use loops, have a play with them, ill have a go to

  3. #3
    Clicker

    Fusion 2.5 DeveloperFusion 2.5+ DLCAndroid Export ModuleHTML5 Export ModuleiOS Export ModuleSWF Export ModuleXNA Export ModuleUnicode Add-on
    mobichan's Avatar
    Join Date
    Oct 2007
    Location
    Buffalo, NY
    Posts
    3,310
    Mentioned
    28 Post(s)
    Tagged
    0 Thread(s)

    Re: Straight beam which colides with objects

    I'm sure there is a better way to do this, but you could approach it similar to how you make normal bullet fire. When the player presses the fire button, create a beam sprite and give the sprite a simple, vertical movement (vector movement might be easiest) in the sprite's "Properties." That way, when the sprite is created, it will automatically fire in the right direction at the right speed. The thing to remember is that the slower you move each sprite, the more your beam will wave when you move the player around. To keep the beam straight you need to up the speed.

    Also, to make the beam stop when it hits something, you need to call a "Destroy" command on any collision between the sprite and enemies/backgrounds it shouldn't pass through.

    You might want to make your sprites taller than a pixel high as well, because you will probably get alot of slowdown from creating so many sprites.

    Hope that helps,

    Mobichan

  4. #4
    No Products Registered

    Join Date
    Dec 2006
    Posts
    30
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Straight beam which colides with objects

    Thanks for the ideas thus far. Much appreciated.

    I'm not getting mobichan's method to work. It was pretty much the way I've been trying to do it until now.

    The problem with that method is that I'm having troubles getting a perfectly straight line. - as the beam is made up of individual segments, when the ship moves, the line "bends".

    Further problems with that method are that I'm getting when shooting the bullets, I have to do it fast enough to try and stop the above problem with "bending" happening and still have a very fast shot frequency to the point where I can't seem to shoot any faster.

    The final problem is that once you move backwards and forwards you inevitably create gaps in the bullets, so the line breaks up and you loose the illusion of a straight line.

    This approach seems a little messy, maybe someone has another approach to this problem?

  5. #5
    Clicker Fusion 2.5

    Join Date
    May 2008
    Location
    In Your Cheese
    Posts
    132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Straight beam which colides with objects

    Hey I just did something like this! It's pretty tough, but I found a good way to do it.

    What I did was made a 1 X 8 pixel beam object, and made it so that the Horizontal scale was equal to the horizontal distance between the player and the enemy the beam was overlapping. In your case, you would use the vertical scale, but it's the same idea.

    The equation I used was something like: (Set X scale to (-distance of beam from player -(X of player) + (X of ememy))

    When the scale of the beam is greater than the distance of the enemy, you'll have to shorten the beam, and when the beam isn't hitting anything, you can set the scale to (current scale + #). The bigger the number, the faster the beam will lengthen.

    Hope that helps you.

Similar Threads

  1. Move straight from one point to the next?
    By Konidias in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 28th July 2012, 08:14 PM
  2. Mac - Drawing a Straight Line Between Two Objects?
    By pinacoladaxb in forum Multimedia Fusion 2 - Technical Support
    Replies: 8
    Last Post: 24th February 2011, 01:41 AM
  3. Platform - Jumpt straight upwards
    By Maarten in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 20th November 2010, 11:37 AM
  4. Shoot object not straight...?
    By Blue66 in forum Multimedia Fusion 2 - Technical Support
    Replies: 5
    Last Post: 26th January 2008, 02:23 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •