Drawing a dotted line and clearing it [solved]

Started by AnasAbdin, Mon 05/10/2015 19:02:42

Previous topic - Next topic

AnasAbdin

Well after Vincent started this thread 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.



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 :)

Mandle

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.

Scavenger

It's very very rough, but it's the quickest solution I could think of to make a dotted line:


Game project is here.

AnasAbdin

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.

Mandle

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...

AnasAbdin

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.

Scavenger

#6
OK, it didn't seem like that much of a problem to try and rig up something that would work:



Game project is here

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.

AnasAbdin

#7
Thanks :) But I can't seem to unzip the second file  :-\

Edit: The file is fine, I had a download error.

Scavenger


AnasAbdin


SMF spam blocked by CleanTalk