Hi, I am new on sfml and ever in programming(game, just small things).
I have tested small things like play music and load images. I've tested now to press "a" it shows then "A: 1" (like its true) and if I don't press a then "A: 0".
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::A))
{
Text.SetText("A: 1");
}
else if ((Event.Type == sf::Event::KeyReleased) && (Event.Key.Code == sf::Key::A))
{
Text.SetText("A: 0");
}
No i got the idea to make for all Keys from A to Z.
I know i need for() for this one, but i don't really know how.
I know it should be then
sf::Key::i and Text.SetText(i + ": 0");
But my problem is I don't know how to count keys of sfml from event. If i put my mouse on A it shows me =97 and Z = 122.
so was my idea to make
for(int i=sf::Key::A; i <= sf::Key::B; i++)
{
char Buffer[5];
//sprintf(Buffer,"%d\n", i);
//MessageBox(NULL,Buffer,"Error",MB_OK | MB_ICONEXCLAMATION | MB_TOPMOST);
if ((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == i))
{
Text.SetText(i+": 1");
}
else if ((Event.Type == sf::Event::KeyReleased) && (Event.Key.Code == i))
{
Text.SetText(i+": 0");
}
Its working but my problem is now in SetText. I don't know how to show A or B.[/code]