Hi Simon,
the moveToNextPhaseCode looks like this
Code: Select all
on moveToNextPhase
if correctResponse is 15 then
go to next card
else
go to openCard
end if
end moveToNextPhase
the keyDown contains this
Code: Select all
on keyDown theKey
if theKey is k then
if vRandomLocation is 2 then
set the visible of img "GREEN CHECK.png" to true
add 1 to correctResponse
go to moveToNextPhase
else
set the visible of img "RED X.png" to true
put 0 into correctResponse
end if
pass keyDown
else if theKey is d then
if vRandomLocation is 1 then #get location of correct response
set the visible of img "GREEN CHECK.png" to true
add 1 to correctResponse
go to moveToNextPhase
else #If response is incorrect
set the visible of img "RED X.png" to true
put 0 into correctResponse
end if
pass keyDown
else
end if
end keyDown
What I tried to have happen is the program evaluates the key press as either correct or incorrect based on the variable vRandomLocation which is also used to decide which position images are placed in (left or right in this case). If the user response is correct it shows a green check, adds one to correctResponse, and goes to moveToNextPhase where it evaluates if the user got 15 correct response in a row. If the user response is incorrect it shows a red x puts 0 into correctResponse and then waits for the user to input a correct response before restarting from the openCard and doing everything again. Right now it displays the images correctly and takes the user input and evaluates it correctly and displays the green check or red x appropriately, but doesn't go back to the openCard to execute again.
You can ignore the code in the first post: that's where I was playing around with it in a simpler version of the program to see if I could get it to work there, but no such luck. The rest of the code I posted is from the actual program I'm working on.
Craig, I've played around some with 'wait' but I'm wondering now if it would be easier to try and have this work without a repeat loop (or if it will work without a repeat loop).
And you are correct about the inexperience. I'm trying to teach myself how to do this as I go. I have no previous coding experience, so I really appreciate everyone's help.
Jeff