Update MiniEngine_Simple.hpp

This commit is contained in:
Kirigaya Kazuto 2017-02-24 11:12:48 +08:00 committed by GitHub
parent 8541e817ef
commit 77e1d1153e

View File

@ -815,6 +815,63 @@ private:
};
class Event
{
public:
int gettype()
{
return e.type;
}
protected:
Event()=default;
SDL_Event e;
private:
friend class EventEngine;
};
class MouseButtonEvent : public Event
{
public:
int getx()
{
return e.button.x;
}
int gety()
{
return e.button.y;
}
int getbutton()
{
return e.button.button;
}
};
class EventEngine
{
public:
Event poll(bool mustNew=false) /// mustNew: false=SDL_PollEvent(&e) returns 0 ; true=SDL_PollEvent(&e) returns 1
{
Event e;
while(1)
{
int ret=SDL_PollEvent(&e.e);
if((mustNew&&ret)||!mustNew) break;
}
return e;
}
Event wait()
{
Event e;
SDL_WaitEvent(&e.e);
return e;
}
Event waitfor(int ms)
{
Event e;
SDL_WaitEventTimeout(&e.e,ms);
return e;
}
};
}/// End of namespace MiniEngine