i need to create a toggle switch and detect a keypress but not continually output to the console
Update: i do not want code snippets or anything like that just try to point me in the direction of certain functions or things you think i may find useful i just started learning c++ 2 days ago and have been teaching myself this is the way i learn best
// game.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
#include <Windows.h>
using namespace std;
int en;
/*class entity {
bool alive;
bool asleep;
int health;
int x, y;
int affect;
string color;
public:
void set_values(bool, bool, int, int, int, int, string);
void display_values();
};
void entity::set_values(bool a, bool b, int c, int d, int e, int f, string g) {
alive = a;
asleep = b;
health = c;
x = d;
y = e;
affect = f;
color = g;
}
int main()
{
car cr;
while (true)
{
//needs to detect keypress but not repeatedly send the output
if (GetAsyncKeyState('W') & 0x8000)
{
cr.accelerate();
}
if (GetAsyncKeyState('S') & 0x8000)
{
cr.breaks();
}
if (GetAsyncKeyState('R') & 0x8000)
{
cr.start_stop();
}
}