Page 3 of 4

Re: commands U.I friendly

Posted: Mon Jan 17, 2022 1:16 pm
by richmond62
out of curiosity, who puts the fire icons on the posts?
It seems to be something that comes with the Forums packet.
-
Screen Shot 2022-01-17 at 2.15.10 PM.png
Screen Shot 2022-01-17 at 2.15.10 PM.png (5.38 KiB) Viewed 9224 times
-
Гореща Тема?

Re: commands U.I friendly

Posted: Mon Jan 17, 2022 1:45 pm
by Samuele
richmond62 wrote:
Mon Jan 17, 2022 1:14 pm
Somewhere between 1 and 2 something went wrong. :D
:lol:
richmond62 wrote:
Mon Jan 17, 2022 1:14 pm
BUT; the outdated belief that one has to be a Mathematical genius to program computers is nonsense.
Interesting because that belief is really spreading, and it's affecting my math studies :roll:

Re: commands U.I friendly

Posted: Mon Jan 17, 2022 2:01 pm
by richmond62
that belief is really spreading, and it's affecting my math studies
All across Europe there is a drive to get ALL children to do programming.

I have children every summer who have no more Mathematics than I had at the age of 9-10-11 who still manage to
have a computer game finished and working within 24 hours of classes.

When I did PASCAL V programming in my second year at University the only reason I was allowed to do
it was because the Head of the Philosophy department wanted to prove the Head of the Mathematics department wrong:
and he did: I came second out of 100 students.

Re: commands U.I friendly

Posted: Mon Jan 17, 2022 6:06 pm
by Samuele
richmond62 wrote:
Mon Jan 17, 2022 2:01 pm
that belief is really spreading, and it's affecting my math studies
All across Europe there is a drive to get ALL children to do programming.

I have children every summer who have no more Mathematics than I had at the age of 9-10-11 who still manage to
have a computer game finished and working within 24 hours of classes.

When I did PASCAL V programming in my second year at University the only reason I was allowed to do
it was because the Head of the Philosophy department wanted to prove the Head of the Mathematics department wrong:
and he did: I came second out of 100 students.
Wow👏

Re: commands U.I friendly

Posted: Thu Mar 10, 2022 9:43 pm
by Samuele
bobcole wrote:
Mon Jan 17, 2022 5:50 am
Following up on Richmond62's recommendation, I devised an example to calculate the "speed" of dragging an object (a button in this case).
The faster you drag the button from one place to another, the higher the speed in pixels per tick (a proxy for the 'force' exerted).
Admittedly rough but it was a fun exercise that might help.
Bob
DragLineSpeed.livecode.zip
Hi, first of all thanks, second, I'm trying to modify a little bit the stack so that it does:
1) the oval will gradually sas it low down (as it travels along the line created)
2) that the created line will end with the "bottomLeft of button" DragMe "" but with + something (for example + 100)
The stack is this /|\
|
Thanks!

Re: commands U.I friendly

Posted: Sat Mar 12, 2022 4:43 pm
by richmond62
SShot 2022-03-12 at 17.42.28.png
SShot 2022-03-12 at 17.42.28.png (8.13 KiB) Viewed 8743 times
-
Erm . . . ?
to modify a little bit the stack
Which stack is that?

Certainly if you could post it here we could play around
with it and try to understand what you need.

Re: commands U.I friendly

Posted: Sun Mar 13, 2022 11:48 am
by Samuele
richmond62 wrote:
Sat Mar 12, 2022 4:43 pm
Which stack is that?
Certainly if you could post it here we could play around
with it and try to understand what you need.
This one,
DragLineSpeed.livecode.zip
(2.31 KiB) Downloaded 174 times
previously posted by bobcole
bobcole wrote:
Mon Jan 17, 2022 5:50 am
DragLineSpeed.livecode.zip
Thanks!

Re: commands U.I friendly

Posted: Sun Mar 13, 2022 6:59 pm
by Samuele
I think i can phrase my question also in this way, how can i add values to a point, for example, i have a point (240, 70) and i want to add to it and transform it to (250, 80) how can i do it?
well in my case it's a little bit more complicated, because i want the "further" point to be in correspondence with the created line.
Thanks!

Re: commands U.I friendly

Posted: Sun Mar 13, 2022 8:11 pm
by richmond62
240 + 10 = 250

70 + 10 = 80

It isn't that difficult. 8)

Code: Select all

on mouseUp
put item 1 of the loc of img "XXX" into LR
put item 2 of the loc of img "XXX" into UD
move img "XXX" to ((LR + 10), (UD + 10)))
end mouseUp
If you want you can reduce that from 5 lines of code to only 3. :D

Re: commands U.I friendly

Posted: Sun Mar 13, 2022 9:04 pm
by richmond62
Oh, and, as a thought, check out moveSpeed . . . 8)
-
SShot 2022-03-13 at 22.04.25.png

Re: commands U.I friendly

Posted: Sun Mar 13, 2022 11:58 pm
by Samuele
richmond62 wrote:
Sun Mar 13, 2022 8:11 pm
240 + 10 = 250

70 + 10 = 80

It isn't that difficult. 8)

Code: Select all

on mouseUp
put item 1 of the loc of img "XXX" into LR
put item 2 of the loc of img "XXX" into UD
move img "XXX" to ((LR + 10), (UD + 10)))
end mouseUp
If you want you can reduce that from 5 lines of code to only 3. :D
Thanks! that worked in general, but i realized that it doesn't make sense for what I'm trying to do...
now I'm talking about the stack previously shared.
I'm trying to make that the created line will be longer then just the location the user dragged the button but respectively to its movement.
for example:
Screenshot 2022-03-14 003610.png
so I think i need to get the equation of the created line and the add to line numbers corresponding to the same equation.
Thanks!

Re: commands U.I friendly

Posted: Tue Mar 15, 2022 12:14 pm
by Samuele
i got the idea, how can i make it in a way that works?

Code: Select all

on Calculatem
   #put all the single nnumbers of the points into variables to semplify the altogheter
   put item 1 of sDragStartPosition into tsX
   put item 2 of sDragStartPosition into tsY
   put item 1 of sDragEndPosition into teX
   put item 2 of sDragEndPosition into teY
   
   #the function of the m (pendence)
   put ((tsY - teY) / (tsX-teX)) into m
end Calculatem


function CalculateFunction
   return Y - teY = m * (X - teX)
end CalculateFunction

Re: commands U.I friendly

Posted: Tue Mar 15, 2022 12:45 pm
by richmond62
You first need to catch the SPEED at which the user drags the object.

Code: Select all

global startT
global startLR
global startUD

on mouseDown
put the time into startT
put item 1 of the loc of me into startLR
put item 2 of the loc of me into startUD
grab me
end mouseDown

on mouseUp
put item 1 of the loc of me into finLR
put item 2 of the loc of me into finUD
put the time into finT
put (finT - startT) into timeTAKEN
put (1/timeTaken) into mSpeed
Then you use my Mathematics and multiply it by something like 2 * 1/X where X is the time taken.

Then you can do something with the horizontal distance moved and the vertical distance moved to work out the direction
and then calculate a move factor based on the time taken.

Re: commands U.I friendly

Posted: Tue Mar 15, 2022 12:49 pm
by Samuele
yeah I'm in the middle of it, something like this?

Code: Select all

local sDragStartTicks, sDragEndTicks, sDragDurationTicks --script variables
local sDragStartSeconds, sDragEndSeconds, sDragDurationSeconds
local sDragStartPosition, sDragEndPosition
local sLineLength

on mouseDown pButtonNumber
   put empty into message box
   put the loc of me into sDragStartPosition
   set the loc of graphic "oval" to sDragStartPosition
   put the ticks into sDragStartTicks
   grab me   
end mouseDown

on mouseUp pButtonNumber
   put the loc of me into sDragEndPosition
   put the ticks into sDragEndTicks
   
   put (sDragEndTicks - sDragStartTicks) into sDragDurationTicks
   put "sDragDurationTicks: " & sDragDurationTicks & return after message box
   put sDragDurationTicks / 60 into sDragDurationSeconds
   put "sDragDurationSeconds: " & sDragDurationSeconds & return after message box
   
   put "sDragStartPosition " & sDragStartPosition & return after message box
   put "sDragEndPosition " & sDragEndPosition & return after message box
   put item 1 of sDragEndPosition - item 1 of sDragStartPosition into tHorizontalPixels
   put item 2 of sDragEndPosition - item 2 of sDragStartPosition into tVerticalPixels
   
   --calculate the length of the line and the speed 
   put "tHorizontalPixels: " & tHorizontalPixels & return after message box
   put "tVerticalPixels: " & tVerticalPixels & return after message box
   set the numberFormat to "#.#"
   #QUESTA è LA DISTANZA!!! (d= sqrt(x-x)^2 + (y-y)^2)
   put sqrt(tHorizontalPixels^2 + tVerticalPixels^2) into sLineLength
   put "sLineLength: " & sLineLength & " (pixels)" & return after message box
   put sLineLength into field "Line Length"
   put sLineLength/sDragDurationTicks into tDragSpeed --pixels per tick
   put "tDragSpeed: " & tDragSpeed & " (pixels/tick)" & return after message box
   put tDragSpeed into field "Speed"
   
   drawLine sDragStartPosition, sDragEndPosition
   put the bottomLeft of button "DragMe" into tTryEndPlus
   #put item 1 of the loc of btn "DragMe" into tX
   #put item 2 of the loc of btn "DragMe" into ty
   set the bottomLeft of button "DragMe" to sDragEndPosition
   #put ((tX - 0), (tY - 50)) into sDragEndPosition
   
   moveCircle sDragStartPosition, sDragEndPosition, sDragDurationTicks
end mouseUp

command drawLine pStartPoint,pEndPoint
   set the points of graphic "Line" to pStartPoint,pEndPoint
end drawLine

command moveCircle pStartPoint,pEndPoint,pDragDurationTicks
   move graphic "Oval" to pEndPoint in pDragDurationTicks ticks
end moveCircle


on Calculatem
   #put all the single nnumbers of the points into variables to semplify the altogheter
   put item 1 of sDragStartPosition into tsX
   put item 2 of sDragStartPosition into tsY
   put item 1 of sDragEndPosition into teX
   put item 2 of sDragEndPosition into teY
   
   #the function of the m (pendence)
   put ((tsY - teY) / (tsX-teX)) into m
   
   #Set the X and the Y as a further point according to the m and the teY / tsY
   if m > 0 and if teY < tsY
   then
      put (teX + (sLineLength)) into X
      put 
      
   end Calculatem


function CalculateFunction
   #return Y - teY = m * (X - teX)
   return m * X - (m * teX) + teY
   #put into Y
end CalculateFunction
(most of the code is from bobcole)

Re: commands U.I friendly

Posted: Fri Mar 18, 2022 10:08 am
by richmond62
Free day today: the code took 10 minutes:

Code: Select all

local T1
local T2
local LR1
local UD1
local LR2
local UD2

on mouseDown
   put item 1 of the loc of me into LR1
   put item 2 of the loc of me into UD1
   put the milliseconds into T1
   grab me
end mouseDown

on mouseUp
   put the milliseconds into T2
   put item 1 of the loc of me into LR2
   put item 2 of the loc of me into UD2
   put LR2 - LR1 into relLR
   put UD2 - UD1 into relUD
   put T2 - T1 into SEX
   put (1 / SEX) into XES
   put (XES * 100) into XXES
   put (LR2 + (relLR * XXES)) into distLR
   put (UD2 + (relUD * XXES)) into distUD
   put (100000 * XES) into ballSPEED
   set the moveSpeed to ballSPEED
   move me to distLR, distUD
end mouseUp
-
footie.jpg
-
Of course the thing needs a spot of refinement such
as a script to stop the ball going off into cyberspace. :D

But as I am fairly goofy mathematically I wonder why there seems
to be such a cafuffle about doing this sort of thing.