Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - MosteM

Pages: [1]
1
Window / Problem with IsKeyDown() allthough IsMouseButtonDown() works
« on: February 27, 2009, 02:38:48 am »
OH NO!!!
Thank you so much!

I'm quite new to object orientated programming too which is probably why I just oversaw that while adding the new keyboard functionality to the function. As you might have seen, the function is quite messy because I added some new functionalities and haven't cleaned up until now.

Thanks again!

2
Window / Problem with IsKeyDown() allthough IsMouseButtonDown() works
« on: February 27, 2009, 02:20:38 am »
Of course! And thank you for the fast reply.

I'm using WinXp Sp3 32 Bit and no fancy keyboard or mouse.

This is my main loop:

Code: [Select]

while(Win->IsOpened())
{
while(Win->GetEvent(*Ereignis))
{
if(Ereignis->Type == Event::Closed)
{
Win->Close();
}
if((Ereignis->Type == Event::KeyPressed) && (Ereignis->Key.Code == Key::Escape))
{
Win->Close();
}
if((Ereignis->Type == Event::KeyPressed) && (Ereignis->Key.Code == Key::C))
{
Feld.Neu();
}
if((Ereignis->Type == Event::KeyPressed) && (Ereignis->Key.Code == Key::D))
{
DichteAusgabe = !DichteAusgabe;
}
if((Ereignis->Type == Event::KeyPressed) && (Ereignis->Key.Code == Key::V))
{
GeschwAusgabe = !GeschwAusgabe;
}
}
Ausfuehrzeit += Win->GetFrameTime();
while(Ausfuehrzeit > dt)
{
//eingabe

//physik
Manager->Update();                  //THIS IS IMPORTANT!!!

Ausfuehrzeit -= dt;
}
//grafik
Render->BeginneMalen();

if(GeschwAusgabe)
{
Manager->MaleGeschw();
}
if(DichteAusgabe)
{
Manager->MaleDichte();
}

Render->StoppeMalen();

}


The if-statement in the main loop is for a constant time step. Manager->Update(); This is where all the calculations and the input are handled. All it does is reset some values each frame then it takes care of the input and then it does the calculations. The function for the input which is shown below is called directly here.

Code: [Select]

mx = Eingabe->MausX();
my = Render->GetHoehe() - Eingabe->MausY();

if(!Win->GetInput().IsMouseButtonDown(sf::Mouse::Left) && !Win->GetInput().IsMouseButtonDown(sf::Mouse::Right))
{
mx0 = mx;
my0 = my;
return false;
}

i = (int)((Eingabe->MausX() / (skalar)Render->GetBreite()) * Feld.N + 1);
j = (int)((((skalar)Render->GetHoehe() - Eingabe->MausY()) / (skalar)Render->GetHoehe()) * Feld.N + 1);

if(i < 1 || i > (signed)Feld.N || j < 1 || j > (signed)Feld.N)
{
mx0 = mx;
my0 = my;
return false;
}

if(Win->GetInput().IsMouseButtonDown(sf::Mouse::Left))
{
Feld.u[Feld.IX(i, j)] = MAUSKRAFT * (mx-mx0);
Feld.v[Feld.IX(i, j)] = MAUSKRAFT * (my-my0);
}
if(Win->GetInput().IsMouseButtonDown(sf::Mouse::Right))
{
Feld.roh[Feld.IX(i, j)] = DICHTESTAERKE;
}
if(Win->GetInput().IsKeyDown(sf::Key::Left))                          //HERE IS THE PROBLEM
{
Feld.roh[Feld.IX(i, j)] = -DICHTESTAERKE;
}

mx0 = mx;
my0 = my;

return true;
}


The input through events in the main loop works.

If it helps I can translate the names into English.

3
Window / Problem with IsKeyDown() allthough IsMouseButtonDown() works
« on: February 27, 2009, 12:56:17 am »
Like the subject allready says the first piece of code works perfectly fine, but IsKeyDown() in the second one never returns true. Both pieces are from one member function and there is no code between them which could cause problems.

Code: [Select]

if(Win->GetInput().IsMouseButtonDown(sf::Mouse::Right))
{
...
}


Code: [Select]

if(Win->GetInput().IsKeyDown(sf::Key::A))
{
...
}


I've tested it with different keys and IsMouseButtonDown(sf::Mouse::Middle) for example doesn't work either. I hope I haven't overseen something obvious and would be very glad about an answer.

P.S.: I'm quite new to SFML, but until now it's fantastic!

Pages: [1]