Solved

URGENT: CONSOLE APP

Posted on 2000-05-12
3
183 Views
Last Modified: 2010-04-02
i´m doing the reversi game (kind of checkers) and my project consists on a Win32 Concole
Application,since i don´t want to use windows functions ,or MFC or other kind of project type my question
is:
imagine that on the left upper corner of the console i have 2 menu options : Start Game and
Quit Game.
i just want to ignore the keyboard and use the mouse as my main input.
I would like to know how can i ( using only console related functions....)
validate if the player made a click on the "Start Game" screen area ,for example,
without any kind of loop...i´d like to use a sort of an event,that is constantly
checking the input on those screen coordinates,while the game is going on...
i don´t want to have code like the following:

do
  do
  {
      playerX_move();
       ..........
       validation code goes here
       ..........
      show_score();
  }while (!move_is_legal(playerX) );
while ( mouseclick_area      != menu_options_screen_area)

the first do...while is the one that i want to avoid...imagine that the player made the
click on "Quit Game" before making the move...only when the nested do...while was done
(after validating the move and showing the score) only after that my program could validate the
mouseclick_area and i don´t want that...i want to do things instantly....

if any of you guys could help me out i´d be thankful,because this is my last college project
this year :)

best regards

Rui

Lisbon,Portugal
0
Comment
Question by:Rui_Cunha
  • 2
3 Comments
 

Expert Comment

by:wraith0
ID: 2806313
Hello,
Just an idea, but have you thought of using an interrupt?
0
 
LVL 22

Accepted Solution

by:
nietod earned 100 total points
ID: 2806743
>> i don´t want to use windows functions
You will have to.   Standard C++ has no support for mice (or even graphical displays).  

>> using only console related functions
If you mean the Windows console functions, these are Windows API functions.  

You can use the ReadConsoleInput() windows API function to read mouse information.  This procedure will return more than just mouse information, it will return input (keyboard) information and information about the window being moved.  But that should not be a problem, you can just ignore the information you don't want.
0
 
LVL 22

Expert Comment

by:nietod
ID: 2806747
You might have code like

HANDLE StdInp = GetStdHandle(STD_INPUT_HANDLE);
INPUT_RECORD InpRec;
DWORD EvtRed;

ReadConsoleInput(StdInp,&InpRec,1,&EvtRed);

if (EvtRed == 1 && InpRec.EvenType == MOUSE_EVENT)
{
    if (InpRec.MouseEvent.DwButtonState & FROM_LEFT_1ST_BUTTON_PRESSED)
    {
             *   *   *
    }
}
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now