User Tag List

Page 1 of 2 1 2 LastLast
Results 1 to 10 of 12

Thread: Using the surface object to draw a line to the closest object of the same kind.

  1. #1
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module

    Join Date
    Nov 2011
    Location
    Melbourne, Australia
    Posts
    150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Using the surface object to draw a line to the closest object of the same kind.

    Hi, Im trying to use the surface object to draw a line from the x and y co ordinates of one object to another of the same type, so someone could for example click the mouse to spawn an object (a point) and the last point created would draw a line to the new point, I'd like to have versions based on distance to the nearest object and last object spawned.
    In practice this would be a bit like using the tool in ms paint that draws lines every time you click the mouse, and loops to the start when you double click.
    Iv'e really tried to figure this out on my own but i'm really at a loss on how to do this, so if any click team code masters would like to share their wisdom, that would be very much appreciated

  2. #2
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,156
    Mentioned
    27 Post(s)
    Tagged
    1 Thread(s)
    Here's a very quick example
    (if I got what you need )

    point_click_paint.mfa

    (just add object creation at xmouse,ymouse in events 3,4 - forgot about that )

  3. #3
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,156
    Mentioned
    27 Post(s)
    Tagged
    1 Thread(s)
    Sorry, just re-read your question
    totally overlooked the "pick nearest" part
    here's it below:

    point_click_paint_obj.mfa

    left click is just point-click line (red line)
    right click will pick the nearest object (blue line)
    double click left or right will close to starting point (green line)

  4. #4
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module

    Join Date
    Nov 2011
    Location
    Melbourne, Australia
    Posts
    150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow, you are an absolute legend man. I've been after this for so long, i'm going to do alot with this.
    thanks a ton

  5. #5
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module

    Join Date
    Nov 2011
    Location
    Melbourne, Australia
    Posts
    150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    One other thing. With the example, on the "nearest" loop the odistance check for active (the points placed) tests against the position of Xmouse, ymouse, is there a way to replace this with nearest active instead?

    What im trying to do is place all the points first, then on key press, join all the nearest points (clear surface, then redraw all points), this way a room could be pre-populated, or even have the points loaded from an array.

  6. #6
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,156
    Mentioned
    27 Post(s)
    Tagged
    1 Thread(s)
    Hey Jinxtengu,
    reading from your various post I'm not sure I've figure it out precisely,
    if I got it correctly,
    you want to do things this way, and in this succession:

    1) you want to place objects without drawing lines

    2) on key press, you want the system to join all points following all of these rules:

    a) each point must be connected to the nearest "not-already-connected" point
    b) ^ save for last point, which must be connected to the "starting point"
    c) starting point is the first point you place when creating objects (or?)

  7. #7
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module

    Join Date
    Nov 2011
    Location
    Melbourne, Australia
    Posts
    150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey Schrodinger,
    my apologies if I didn't clearly explain what i was trying to achieve, I'll try to clarify your points.
    Here is the order I'm after.

    1) place objects without drawing lines

    2) on key press, the system will join all points following all of the rules

    a) each point must be connected to the nearest "not-already-connected" point,
    B, and C aren't necessary.
    The purpose of the script is to construct a drawing from a saved array file, that's my ultimate goal here.
    By the way thanks for your support, the examples you posted have been extremely useful!!
    Images attachées Images attachées

  8. #8
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,156
    Mentioned
    27 Post(s)
    Tagged
    1 Thread(s)
    sorry another question: sure you don't need to store a "sequence" of points?
    say you place a,b,c,d etc. then you want to connect them again in the same order a,b,c,d...

    nearest points may not give you desired result if you are up to make a drawing,
    it is likely they won't make up for a drawing in the end, if you don't place hem specifically knowing this rule
    (but perhaps this is the challenge / purpose of the game ?)

  9. #9
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module

    Join Date
    Nov 2011
    Location
    Melbourne, Australia
    Posts
    150
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i know you're right there. creating an image using nearest objects as a rule to connect lines probably wouldn't work well, i was just curious to see how it could be done. i can't seem to work it out. in the example you posted the program is comparing the nearest point to the mouse position, rather than the nearest point to the nearest point, that could create a pretty cool electricity effect i think.
    but anyway, with loading from an array it would probably need to place a,b,c,d in the same order and also have a number designated to 'break' the line drawing. I've been doing some test drawing and you do need to break the line sometimes in order to create ok drawings. i've been able to do that at least. no, the nearest point is not related to the purpose of the game i had in mind, i just thought it might be a cool and memory efficient way to build levels, background scenery mainly...

  10. #10
    Clicker Fusion 2.5 DeveloperAndroid Export ModuleHTML5 Export ModuleiOS Export Module
    Fusion 2.5 (Steam)
    schrodinger's Avatar
    Join Date
    Nov 2014
    Posts
    3,156
    Mentioned
    27 Post(s)
    Tagged
    1 Thread(s)
    above example was comparing xmouse,ymouse to the nearest object,
    because I thought you needed to connect the object you just placed to the "nearest" object found around

    can't picture how to compare the nearest point to the nearest point, isn't that a recursion?
    you mean each point would search for nearest other plotted point, independently from mouse position

    but you still need to plot points with mouse.. so it's a two phases thing:
    first you plot with mouse
    then you connect all plotted points using the nearest rule
    (but since they would be joined depending on which one is nearest and "still available", starting point matters,
    it would determine slightly different drawing if it was started from a point or another)

    (sorry for all questions I'm having hard times picturing what you're precisely after )

Page 1 of 2 1 2 LastLast

Similar Threads

  1. Surface or Draw Object / HTML5?
    By drnebula in forum HTML5 Export Module 2.5
    Replies: 1
    Last Post: 23rd December 2016, 10:01 AM
  2. Who needs a kind of draw object like me?
    By tom79 in forum Android Export Module 2.5
    Replies: 8
    Last Post: 28th February 2014, 01:39 AM
  3. [request] draw/surface-like object
    By SolarB in forum iOS Export Module Version 2.0
    Replies: 2
    Last Post: 8th October 2013, 09:45 AM
  4. Draw Line avec l'extension surface.
    By SpringUp in forum File Archive
    Replies: 4
    Last Post: 24th October 2011, 12:22 AM
  5. [Screen Draw Object]Bug with Draw Line
    By LB in forum Extension Development
    Replies: 1
    Last Post: 2nd June 2009, 01:32 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •