Need a better way to highlight and select positions around a circle...

0 favourites
From the Asset Store
You can change amount and speed of circles, length of lines and etc. Only 6 events.
  • I need to be able to select points around a circle with either the keyboard or a gamepad (stick or dpad)

    My first attempt sort of works, but you can't select the middle circle.

    I was thinking of setting up a grid with numbers but that doesn't really work without a lot of conditions.

    Any better ideas or better approach I should take?

    dropbox.com/s/rj6q8cie4qleivi/position_select.c3p

  • Here is my version. You can make the Dot sprite invisible.

    dropbox.com/s/craeh1k9zpknkty/position_select.c3p

  • I gave it a quick shot too... I made it like a joystick, so it auto selects the center position unless you are pressing a key. I prefer arrow keys so I used those. I don't have a gamepad to test with so it is keyboard only.

    https://www.rieperts.com/games/forum/position_select2.c3p

  • AllanR oh I like how you use sub-events here, I never do it like that! this is great thanks..

    dop2000 awesome! this works great, yeah I was wondering if an invisible object is the way to go here. And how you use the X/Y with nearest is a completely different approach! I love it, thanks!

  • dop2000 how did you come up with the +/- 20 number? EDIT: nm, I see the size of the sprite is 20x20

    a total gaff by me! I forgot to add in that the main sprite circle is slowly rotating, so that throws things off a bit as everything rotates. I still think your approach is best though since it relies on position.

    its that center one which really messes everything up! since its rotating you can't check the X.

  • yeah this is a tricky one!

    I somehow have to figure a way to go to the center one if you tap WASD in the opposite direction of where we are in relation to the center. But then it has to work when you are in the center as well...

    dropbox.com/s/b2q9glrm5a7qjpv/position_selectDOP2000.c3p

  • got it working a little better, but it sometimes doesn't feel quite right.

    dropbox.com/s/5nkp6p7dh4ja6wr/position_selectDOP2000_mod.c3p

    or try it here:

    spacecapsulegames.com/test

    and let me know what you think (SPACE BAR will pause the spinning)

  • how did you come up with the +/- 20 number? EDIT: nm, I see the size of the sprite is 20x20

    No, it has nothing to do with the sprite size, just some non-zero number.

    Yeah, rotation certainly makes it harder to pick the center point. I would probably do this with LOS behavior on the posHighlight sprite. Set LOS cone of view to something like 60-120 degrees. You'll have to experiment.

    When W is pressed, set posHighlight angle to 270 (up), pick all dots in line of sight, and then pick nearest. When A pressed, set angle to 180 (left), and do the same. This should allow to pick the center dot.

  • dropbox.com/s/mah6i0g1eptlh8r/trigselect.c3p

    Its ok to abuse expressions occasionally isn't it?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • newt sure.. that's a cool way to do it! I could probably figure a way to add it to a trigger and leave the highlight selection in the place you selected after you let go.

  • dop2000 oh nice LOS is another good idea to try... although when you are at the center dot and hit LEFT you will go to the nearest which might not be the one at 3 o'clock.

    One of these ideas should help me. Thanks guys!

  • You can use two LOSs - one with narrower cone of view, another one with wider. Try the first, if it doesn't pick any dots, then try the second.

    (or use one LOS behavior and change cone of view in the event)

  • Seems like an interesting problem. Thanks for everyone for the examples. It took me a bit to realize what they did since I’m on my phone.

    Here’s my event based solution. The first part is just for input, the last event is the meat.

    First it skips the dot the cursor is on.

    Next it picks all the dots in a cone in the direction pressed.

    Then it utilizes “for each ordered” to sort them by distance. It would be the same as “pick closest” but it also adds a fraction of the perpendicular distance so it prefers the dots closer to the direction pressed as opposed to just one of them when they are all the same distance away.

    variable joyx=0
    variable joyy=0
    variable dir=0
    variable move=false
    
    every tick
    -- set move to true
    -- set joyx to 0
    -- set joyy to 0
    
    on left pressed
    -- add -1 to joyx
    
    on right pressed
    -- add 1 to joyx
    
    on up pressed
    -- add -1 to joyy
    
    on down pressed
    -- add 1 to joyy
    
    compare: abs(joyx)+abs(joyy)=0
    -- set move to false
    else
    -- set dir to angle(0,0,joyx,joyy)
    
    move is true
    pick dot by evaluate: dot.x<>cursor.x & dot.y<>cursor.y
    pick dot by evaluate: 45>anglediff(dir, angle(cursor.x, cursor.y, dot.x, dot.y))
    for each dot ordered by distance(cursor.x, cursor.y, dot.x, dot.y) + abs(cos(dir+90)*(dot.x-cursor.x)+sin(dir+90)*(dot.y-cursor.y))/1000 ascending
    -- stop loop
    -- cursor: set position to dot
  • dop2000 thanks! and it even works with moving the circles/image points around a bit. although sometimes it skips too far, but cone and range can be adjusted.

    R0J0hound oh this looks super clever! I need to try this out! thanks!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)