Northern49
Member
OR ALTERNATIVELY
How to draw a green line representing the lightning bolt between the hero and the event.
I have an event that shoots a lightning bolt at the character when it comes near. The problem is that the lightning bolt is a picture, and needs to rotate to a certain angle according to where the hero is standing.
Lightning bolt:
http://img130.imageshack.us/img130/7926/boltiu4.png[/img]
I can easily enough have the picture rotate accurately if say, the difference between the event and the player is -7, rotate the image by -7 for 5 frames, stop rotating, display and move image towards player/event, but that is according to 1 coordinate, either the Y difference or the X difference. Finding an accurate method to rotate an image depending on both Y and X is a difficult task.
I'm wondering if there is a way to have an image point directly towards a certain event or the player using a script, or, if anyone knows if this can be achieved using an event systematic I haven't thought of yet.
If you still have trouble understanding what I mean by this post, look at the below chart.
Now, I am going to write out an event systematic. Try to follow along.
[/COLOR]
This is looking strictly at the Y coordinate. And that works just fine.
But when you also need to look at the X coordinate, it changes the way the whole system functions.
For example, look at the chart. Now imagine this, the event (the dark circle) is about to shoot its lightning bolt at you. You, the player, are standing in Quadrant 2, in the blue block, at 96 pixels. Imagine the lightning bolt coming at you. Now imagine the same thing, but instead standing at 96 pixels in the yellow block. The image will have to rotate according to the change in your X position, but the Y position is the same. It won't be able to distinguish the difference and the lightning bolt will not rotate in the proper angle.
http://img518.imageshack.us/img518/1417/blockswt1.png[/img]
How to draw a green line representing the lightning bolt between the hero and the event.
I have an event that shoots a lightning bolt at the character when it comes near. The problem is that the lightning bolt is a picture, and needs to rotate to a certain angle according to where the hero is standing.
Lightning bolt:
http://img130.imageshack.us/img130/7926/boltiu4.png[/img]
I can easily enough have the picture rotate accurately if say, the difference between the event and the player is -7, rotate the image by -7 for 5 frames, stop rotating, display and move image towards player/event, but that is according to 1 coordinate, either the Y difference or the X difference. Finding an accurate method to rotate an image depending on both Y and X is a difficult task.
I'm wondering if there is a way to have an image point directly towards a certain event or the player using a script, or, if anyone knows if this can be achieved using an event systematic I haven't thought of yet.
If you still have trouble understanding what I mean by this post, look at the below chart.
Now, I am going to write out an event systematic. Try to follow along.
Code:
[COLOR=Green]Comment: Quadrant I (top-right quarter)[/COLOR]
[COLOR=Blue]Condition Branch: If [Event X] [I](the circle in the center)[/I] < [Player X]
Conditional Branch: If [Event Y] > [Player Y][/COLOR]
[COLOR=Red]
Variable operation: [Distance between Event & Player X] = Event X
Variable operation: [Distance between Event & Player X] -= Player X
Variable operation: [Distance between Event & Player Y] = Event Y
Variable operation: [Distance between Event & Player Y] -= Player Y[/COLOR]
[COLOR=Blue]Conditional Branch: If [Distance between Event & Player Y] = 32[/COLOR]
[COLOR=DarkOrchid]Show image [Lightning bolt] 0 opacity
Rotate [Lightning bolt] by 1[/COLOR]
Wait 5 frames
[COLOR=DarkOrchid]Rotate [Lightning bolt] by 0
Move image [Lightning bolt] 255 opacity
Move image [Lightning bolt] to [Player X]/[Player Y][/COLOR]
[COLOR=Blue]else
Conditional Branch: If [Distance between Event & Player Y] = 64[/COLOR]
[COLOR=DarkOrchid] Show image [Lightning bolt] 0 opacity
Rotate [Lightning bolt] by 2[/COLOR]
Wait 5 frames
[COLOR=DarkOrchid] Rotate [Lightning bolt] by 0
Move image [Lightning bolt] 255 opacity
Move image [Lightning bolt] to [Player X]/[Player Y][/COLOR]
[COLOR=Blue] else
Conditional Branch: If [Distance between Event & Player Y] = 96[/COLOR]
[COLOR=DarkOrchid] Show image [Lightning bolt] 0 opacity
Rotate [Lightning bolt] by 2[/COLOR]
Wait 5 frames
[COLOR=DarkOrchid] Rotate [Lightning bolt] by 0
Move image [Lightning bolt] 255 opacity
Move image [Lightning bolt] to [Player X]/[Player Y]
This is looking strictly at the Y coordinate. And that works just fine.
But when you also need to look at the X coordinate, it changes the way the whole system functions.
For example, look at the chart. Now imagine this, the event (the dark circle) is about to shoot its lightning bolt at you. You, the player, are standing in Quadrant 2, in the blue block, at 96 pixels. Imagine the lightning bolt coming at you. Now imagine the same thing, but instead standing at 96 pixels in the yellow block. The image will have to rotate according to the change in your X position, but the Y position is the same. It won't be able to distinguish the difference and the lightning bolt will not rotate in the proper angle.
http://img518.imageshack.us/img518/1417/blockswt1.png[/img]