Solved

URGENT: CONSOLE APP

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

Title # Comments Views Activity
Quicksort a dynamic deque 33 79
operator overload: incompatible type and too many params 5 89
Create a path if not exists 7 106
Why isn't object file created? 6 86
  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 goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

713 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