Draw Line issues

Started by DrewCCU, Wed 09/06/2010 18:52:26

Previous topic - Next topic

DrewCCU

I've searched the AGS help files for this and i can't find anything that i understand well enough to be of any help.  I am drawing a line from one character's coordinates to another characters coordinates.  The first issue is I need the line to appear ON TOP of the characters not below them on the background.  The second issue is I need to be able to "Delete" the line pretty much as soon as its finished drawing.  It needs to be "Deleted" in such a manor as if it were never there to begin with.  So I guess what i'm trying to say is simply "hiding" the drawing probably won't work (at least I don't think it would be the best idea).  The third issue - although not really an issue - more of a question: can  you change the speed at which the line is drawn?

Possibly useful information:
I have it set so that the line is drawn from cCharacterA's x,y TO cCharacterB's x,y because the characters are moving around the screen randomly so at any one point when this script is initiated the characters could be anywhere on screen.  This isn't an issue as I know how to code this ... i just thought it might effect how to do the other stuff i'm having problems with. So keep that in mind.

Recap:
1) Need the line to appear above characters.
2) Need line to be deleted after being drawn.
3) Can you change the speed in which the line is drawn?
Keep in mind: Characters move randomly around.

thanks.
"So much of what we do is ephemeral and quickly forgotten, even by ourselves, so it's gratifying to have something you have done linger in people's memories."
-John Williams

Vince Twelve

When you draw a line, the whole line just pops into existence, it doesn't start at one end and grow outwards.  Is that what you're trying to do?

If you want to do that, it's going to be more complicated because you'll have to calculate the point forming an increasingly large line segment each frame and draw the line onto a GUI or overlay every frame until it reaches the other character.

Is that what you want to see?  The line starting at one character and growing outwards until it reaches the other character?

DrewCCU

#2
Quote from: Vince Twelve on Wed 09/06/2010 19:40:08
When you draw a line, the whole line just pops into existence, it doesn't start at one end and grow outwards.  Is that what you're trying to do?

If you want to do that, it's going to be more complicated because you'll have to calculate the point forming an increasingly large line segment each frame and draw the line onto a GUI or overlay every frame until it reaches the other character.

Is that what you want to see?  The line starting at one character and growing outwards until it reaches the other character?

well having it drawn from point a to point b would be nice - but if the code is too complicated its not necessary ... the most important things are how to get the line above the characters and get it to be deleted.
"So much of what we do is ephemeral and quickly forgotten, even by ourselves, so it's gratifying to have something you have done linger in people's memories."
-John Williams

Vince Twelve

To get it on top of the characters, you would draw it to an object, GUI, or overlay.  You would then Wait() for however long you want it to show up and then release the drawing surface, delete the sprite, dispose of the overlay, whatever is appropriate to clear out that memory.  You'll need to read about dynamic sprites and drawing surfaces in the manual if you're not clear on them.

Let me know if you need something more specific.

DrewCCU

Quote from: Vince Twelve on Wed 09/06/2010 20:08:47
To get it on top of the characters, you would draw it to an object, GUI, or overlay.  You would then Wait() for however long you want it to show up and then release the drawing surface, delete the sprite, dispose of the overlay, whatever is appropriate to clear out that memory.  You'll need to read about dynamic sprites and drawing surfaces in the manual if you're not clear on them.

Let me know if you need something more specific.

To be honest ... that is exactly how i thought i would need to do it ... i just was wondering if there might be a simpler way.  Maybe a piece of code or something i knew nothing about.  Anyway being that this is the case - i did read up on dynamic sprites some and experimented with it but couldnt seem to get it to work just right so that this line that is drawn would be deleted (not just hidden) after the wait time ... and actually wait() wouldn't work here cus i don't want other scripting to halt ... so i should probably use a timer correct?
"So much of what we do is ephemeral and quickly forgotten, even by ourselves, so it's gratifying to have something you have done linger in people's memories."
-John Williams

Vince Twelve

To delete it, you don't delete the line, you release the drawing surface and delete the dynamic sprite that you drew it on.  (And dispose of the overlay if you were using one.)   Then when you need another one, you could declare it again.  Or you could just clear the drawing surface to remove the line if you want to leave the dynamic sprite in memory.

And yeah, if you don't want it blocking you could use a timer, or set a countdown variable which you decrement in repeatedly_execute_always.

If it's not blocking though, and characters are moving around in the background, you may have to be clearing and re-drawing the line each game loop in repeatedly_execute_always to keep the line on the moving characters.  It depends on what, exactly you're trying to accomplish.

DrewCCU

#6
also - i'm having trouble figuring out how to draw onto a gui ... could you point me in the right direction?

figured it out.
"So much of what we do is ephemeral and quickly forgotten, even by ourselves, so it's gratifying to have something you have done linger in people's memories."
-John Williams

SMF spam blocked by CleanTalk