
-----------------------------------
mitheralice
Tue Jun 03, 2014 4:57 pm

Beat Creator, &quot;Saving&quot; The User's Choice
-----------------------------------
What is it you are trying to achieve?
I want to make a beat maker, similar to the following: http://www.drumbot.com/projects/pattern_sequencer/


What is the problem you are having?
The problem I'm having is try to "remember/save" all of the user's choices. When they click on a box, I want that box to be "saved" until they deactivate it. The box needs to be activated, and stay activated, so when the beat timer (metronome) activates that tile. 


Describe what you have tried to solve this problem
I've looked into forking, and procedures, neither yielded the result I wanted.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)




put "See Attached"



Please specify what version of Turing you are using


-----------------------------------
Raknarg
Wed Jun 04, 2014 9:03 am

RE:Beat Creator, &quot;Saving&quot; The User\'s Choice
-----------------------------------
Before you go any further with this, you need to go to the Turing Walkthrough and learn about arrays, then use them in your program. This will help tremendously

-----------------------------------
mitheralice
Wed Jun 04, 2014 9:35 am

Re: Beat Creator, &quot;Saving&quot; The User's Choice
-----------------------------------
Thank you for responding, I have used arrays and this has helped a lot. 

I have a new problem, when I click the button it activates, now I want it to un-click if I need it to.

if b = 1
            then
        if x > 100 and x < 150
                and y > 325 and y < 375
                then
            re (3) := 1
        end if
    end if


I'm willing to use right click, but I don't know how to receive information from the right button.

So 
if b > 1 or b < 1
then
re (3) := 2
or something similar.

-----------------------------------
Srlancelot39
Wed Jun 04, 2014 9:59 am

RE:Beat Creator, &quot;Saving&quot; The User\'s Choice
-----------------------------------
If I remember correctly, 1 is left click, 100 is right click.  So you would check to see if the button number from mousewhere is 100...

-----------------------------------
Tony
Wed Jun 04, 2014 10:56 am

Re: Beat Creator, &quot;Saving&quot; The User's Choice
-----------------------------------

un-click

[code]
if b = 1 then 
   if x > 100 and x < 150 and y > 325 and y < 375 then 
      re (3) := 1 % what does it mean if re(3) already has a value of 1? 
   end if 
end if 
[/code]

But you'll quickly discover something interesting about mouse buttons. The mouse button state is read hundreds of time per second, so holding the mouse down is not the same as a click. If you consider the passage of time, you can double the number of mouse states:

UP-UP (nothing is happening)
UP-DOWN (clicked down just this moment)
DOWN-DOWN (holding the button down)
DOWN-UP (release the button just this moment)

Test this out! What happens when you click-and-hold on [url=https://en.wikipedia.org/wiki/Finite-state_machine]a link?

-----------------------------------
mitheralice
Wed Jun 04, 2014 1:57 pm

RE:Beat Creator, &quot;Saving&quot; The User\'s Choice
-----------------------------------
I just want to change the value of re(3) if the user clicks on it more than once, or with another mouse button.

-----------------------------------
mitheralice
Wed Jun 04, 2014 2:30 pm

RE:Beat Creator, &quot;Saving&quot; The User\'s Choice
-----------------------------------
Mouse.Where (x, y, b)
    if b = 1
            then
        if x > 100 and x < 150
                and y > 125 and y < 175
                then
            re (1) := 1
            resetvalue (1) := 1
        end if
    end if
    
    
    Mouse.Where (x, y, b)
    if b = 1 and resetvalue (1) > 0
            then
        if x > 100 and x < 150
                and y > 125 and y < 175
                then
            re (1) := 2
            resetvalue (1) := 0
        end if
    end if

I managed to do this, and this works well, but now I have a fresh problem, this isn't efficient, and I have to click really, really, really, fast.

I need to do this 56 times, is there any way to make this automatic with a certain array, if so please respond. Thank you.

-----------------------------------
Tony
Wed Jun 04, 2014 3:13 pm

Re: RE:Beat Creator, &quot;Saving&quot; The User\'s Choice
-----------------------------------
I have to click really, really, really, fast.

Called it!


But you'll quickly discover...

Read my previous comments again. You want to somehow capture the UP-DOWN (or DOWN-UP) transition. Checking for b = 1 is looking only at "DOWN".
[code]
if previous_state = 0 and current_state = 1 then
   % UP-DOWN
[/code]

-----------------------------------
mitheralice
Thu Jun 05, 2014 1:57 pm

RE:Beat Creator, &quot;Saving&quot; The User\'s Choice
-----------------------------------
[code]loop 
    count := count + 1 
    if count > 7 
            then 
        count := 1 
    end if 
    holdy := holdy + 50 

    if holdy > 600 
            then 
        hold := 0 
    end if 

    Mouse.ButtonChoose ("multibutton") 
    Mouse.Where (x, y, b) 
    left := b mod 10               % left = 0 or 1 
    middle := (b - left) mod 100       % middle = 0 or 10 
    right := b - middle - left         % right = 0 or 100 
    if left = 1 then 
        if x > 100 + hold and x < 150 + hold 
                and y > 125 + holdy and y < 175 + holdy 
                then 
            re (count) := 1 
            Music.Play ("aaa") 
        end if 
    end if 
    if right = 100 then 
        if x > 100 and x < 150 
                and y > 125 and y < 175 
                then 
            re (count) := 0 
        end if 
    end if 

    if re (count) = 1 
            then 
        Draw.FillBox (100, 125 + holdy, 150, 175 + holdy, red) 


    elsif re (count) = 0 
            then 
        Draw.FillBox (100, 125 + holdy, 150, 175 + holdy, black) 
        Draw.Box (100, 125 + holdy, 150, 175 + holdy, red) 
    end if 

end loop [/code]


New Problem, it just wont work...
