Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm making a 2D shmup with XNA 4.0 and one of the weapons in the game that I want is a laser beam that follows a path or a series of points and will smoothly beam along the path.

How would I go about achieving this?

share|improve this question

migrated from stackoverflow.com May 30 '12 at 16:27

This question came from our site for professional and enthusiast programmers.

4  
This is way too broad of a question. What do you have so far? Have you tried anything? Perhaps you have some code that isn't quite achieving the result you desire but almost? –  DomenicDatti May 29 '12 at 15:55
    
You've got to google around a bit and try it on your own first. SO is not in the business of hand-holding, sorry. –  SpikeX May 29 '12 at 15:56
1  
Is gamedev.stackexchange.com/questions/29424/… what you're looking for? This question covers the 'bendy laser' that shows up in some shmups. –  Steven Stadnicki Jun 29 '12 at 18:03

1 Answer 1

Try using a Queue of (x,y) coordinates. I don't know if you'll need to do it dynamically or at compile time, but you should be able to figure something out either way.

Are you wanting the laser to follow curves as well, or just connect the dots? If its the first option, you're gonna need to do some math too.

share|improve this answer
    
Yes I want the laser to follow a curve. I have been playing around with some code and I can make lasers go in a straight line just fine so far. –  user1424132 May 29 '12 at 17:52
    
And does it need to go exactly through every point, or would a best-fit curve work? –  Phillip Schmidt May 29 '12 at 18:44
    
Also, do we know anything about the nature of the curve? Is it going to depend on user input? I.e, is the equation of the curve going to be ever-changing? If so, you're fairly screwed here without some extremely complex math. –  Phillip Schmidt May 29 '12 at 18:50
    
no it doesn't have to go through every point. And I have never here of a best fit curve until now. But i'm assuming that it would take the shortest path from start to end. –  user1424132 May 29 '12 at 18:52
    
Kind of. It's calculated using what called the 'least squares method'. An explanation of that method would be out of the scope of this answer, and it too requires some pretty high-level math (at least in nonlinear situations). Last question: where are you getting the points from? Do you have an equation for them, or are you just coming up with them yourself? –  Phillip Schmidt May 29 '12 at 19:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.