From a134f7639660cedea8a681dd52928e65fc86999b Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sun, 4 Mar 2012 22:38:43 -0500 Subject: [PATCH] add events --- Makefile | 2 +- events.cpp | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100755 events.cpp diff --git a/Makefile b/Makefile index c185408..195f56b 100755 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ LD := $(PREFIX)-ld CPPFLAGS := -I$(SFML_DIR)/include LDFLAGS := -L$(SFML_DIR)/lib -lsfml-system -lsfml-window -static-libstdc++ -static-libgcc -all: clock window +all: clock window events %: %.cpp $(CXX) -o $@ $(CPPFLAGS) $^ $(LDFLAGS) diff --git a/events.cpp b/events.cpp new file mode 100755 index 0000000..019b867 --- /dev/null +++ b/events.cpp @@ -0,0 +1,25 @@ + +#include + +int main() +{ + sf::Window App(sf::VideoMode(800, 600, 32), "SFML Window"); + + while (App.IsOpened()) + { + sf::Event Event; + while (App.GetEvent(Event)) + { + if (Event.Type == sf::Event::Closed) + App.Close(); + + if ( (Event.Type == sf::Event::KeyPressed) + && (Event.Key.Code == sf::Key::Escape) ) + App.Close(); + } + + App.Display(); + } + + return EXIT_SUCCESS; +}