Calling a function on event

This is a discussion on Calling a function on event within the C Programming forums, part of the General Programming Boards category; Hello! I programmed the 4 in line game in ASCII characters. Now, I am creating a visual interface for it, ...

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

    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 01:08 PM.

  2. #2
    Bored Programmer
    Join Date
    Jul 2009
    Location
    Tomball, TX
    Posts
    404
    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.

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, 12: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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21