ID:157402
Mar 17 2010, 10:29 am (Edited on Mar 17 2010, 10:36 am)
|
|
How would I make a Beam shoot outwards a desired number of tiles, and then retract to the one who fired it, then delete itself? Thanks in advance!
|
In response to Loduwijk
|
|
I meant by, "Beam" that it would be a projectile that could fire outwards a certain number of tiles that you wanted it, and then return to the user. And no, the user would not be able to move.
|
In response to Xorbah
|
|
Xorbah wrote:
I meant by, "Beam" that it would be a projectile that could fire outwards a certain number of tiles that you wanted it, and then return to the user. And no, the user would not be able to move. Because of your second sentence and because you have not asked about that, I will assume you have already taken care of locking movement and will not mention that. Look up the function step(), the atom variable "dir," probably sleep(), and for loops if you don't know about them. step() will allow you to physically move the object. sleep() will allow you to slow it down so that it does not all happen instantly (since you likely want the effect to be visible), and you will need to specify a direction, possibly the firer's dir. So you create a new beam object, then you step(the beam, the direction) a certain number of times, then, since the firer will not be moving, you can step the beam the same number of times in the opposite direction, which would be the direction turn(direction, 180), so you might want to look up turn() as well. The directional rotation turn(), not the icon turning function. If you want the beam to shoot in something other than a straight line, such as if you have a target, then you need to figure out a way to always make the direction be toward the target instead of having the direction be static, in which case you can use get_dir(). Throw the movement into a loop which loops X iterations, and the beam will move X tiles. Here is an example of shooting in a specific direction, then a second example where instead you throw a stone at a target. One of them will be very close to what you want, depending on whether you are shooting in a direction or at a target. // shoot in direction // shoot toward target |
No, but seriously...
What exactly do you mean? Normally I would talk about just how to move objects around, but you specifically say "Beam" and many people mean "A projectile which leaves a trail behind as it moves" when they say just "Beam."
I'll start by at least telling you to look up step() and del. Then you also need to decide a few more things about how you want it to work. What does "retract to the one that fired it" do? Just retrace its step back to the spot it started? Can the object that fired it move while the beam is moving, and if so should the beam return to the firer's new location instead of where the firer was? And, as I said before, what is the behavior of the "beam?"
If you're looking for something extremely simple, my initial jesting answer might still be close to what you want, but I can't say anything for sure since I'm not sure what you want.