New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New Widget Style & Properties, Overall Refactor/Restructure #3
Conversation
I'll have to take a look at this when I get home to night. I can tell you right now though that self.is_active won't work. Imagine this scenario: Player 1 touches his controller, p1.is_active = true. player 2 touches his controller, p2.is_active is now true. p2 moves his finger, p1 is active so it responds. We'll have to bind the movement to the touch itself, so touch.ud will be necessary. we could use _update_coordinates_external and _update_coordinates_internal for a and b respectively. The names hopefully suggest their purposes. update ext: Update coordinates for a point outside the controller. update int: update coordinates for a point inside the controller. It makes sense in my mind, does that make sense to you? Thanks for all the polish! |
This helped, I managed to fix a few of the issues mentioned in the PR detail based on that. Updated resolved issues with
|
@Enteleform please use proper commit messages and git client :) |
@KeyWeeUsr |
This looks good. I'll merge it and if I run into anything else I'll fix it. Thanks again for all the polish! |
Changes:
Restructured component files
Assigned calculations to variables/properties
Extracted large functions into sub-functions
Removed rectangle background
Added circle size, background color, outline color, & outline width:
_total_diameter
is set tomin(*self.size)
, so the joystick will fill whatever space it is actually given automaticallyAdded 'sticky' property
on_touch_up
Removed
pad_callback
. Callbacks should be added withjoystick.bind(pad=callback)
Moved
radians
&angle
out ofmove_pad
and into their own properties, as they were not reliant on the local calculations & can be calculated @ point of usechangedtouch.ud['pad']
toself.is_active
(should allow multiple pads to work simultaneously on multi-touch devices?)I had to remove all of the documentation for readability while editing to make sure I got everything working correctly. I added it back in afterwards, while also allowing the increased use of named variables & sub-functions to speak for themselves. IMO if everything is broken down into named variables/functions - the code will be mostly self-documenting. (IE: Robert Martin's 'Clean Code' philosophy).
My original code wasn't pep8-ed (not a fan of pep8...), tried my best to pep8 the right way in order to pass the checker.
Updated README. Added GIF example & links to documentation/examples. (already linked @ master, so they'll show up as dead links in my repo but should be fine once merged)
Notes:
Magnitude doesn't seem right? It kind of jumps from around 0.6 or so straight to 1. I'm not too great at math stuff, so can't really verify everything 100%, but I added a coordinate readout to the demo so you should be able to see what's going on pretty easily.Some improved collision detection is required. Not sure if the original had the same issue or if it's due to the way I setup up auto-sizing or something else, but clicking outside of the actual joystick area still activates it (since it's technically still part of the joystick widget):Maybe you have some better names for some of the calculation variables? I tried to make them as relevant as possible, but like I said - math isn't really my thing._update_coordinates_a
&_update_coordinates_b
definitely need some context-providing names, I just wasn't sure of what the conditionrelative_distance > self._radius_difference
mean's exactly. Collision DemoMentionedself.is_active
. Haven't built to mobile yet so can't really test to see if it works for multiple joysticks, each with their own lifecycle for [touch_down
,touch_move
,touch_up
]Let me know if there are any problems with the PR. It's kind of massive, changewise, but I had already drafted most of it so didn't know how to go about doing it incrementally.
Also let me know once everything is sorted out, and I'll update the GIF to include the few new styles & coordinate readout.