none
having two different functions for the mousedown command RRS feed

  • Question

  • hi im having problems with this tic tac toe program im writing i need to have a different function for each click of the mouse. so it will display noughts the first click and crosses on the next click my code can be found   at http://smallbasic.com/program/?DBR837 ive tried goto statements ,for loops ,while loops and if loops can you help me please.

    Sunday, July 4, 2010 7:15 PM

Answers

  • show progrm id dbr837-0. if you press the left mouse button it draw elipse and press right button it draw X.

    i have change the mouse event and the subroutine o and ex. i write a new subroutine for the mouse event.
    I hope it helps you.

     


    Best Regards Martin
    Sunday, July 4, 2010 7:41 PM

All replies

  • show progrm id dbr837-0. if you press the left mouse button it draw elipse and press right button it draw X.

    i have change the mouse event and the subroutine o and ex. i write a new subroutine for the mouse event.
    I hope it helps you.

     


    Best Regards Martin
    Sunday, July 4, 2010 7:41 PM
  • import: MCT374-0
    • Edited by Kroltan Sunday, July 4, 2010 9:46 PM added clear button
    Sunday, July 4, 2010 9:38 PM
  • show progrm id dbr837-0. if you press the left mouse button it draw elipse and press right button it draw X.

    i have change the mouse event and the subroutine o and ex. i write a new subroutine for the mouse event.
    I hope it helps you.

     


    Best Regards Martin
    when i right-click your program, it draws a X, right-click again and it draws a +

    |"| /"/|"""\ /"""\|"| |__ __| /\ |"""\ |"| | |/ / | " / | | || | | | / \ | |\ \ | | | |\ \ | | \ | | || |__ | | / \ | | \ \| | |_| \_\|_|\_\\___/|____| |_| /_/""\_\|_| \___|
    Sunday, July 4, 2010 9:48 PM
  • Martmen example slightly modifiedwith comments  to fix the issue spotted by Kroltan, and centre the Xs Os in clicked segment.

    Import dbr837-1.

    Monday, July 5, 2010 6:37 PM
    Moderator
  • thanks very much martmen , kroltan and litdev i am very great-full for your help

    i just wanted to know ,what i was trying to do before with different functions for each click of the mouse is it even possible? thanks ,

    also kroltan your program wont run i dont think small basic has a function called controls.

    Monday, July 5, 2010 7:08 PM
  • stupodio,

    Here is another slight mod showing how to use a single click to alternate player goes from X to O to X etc.

    A flag is set when the mouse is clicked.

    The variable 'player' alternates from 1 to 2 to 1 etc with each go.

    I used a While ("True") ... EndWhile loop for the main game, just repeating this loop and waiting for mouse clicks to be registered with the flag variable 'clicked'

    Import dbr837-2.

    Monday, July 5, 2010 7:20 PM
    Moderator
  • do you have smallbasic 0.9?

    i have it, so it haves the controls object


    |"| /"/|"""\ /"""\|"| |__ __| /\ |"""\ |"| | |/ / | " / | | || | | | / \ | |\ \ | | | |\ \ | | \ | | || |__ | | / \ | | \ \| | |_| \_\|_|\_\\___/|____| |_| /_/""\_\|_| \___|
    Tuesday, July 6, 2010 10:02 PM
  • thanks guys this has really taught me alot about what small basic can do

    kroltan-pardon the ommission

    litdev-thats an awesome soloution i would have just sat there and stared at the screen for a while.

    Thursday, July 8, 2010 4:51 PM