Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

URGENT: CONSOLE APP

Posted on 2000-05-12
3
Medium Priority
?
192 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 400 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
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.
Suggested Courses

722 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