
-----------------------------------
Shamoy
Wed May 07, 2014 4:45 pm

Need help with turing game menu
-----------------------------------
So im making a game in turing and im using loops, if statements, and mousewhere for a flat design button. The only problem is that when I press the button and let go, it doesnt take me to the next part of the program. Can anyone help me on this? Thanks ^_^

-----------------------------------
Raknarg
Wed May 07, 2014 9:16 pm

RE:Need help with turing game menu
-----------------------------------
Correct me if I'm wrong, but it doesn't look like there is a next part of the program. This is all I have in the main loop:


loop

    mousewhere (mouseX, mouseY, button)

    delay (6)

    if mouseX > 415 and mouseX < 865 and mouseY > 170 and mouseY < 425 and button = 0 then

        delay (1)

        Pic.Draw (hoverButton, 0, 0, picCopy)

        delay (1)

    elsif button = 1 and mouseX > 415 and mouseX < 865 and mouseY > 170 and mouseY < 425 and button = 1 then

        delay (1)

        Pic.Draw (pressedButton, 0, 0, picCopy)

        delay (1)

    else

        delay (1)

        Pic.Draw (unpressedButton, 0, 0, picCopy)

        delay (1)

    end if

end loop


-----------------------------------
TWizard
Thu May 08, 2014 2:18 pm

RE:Need help with turing game menu
-----------------------------------
The question now is, where do you want the next part to be? you will need to create another menu image, and type out more positions for the menu items you want to have.

-----------------------------------
Shamoy
Thu May 08, 2014 4:14 pm

Re: Need help with turing game menu
-----------------------------------
my plan is to display another picture when the game starts but i dont know what to do to make it exit the loop after i click it and let go

-----------------------------------
Raknarg
Thu May 08, 2014 4:38 pm

RE:Need help with turing game menu
-----------------------------------
Maybe keep track of the clicking state. If It was clicking in the previous frame, but now it is not, then you know the user has clicked the button.


loop
    if isClicking() then
        clicking := true
    elsif clicking then
        clicked := true
        clicking := false
    end if

    if clicked then
        clicked := false
        %do domething
    end if
end loop


-----------------------------------
Shamoy
Sat May 10, 2014 10:16 am

Re: Need help with turing game menu
-----------------------------------
how would i be able to integrate that into my code though?

-----------------------------------
Shamoy
Sat May 10, 2014 2:06 pm

Re: Need help with turing game menu
-----------------------------------
so i updated it and wanted to see if i could make it exit this way but the problem is that after i click it, i want it to exit when i let go of it (not when i directly click it)

[code]% Looping to display different button images

loop

    mousewhere (mouseX, mouseY, button)

    delay (6)

    if mouseX < 415 and button = 0 or mouseX > 865 and button = 0 or mouseY < 170 and button = 0 or mouseY > 425 and button = 0 then

        delay (1)

        Pic.Draw (unpressedButton, 0, 0, picCopy)

        delay (1)

    elsif mouseX > 415 and mouseX < 865 and mouseY > 170 and mouseY < 425 and button = 0 then

        delay (1)

        Pic.Draw (hoverButton, 0, 0, picCopy)

        delay (1)


    elsif mouseX > 415 and mouseX < 865 and mouseY > 170 and mouseY < 425 and button = 1 then

        loop

            delay (1)

            Pic.Draw (pressedButton, 0, 0, picCopy)

            if mouseX > 415 and mouseX < 865 and mouseY > 170 and mouseY < 425 and button = 0 then

                delay (1)

                Pic.Draw (unpressedButton, 0, 0, picCopy)

                delay (150)
                
                clicked := true
               
            end if

            exit when clicked = true
            
        end loop

    end if

    exit when clicked = true

end loop

% Next part[/code]
