Solved

URGENT: CONSOLE APP

Posted on 2000-05-12
3
186 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

Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

770 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