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
Solved

URGENT: CONSOLE APP

Posted on 2000-05-12
3
187 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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
Fast access to array, using indexes, smart iterative search 2 117
Find Visual Studio Tools 2 111
SNMP error No Such Object available on this agent at this OID 3 298
C++ question 3 70
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

856 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