add text demo
This commit is contained in:
parent
b56c29840c
commit
aaf6b5b709
2
Makefile
2
Makefile
@ -9,7 +9,7 @@ CPPFLAGS := -I$(SFML_DIR)/include
|
|||||||
CXXFLAGS := -mwindows
|
CXXFLAGS := -mwindows
|
||||||
LDFLAGS := -L$(SFML_DIR)/lib -lsfml-system -lsfml-window -lsfml-graphics -lopengl32 -lglu32 -static-libstdc++ -static-libgcc -mwindows
|
LDFLAGS := -L$(SFML_DIR)/lib -lsfml-system -lsfml-window -lsfml-graphics -lopengl32 -lglu32 -static-libstdc++ -static-libgcc -mwindows
|
||||||
|
|
||||||
all: clock window events opengl graphics dlls
|
all: clock window events opengl graphics text dlls
|
||||||
|
|
||||||
%: %.cpp
|
%: %.cpp
|
||||||
$(CXX) -o $@ $(CPPFLAGS) $(CXXFLAGS) $^ $(LDFLAGS)
|
$(CXX) -o $@ $(CPPFLAGS) $(CXXFLAGS) $^ $(LDFLAGS)
|
||||||
|
45
text.cpp
Normal file
45
text.cpp
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
#include <list>
|
||||||
|
#include <math.h>
|
||||||
|
#include <SFML/Graphics.hpp>
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
sf::Clock Clock;
|
||||||
|
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");
|
||||||
|
sf::String text("Hello");
|
||||||
|
text.Move(400, 300);
|
||||||
|
sf::String centered("Centered");
|
||||||
|
centered.SetCenter(centered.GetCharacterPos(8).x / 2.0f, 15);
|
||||||
|
centered.Move(100, 100);
|
||||||
|
|
||||||
|
float last_time = Clock.GetElapsedTime();
|
||||||
|
while (App.IsOpened())
|
||||||
|
{
|
||||||
|
float ticks = Clock.GetElapsedTime();
|
||||||
|
float elapsed = ticks - last_time;
|
||||||
|
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.Clear(sf::Color(0, 0, 0));
|
||||||
|
|
||||||
|
text.Rotate(360.0 * elapsed / 2);
|
||||||
|
centered.Rotate(360.0 * elapsed / 2);
|
||||||
|
App.Draw(text);
|
||||||
|
App.Draw(centered);
|
||||||
|
|
||||||
|
App.Display();
|
||||||
|
last_time = ticks;
|
||||||
|
}
|
||||||
|
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user