Thread: Calling a function on event

  1. #1
    Registered User
    Join Date
    Sep 2012
    Posts
    43

    Calling a function on event

    Hello!

    I programmed the 4 in line game in ASCII characters. Now, I am creating a visual interface for it, and this brings whole new concepts that I must learn.

    I using the openCV library, and with it I was able to draw the game board. This library also has some mouse callback functions that allow me to use the mouse to make a move on the board easily.

    But when it comes to the computer making a move on its own, it is not that simple.

    I have a variable that changes between 1 and 2, depending on who's turn it is to play. I was wondering if there is any way to call the function that generates the move every time that variable changes to 2 (computers turn).


    If maybe you could provide a simple example, for example, a function that prints "Hello" every time a counter changes in some other function (without calling it ofc), I think I could understand and adapt it to my code.
    Last edited by Median; 11-10-2012 at 02:08 PM.

  2. #2
    Bored Programmer
    Join Date
    Jul 2009
    Location
    Tomball, TX
    Posts
    428
    I have a variable that changes between 1 and 2, depending on who's turn it is to play. I was wondering if there is any way to call the function that generates the move every time that variable changes to 2 (computers turn).
    Code:
    if(turn == 2)
      ComputerMove();
    would be the simple call. The definition would be the more complicated part.
    Virtual reality hello world http://www.rodneybrothers.com/vr/vrh...rld/index.html in html and javascript.
    Viewable with dodocase, google cardboard, OR, and other compatible VR gear.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Calling event from Dialog Box in C++?
    By Deaneaux in forum Windows Programming
    Replies: 1
    Last Post: 08-30-2011, 07:38 PM
  2. Replies: 2
    Last Post: 06-06-2011, 08:23 AM
  3. Replies: 3
    Last Post: 12-22-2009, 01:00 PM
  4. calling aspx from button event
    By mixalissen in forum C# Programming
    Replies: 1
    Last Post: 07-04-2008, 12:56 AM
  5. How to get Quit event of WORD from our function?
    By lucadoi in forum Windows Programming
    Replies: 3
    Last Post: 10-09-2007, 11:22 AM