Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: AnasAbdin on Mon 05/10/2015 19:02:42

Title: Drawing a dotted line and clearing it [solved]
Post by: AnasAbdin on Mon 05/10/2015 19:02:42
Well after Vincent started this thread (http://www.adventuregamestudio.co.uk/forums/index.php?topic=52727.0) in the Beginners' Technical Questions. I remembered trying to make a pool game with AGS a year ago. I didn't spend much time with the Math because I was too busy with my other AGS projects. So when I met my first obstacle I ran away like a kid.

Here's the situation, there is an object (1 ball only) when the user clicks and holds the mouse button a dotted line is drawn between the ball object and the mouse cursor. So when the mouse moves a little further the line gets longer, and when nearer the line gets shorter. The line also moves along with the cursor. However, there is a limit to the line (e.g not more than 50 pixels..) the length of the line indicates the strike strength. The position the ball would move to is calculated from the mouse and current ball position... of course the line is cleared when the mouse button is released.

(http://i.imgur.com/Q4u1vC7.png)

I found an old topic with a similar idea but using old RawDraw commands which drove me elsewhere. How can I achieve this effect with AGS 3.3 and later? I'm not asking for a full code script, but the general idea on how to achieve this (dotted effect)
Many thanks in advance :)
Title: Re: Drawing a dotted line and clearing it
Post by: Mandle on Tue 06/10/2015 00:18:17
Hmmmmm...Could you turn on a checkerboard patterned object with alternate transparent/same-green-as-pool-table squares and have the balls baseline set so they are on top of it but the line draws behind it?

A rough-and-ready solution at best which probably has weird results depending on the angle of the line.

I have no idea about a code solution.
Title: Re: Drawing a dotted line and clearing it
Post by: Scavenger on Tue 06/10/2015 02:16:49
It's very very rough, but it's the quickest solution I could think of to make a dotted line:
(https://dl.dropboxusercontent.com/u/50882197/art/GameStuff/dotted_line.PNG)

Game project is here. (https://dl.dropboxusercontent.com/u/50882197/art/GameStuff/dotted.zip)
Title: Re: Drawing a dotted line and clearing it
Post by: AnasAbdin on Tue 06/10/2015 06:40:06
Sounds interesting Mandle. I was thinking of creating two 1x1 sprites (black and white) and see where I can go from there.

Scavenger: This looks very interesting and promising. I will try it later from my home PC  :) but so far this looks exactly like the effect I am looking for.
Title: Re: Drawing a dotted line and clearing it
Post by: Mandle on Tue 06/10/2015 06:51:58
AH...I didn't look carefully enough. I thought it was a white dotted line on a dark green background. I didn't notice the gaps in between were black. Need my glasses on I guess...
Title: Re: Drawing a dotted line and clearing it
Post by: AnasAbdin on Tue 06/10/2015 07:04:50
Mandle: Ha! This is called karma for what you did to us in your points game  (laugh)

Scavenger: I couldn't wait to get home, I ran your code and played a little with it. It is PERFECT. Just need to see how to limit the line length to a specific number of sprites though.
But seriously thanks a lot.
Title: Re: Drawing a dotted line and clearing it
Post by: Scavenger on Tue 06/10/2015 10:36:19
OK, it didn't seem like that much of a problem to try and rig up something that would work:

(https://dl.dropboxusercontent.com/u/50882197/art/GameStuff/dotted2.PNG)

Game project is here (https://dl.dropboxusercontent.com/u/50882197/art/GameStuff/dotted3.zip)

It all predicates about finding the length of the line, and then putting the mouse back to a position where the line isn't over 50 pixels. It works quite well. Also, I tried to smooth the line a bit with some grey pixels, it looks a LITTLE smoother but it's literally just five seconds of work to avoid some of the harshness of the original.
Title: Re: Drawing a dotted line and clearing it
Post by: AnasAbdin on Tue 06/10/2015 10:48:31
Thanks :) But I can't seem to unzip the second file  :-\

Edit: The file is fine, I had a download error.
Title: Re: Drawing a dotted line and clearing it
Post by: Scavenger on Tue 06/10/2015 10:56:06
Try downloading this one (https://dl.dropboxusercontent.com/u/50882197/art/GameStuff/dotted3.zip)?
Title: Re: Drawing a dotted line and clearing it
Post by: AnasAbdin on Tue 06/10/2015 11:00:31
Perfect. Thanks  :)