Beat Creator, "Saving" The User's Choice
Author |
Message |
mitheralice
|
Posted: Tue Jun 03, 2014 4:57 pm Post subject: Beat Creator, "Saving" 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)
Turing: |
put "See Attached"
|
Please specify what version of Turing you are using
<Turing v 4.1.1>
Description: |
|
![](http://compsci.ca/v3/pafiledb/images/icons/clip.gif) Download |
Filename: |
Beats.t |
Filesize: |
5.4 KB |
Downloaded: |
127 Time(s) |
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Raknarg
![](http://compsci.ca/v3/uploads/user_avatars/3745510004d8be6689b92f.jpg)
|
Posted: Wed Jun 04, 2014 9:03 am Post subject: RE:Beat Creator, "Saving" 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
|
|
|
|
|
![](images/spacer.gif) |
mitheralice
|
Posted: Wed Jun 04, 2014 9:35 am Post subject: Re: Beat Creator, "Saving" 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.
|
|
|
|
|
![](images/spacer.gif) |
Srlancelot39
![](http://compsci.ca/v3/uploads/user_avatars/208361363253ae43a498500.gif)
|
Posted: Wed Jun 04, 2014 9:59 am Post subject: RE:Beat Creator, "Saving" 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...
|
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Wed Jun 04, 2014 10:56 am Post subject: Re: Beat Creator, "Saving" The User's Choice |
|
|
Quote:
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
|
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 a link?
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
mitheralice
|
Posted: Wed Jun 04, 2014 1:57 pm Post subject: RE:Beat Creator, "Saving" 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.
|
|
|
|
|
![](images/spacer.gif) |
mitheralice
|
Posted: Wed Jun 04, 2014 2:30 pm Post subject: RE:Beat Creator, "Saving" 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.
|
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Wed Jun 04, 2014 3:13 pm Post subject: Re: RE:Beat Creator, "Saving" The User\'s Choice |
|
|
mitheralice @ Wed Jun 04, 2014 2:30 pm wrote: I have to click really, really, really, fast.
Called it!
Tony @ Wed Jun 04, 2014 10:56 am wrote:
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
|
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
mitheralice
|
Posted: Thu Jun 05, 2014 1:57 pm Post subject: RE:Beat Creator, "Saving" 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 |
New Problem, it just wont work...
|
|
|
|
|
![](images/spacer.gif) |
|
|