Switch example resources to public domain ones.
@ -37,5 +37,5 @@ if(SFML_BUILD_GRAPHICS)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
if(SFML_BUILD_GRAPHICS AND SFML_BUILD_AUDIO)
|
if(SFML_BUILD_GRAPHICS AND SFML_BUILD_AUDIO)
|
||||||
add_subdirectory(pong)
|
add_subdirectory(tennis)
|
||||||
endif()
|
endif()
|
||||||
|
BIN
examples/android/app/src/main/assets/tuffy.ttf
Executable file
@ -91,21 +91,13 @@ int main(int argc, char *argv[])
|
|||||||
image.setOrigin(texture.getSize().x/2, texture.getSize().y/2);
|
image.setOrigin(texture.getSize().x/2, texture.getSize().y/2);
|
||||||
|
|
||||||
sf::Font font;
|
sf::Font font;
|
||||||
if (!font.loadFromFile("sansation.ttf"))
|
if (!font.loadFromFile("tuffy.ttf"))
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
sf::Text text("Tap anywhere to move the logo.", font, 64);
|
sf::Text text("Tap anywhere to move the logo.", font, 64);
|
||||||
text.setFillColor(sf::Color::Black);
|
text.setFillColor(sf::Color::Black);
|
||||||
text.setPosition(10, 10);
|
text.setPosition(10, 10);
|
||||||
|
|
||||||
// Loading canary.wav fails for me for now; haven't had time to test why
|
|
||||||
|
|
||||||
/*sf::Music music;
|
|
||||||
if(!music.openFromFile("canary.wav"))
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
|
|
||||||
music.play();*/
|
|
||||||
|
|
||||||
sf::View view = window.getDefaultView();
|
sf::View view = window.getDefaultView();
|
||||||
|
|
||||||
sf::Color background = sf::Color::White;
|
sf::Color background = sf::Color::White;
|
||||||
|
25
examples/asset_licenses.md
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# Assets used by SFML's example projects.
|
||||||
|
|
||||||
|
All assets are under public domain (CC0):
|
||||||
|
|
||||||
|
| Name | Author | Link |
|
||||||
|
| ------------------------------- | ------------------------- | -------------------------- |
|
||||||
|
| Tuffy 1.1 font | Thatcher Ulrich | [Ulrich's fonts][1] |
|
||||||
|
| sounds/resources/doodle_pop.ogg | MrZeusTheCoder | [public-domain][2] |
|
||||||
|
| tennis/resources/ball.wav | MrZeusTheCoder | [public-domain][2] |
|
||||||
|
| opengl/resources/background.jpg | Nidhoggn | [Open Game Art][3] |
|
||||||
|
| shader/resources/background.jpg | Arcana Dea | [Public Domain Images][4] |
|
||||||
|
| shader/resources/devices.png | Kenny.nl | [Game Icons Pack][5] |
|
||||||
|
| sound/resources/ding.flac | Kenny.nl | [Interface Sounds Pack][6] |
|
||||||
|
| win32/resources/image1.jpg | Kenny.nl | [Toon Character Pack][7] |
|
||||||
|
| win32/resources/image2.jpg | Kenny.nl | [Toon Character Pack][7] |
|
||||||
|
| sound/resources/killdeer.wav | US National Park Services | [Bird sounds][8] |
|
||||||
|
|
||||||
|
[1]: http://tulrich.com/fonts/
|
||||||
|
[2]: https://github.com/MrZeusTheCoder/public-domain
|
||||||
|
[3]: https://opengameart.org/content/backgrounds-3
|
||||||
|
[4]: https://www.publicdomainpictures.net/en/view-image.php?image=10979&picture=monarch-butterfly
|
||||||
|
[5]: https://www.kenney.nl/assets/game-icons
|
||||||
|
[6]: https://www.kenney.nl/assets/interface-sounds
|
||||||
|
[7]: https://www.kenney.nl/assets/toon-characters-1
|
||||||
|
[8]: https://www.nps.gov/subjects/sound/sounds-killdeer.htm
|
@ -39,9 +39,8 @@ set(SRC ${SRCROOT}/CocoaAppDelegate.h
|
|||||||
compile_xib(INPUT "${SRCROOT}/MainMenu.xib" OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/MainMenu.nib")
|
compile_xib(INPUT "${SRCROOT}/MainMenu.xib" OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/MainMenu.nib")
|
||||||
|
|
||||||
# all resource files
|
# all resource files
|
||||||
set(RESOURCES ${SRCROOT}/resources/logo.png
|
set(RESOURCES ${SRCROOT}/resources/icon.icns
|
||||||
${SRCROOT}/resources/icon.icns
|
${SRCROOT}/resources/tuffy.ttf
|
||||||
${SRCROOT}/resources/sansation.ttf
|
|
||||||
${SRCROOT}/resources/blue.png
|
${SRCROOT}/resources/blue.png
|
||||||
${SRCROOT}/resources/green.png
|
${SRCROOT}/resources/green.png
|
||||||
${SRCROOT}/resources/red.png
|
${SRCROOT}/resources/red.png
|
||||||
|
@ -54,7 +54,7 @@ struct SFMLmainWindow
|
|||||||
unsigned int wh = renderWindow.getSize().y;
|
unsigned int wh = renderWindow.getSize().y;
|
||||||
sprite.setPosition(sf::Vector2f(ww, wh) / 2.f);
|
sprite.setPosition(sf::Vector2f(ww, wh) / 2.f);
|
||||||
|
|
||||||
if (!font.loadFromFile(resPath + "/sansation.ttf"))
|
if (!font.loadFromFile(resPath + "/tuffy.ttf"))
|
||||||
NSLog(@"Couldn't load the font");
|
NSLog(@"Couldn't load the font");
|
||||||
|
|
||||||
text.setFillColor(sf::Color::White);
|
text.setFillColor(sf::Color::White);
|
||||||
|
BIN
examples/cocoa/resources/tuffy.ttf
Executable file
@ -85,7 +85,7 @@ int main()
|
|||||||
window.setVerticalSyncEnabled(true);
|
window.setVerticalSyncEnabled(true);
|
||||||
|
|
||||||
sf::Font font;
|
sf::Font font;
|
||||||
if (!font.loadFromFile("resources/sansation.ttf"))
|
if (!font.loadFromFile("resources/tuffy.ttf"))
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
// Create all of our graphics resources
|
// Create all of our graphics resources
|
||||||
|
BIN
examples/island/resources/tuffy.ttf
Executable file
@ -88,12 +88,12 @@ namespace
|
|||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
// Create the window of the application
|
// Create the window of the application
|
||||||
sf::RenderWindow window(sf::VideoMode(400, 680), "Joystick", sf::Style::Close);
|
sf::RenderWindow window(sf::VideoMode(400, 775), "Joystick", sf::Style::Close);
|
||||||
window.setVerticalSyncEnabled(true);
|
window.setVerticalSyncEnabled(true);
|
||||||
|
|
||||||
// Load the text font
|
// Load the text font
|
||||||
sf::Font font;
|
sf::Font font;
|
||||||
if (!font.loadFromFile("resources/sansation.ttf"))
|
if (!font.loadFromFile("resources/tuffy.ttf"))
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
// Set up our string conversion parameters
|
// Set up our string conversion parameters
|
||||||
|
BIN
examples/joystick/resources/tuffy.ttf
Executable file
@ -7,8 +7,7 @@ set(SRC ${SRCROOT}/OpenGL.cpp)
|
|||||||
if (SFML_OS_IOS)
|
if (SFML_OS_IOS)
|
||||||
set(RESOURCES
|
set(RESOURCES
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/resources/background.jpg
|
${CMAKE_CURRENT_SOURCE_DIR}/resources/background.jpg
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/resources/texture.jpg
|
${CMAKE_CURRENT_SOURCE_DIR}/resources/tuffy.ttf)
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/resources/sansation.ttf)
|
|
||||||
set_source_files_properties(${RESOURCES} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
|
set_source_files_properties(${RESOURCES} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ int main()
|
|||||||
|
|
||||||
// Create some text to draw on top of our OpenGL object
|
// Create some text to draw on top of our OpenGL object
|
||||||
sf::Font font;
|
sf::Font font;
|
||||||
if (!font.loadFromFile(resourcesDir() + "sansation.ttf"))
|
if (!font.loadFromFile(resourcesDir() + "tuffy.ttf"))
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
sf::Text text("SFML / OpenGL demo", font);
|
sf::Text text("SFML / OpenGL demo", font);
|
||||||
sf::Text sRgbInstructions("Press space to toggle sRGB conversion", font);
|
sf::Text sRgbInstructions("Press space to toggle sRGB conversion", font);
|
||||||
@ -63,13 +63,13 @@ int main()
|
|||||||
text.setFillColor(sf::Color(255, 255, 255, 170));
|
text.setFillColor(sf::Color(255, 255, 255, 170));
|
||||||
sRgbInstructions.setFillColor(sf::Color(255, 255, 255, 170));
|
sRgbInstructions.setFillColor(sf::Color(255, 255, 255, 170));
|
||||||
mipmapInstructions.setFillColor(sf::Color(255, 255, 255, 170));
|
mipmapInstructions.setFillColor(sf::Color(255, 255, 255, 170));
|
||||||
text.setPosition(250.f, 450.f);
|
text.setPosition(280.f, 450.f);
|
||||||
sRgbInstructions.setPosition(150.f, 500.f);
|
sRgbInstructions.setPosition(175.f, 500.f);
|
||||||
mipmapInstructions.setPosition(180.f, 550.f);
|
mipmapInstructions.setPosition(200.f, 550.f);
|
||||||
|
|
||||||
// Load a texture to apply to our 3D cube
|
// Load a texture to apply to our 3D cube
|
||||||
sf::Texture texture;
|
sf::Texture texture;
|
||||||
if (!texture.loadFromFile(resourcesDir() + "texture.jpg"))
|
if (!texture.loadFromFile(resourcesDir() + "logo.png"))
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
// Attempt to generate a mipmap for our cube texture
|
// Attempt to generate a mipmap for our cube texture
|
||||||
@ -209,7 +209,7 @@ int main()
|
|||||||
if (mipmapEnabled)
|
if (mipmapEnabled)
|
||||||
{
|
{
|
||||||
// We simply reload the texture to disable mipmapping
|
// We simply reload the texture to disable mipmapping
|
||||||
if (!texture.loadFromFile(resourcesDir() + "texture.jpg"))
|
if (!texture.loadFromFile(resourcesDir() + "logo.png"))
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
mipmapEnabled = false;
|
mipmapEnabled = false;
|
||||||
@ -274,7 +274,7 @@ int main()
|
|||||||
#ifdef SFML_SYSTEM_IOS
|
#ifdef SFML_SYSTEM_IOS
|
||||||
pos = sf::Touch::getPosition(0);
|
pos = sf::Touch::getPosition(0);
|
||||||
#else
|
#else
|
||||||
pos = sf::Mouse::getPosition();
|
pos = sf::Mouse::getPosition(window);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
float x = pos.x * 200.f / window.getSize().x - 100.f;
|
float x = pos.x * 200.f / window.getSize().x - 100.f;
|
||||||
|
Before Width: | Height: | Size: 140 KiB After Width: | Height: | Size: 105 KiB |
BIN
examples/opengl/resources/logo.png
Normal file
After Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 20 KiB |
BIN
examples/opengl/resources/tuffy.ttf
Executable file
@ -17,7 +17,7 @@ class Pixelate : public Effect
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
Pixelate() :
|
Pixelate() :
|
||||||
Effect("pixelate")
|
Effect("Pixelate")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ class WaveBlur : public Effect
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
WaveBlur() :
|
WaveBlur() :
|
||||||
Effect("wave + blur")
|
Effect("Wave + Blur")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -127,7 +127,7 @@ class StormBlink : public Effect
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
StormBlink() :
|
StormBlink() :
|
||||||
Effect("storm + blink")
|
Effect("Storm + Blink")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -182,7 +182,7 @@ class Edge : public Effect
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
Edge() :
|
Edge() :
|
||||||
Effect("edge post-effect")
|
Effect("Edge Post-effect")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,7 +266,7 @@ class Geometry : public Effect
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
Geometry() :
|
Geometry() :
|
||||||
Effect("geometry shader billboards"),
|
Effect("Geometry Shader Billboards"),
|
||||||
m_pointCloud(sf::Points, 10000)
|
m_pointCloud(sf::Points, 10000)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -352,7 +352,7 @@ int main()
|
|||||||
|
|
||||||
// Load the application font and pass it to the Effect class
|
// Load the application font and pass it to the Effect class
|
||||||
sf::Font font;
|
sf::Font font;
|
||||||
if (!font.loadFromFile("resources/sansation.ttf"))
|
if (!font.loadFromFile("resources/tuffy.ttf"))
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
Effect::setFont(font);
|
Effect::setFont(font);
|
||||||
|
|
||||||
@ -438,7 +438,11 @@ int main()
|
|||||||
effects[current]->update(clock.getElapsedTime().asSeconds(), x, y);
|
effects[current]->update(clock.getElapsedTime().asSeconds(), x, y);
|
||||||
|
|
||||||
// Clear the window
|
// Clear the window
|
||||||
window.clear(sf::Color(255, 128, 0));
|
if(effects[current]->getName() == "Edge Post-effect"){
|
||||||
|
window.clear(sf::Color::White);
|
||||||
|
} else {
|
||||||
|
window.clear(sf::Color(50, 50, 50));
|
||||||
|
}
|
||||||
|
|
||||||
// Draw the current example
|
// Draw the current example
|
||||||
window.draw(*effects[current]);
|
window.draw(*effects[current]);
|
||||||
|
Before Width: | Height: | Size: 52 KiB After Width: | Height: | Size: 65 KiB |
Before Width: | Height: | Size: 50 KiB After Width: | Height: | Size: 7.0 KiB |
BIN
examples/shader/resources/tuffy.ttf
Executable file
@ -15,11 +15,11 @@ void playSound()
|
|||||||
{
|
{
|
||||||
// Load a sound buffer from a wav file
|
// Load a sound buffer from a wav file
|
||||||
sf::SoundBuffer buffer;
|
sf::SoundBuffer buffer;
|
||||||
if (!buffer.loadFromFile("resources/canary.wav"))
|
if (!buffer.loadFromFile("resources/killdeer.wav"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Display sound informations
|
// Display sound informations
|
||||||
std::cout << "canary.wav:" << std::endl;
|
std::cout << "killdeer.wav:" << std::endl;
|
||||||
std::cout << " " << buffer.getDuration().asSeconds() << " seconds" << std::endl;
|
std::cout << " " << buffer.getDuration().asSeconds() << " seconds" << std::endl;
|
||||||
std::cout << " " << buffer.getSampleRate() << " samples / sec" << std::endl;
|
std::cout << " " << buffer.getSampleRate() << " samples / sec" << std::endl;
|
||||||
std::cout << " " << buffer.getChannelCount() << " channels" << std::endl;
|
std::cout << " " << buffer.getChannelCount() << " channels" << std::endl;
|
||||||
@ -88,7 +88,7 @@ int main()
|
|||||||
playSound();
|
playSound();
|
||||||
|
|
||||||
// Play music from an ogg file
|
// Play music from an ogg file
|
||||||
playMusic("orchestral.ogg");
|
playMusic("doodle_pop.ogg");
|
||||||
|
|
||||||
// Play music from a flac file
|
// Play music from a flac file
|
||||||
playMusic("ding.flac");
|
playMusic("ding.flac");
|
||||||
|
BIN
examples/sound/resources/doodle_pop.ogg
Normal file
BIN
examples/sound/resources/killdeer.wav
Normal file
@ -1,17 +1,17 @@
|
|||||||
|
|
||||||
set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/pong)
|
set(SRCROOT ${PROJECT_SOURCE_DIR}/examples/tennis)
|
||||||
|
|
||||||
# all source files
|
# all source files
|
||||||
set(SRC ${SRCROOT}/Pong.cpp)
|
set(SRC ${SRCROOT}/Tennis.cpp)
|
||||||
if (SFML_OS_IOS)
|
if (SFML_OS_IOS)
|
||||||
set(RESOURCES
|
set(RESOURCES
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/resources/ball.wav
|
${CMAKE_CURRENT_SOURCE_DIR}/resources/ball.wav
|
||||||
${CMAKE_CURRENT_SOURCE_DIR}/resources/sansation.ttf)
|
${CMAKE_CURRENT_SOURCE_DIR}/resources/tuffy.ttf)
|
||||||
set_source_files_properties(${RESOURCES} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
|
set_source_files_properties(${RESOURCES} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# define the pong target
|
# define the pong target
|
||||||
sfml_add_example(pong GUI_APP
|
sfml_add_example(tennis GUI_APP
|
||||||
SOURCES ${SRC}
|
SOURCES ${SRC}
|
||||||
BUNDLE_RESOURCES ${RESOURCES}
|
BUNDLE_RESOURCES ${RESOURCES}
|
||||||
DEPENDS sfml-audio sfml-graphics
|
DEPENDS sfml-audio sfml-graphics
|
@ -39,7 +39,7 @@ int main()
|
|||||||
float ballRadius = 10.f;
|
float ballRadius = 10.f;
|
||||||
|
|
||||||
// Create the window of the application
|
// Create the window of the application
|
||||||
sf::RenderWindow window(sf::VideoMode(gameWidth, gameHeight, 32), "SFML Pong",
|
sf::RenderWindow window(sf::VideoMode(gameWidth, gameHeight, 32), "SFML Tennis",
|
||||||
sf::Style::Titlebar | sf::Style::Close);
|
sf::Style::Titlebar | sf::Style::Close);
|
||||||
window.setVerticalSyncEnabled(true);
|
window.setVerticalSyncEnabled(true);
|
||||||
|
|
||||||
@ -49,6 +49,14 @@ int main()
|
|||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
sf::Sound ballSound(ballSoundBuffer);
|
sf::Sound ballSound(ballSoundBuffer);
|
||||||
|
|
||||||
|
// Create the SFML logo texture:
|
||||||
|
sf::Texture sfmlLogoTexture;
|
||||||
|
if(!sfmlLogoTexture.loadFromFile(resourcesDir() + "sfml_logo.png"))
|
||||||
|
return EXIT_FAILURE;
|
||||||
|
sf::Sprite sfmlLogo;
|
||||||
|
sfmlLogo.setTexture(sfmlLogoTexture);
|
||||||
|
sfmlLogo.setPosition(170, 50);
|
||||||
|
|
||||||
// Create the left paddle
|
// Create the left paddle
|
||||||
sf::RectangleShape leftPaddle;
|
sf::RectangleShape leftPaddle;
|
||||||
leftPaddle.setSize(paddleSize - sf::Vector2f(3, 3));
|
leftPaddle.setSize(paddleSize - sf::Vector2f(3, 3));
|
||||||
@ -68,27 +76,27 @@ int main()
|
|||||||
// Create the ball
|
// Create the ball
|
||||||
sf::CircleShape ball;
|
sf::CircleShape ball;
|
||||||
ball.setRadius(ballRadius - 3);
|
ball.setRadius(ballRadius - 3);
|
||||||
ball.setOutlineThickness(3);
|
ball.setOutlineThickness(2);
|
||||||
ball.setOutlineColor(sf::Color::Black);
|
ball.setOutlineColor(sf::Color::Black);
|
||||||
ball.setFillColor(sf::Color::White);
|
ball.setFillColor(sf::Color::White);
|
||||||
ball.setOrigin(ballRadius / 2, ballRadius / 2);
|
ball.setOrigin(ballRadius / 2, ballRadius / 2);
|
||||||
|
|
||||||
// Load the text font
|
// Load the text font
|
||||||
sf::Font font;
|
sf::Font font;
|
||||||
if (!font.loadFromFile(resourcesDir() + "sansation.ttf"))
|
if (!font.loadFromFile(resourcesDir() + "tuffy.ttf"))
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
|
||||||
// Initialize the pause message
|
// Initialize the pause message
|
||||||
sf::Text pauseMessage;
|
sf::Text pauseMessage;
|
||||||
pauseMessage.setFont(font);
|
pauseMessage.setFont(font);
|
||||||
pauseMessage.setCharacterSize(40);
|
pauseMessage.setCharacterSize(40);
|
||||||
pauseMessage.setPosition(170.f, 150.f);
|
pauseMessage.setPosition(170.f, 200.f);
|
||||||
pauseMessage.setFillColor(sf::Color::White);
|
pauseMessage.setFillColor(sf::Color::White);
|
||||||
|
|
||||||
#ifdef SFML_SYSTEM_IOS
|
#ifdef SFML_SYSTEM_IOS
|
||||||
pauseMessage.setString("Welcome to SFML pong!\nTouch the screen to start the game");
|
pauseMessage.setString("Welcome to SFML Tennis!\nTouch the screen to start the game.");
|
||||||
#else
|
#else
|
||||||
pauseMessage.setString("Welcome to SFML pong!\nPress space to start the game");
|
pauseMessage.setString("Welcome to SFML Tennis!\n\nPress space to start the game.");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Define the paddles properties
|
// Define the paddles properties
|
||||||
@ -197,21 +205,21 @@ int main()
|
|||||||
ball.move(std::cos(ballAngle) * factor, std::sin(ballAngle) * factor);
|
ball.move(std::cos(ballAngle) * factor, std::sin(ballAngle) * factor);
|
||||||
|
|
||||||
#ifdef SFML_SYSTEM_IOS
|
#ifdef SFML_SYSTEM_IOS
|
||||||
const std::string inputString = "Touch the screen to restart";
|
const std::string inputString = "Touch the screen to restart.";
|
||||||
#else
|
#else
|
||||||
const std::string inputString = "Press space to restart or\nescape to exit";
|
const std::string inputString = "Press space to restart or\nescape to exit.";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Check collisions between the ball and the screen
|
// Check collisions between the ball and the screen
|
||||||
if (ball.getPosition().x - ballRadius < 0.f)
|
if (ball.getPosition().x - ballRadius < 0.f)
|
||||||
{
|
{
|
||||||
isPlaying = false;
|
isPlaying = false;
|
||||||
pauseMessage.setString("You Lost!\n" + inputString);
|
pauseMessage.setString("You Lost!\n\n" + inputString);
|
||||||
}
|
}
|
||||||
if (ball.getPosition().x + ballRadius > gameWidth)
|
if (ball.getPosition().x + ballRadius > gameWidth)
|
||||||
{
|
{
|
||||||
isPlaying = false;
|
isPlaying = false;
|
||||||
pauseMessage.setString("You Won!\n" + inputString);
|
pauseMessage.setString("You Won!\n\n" + inputString);
|
||||||
}
|
}
|
||||||
if (ball.getPosition().y - ballRadius < 0.f)
|
if (ball.getPosition().y - ballRadius < 0.f)
|
||||||
{
|
{
|
||||||
@ -259,7 +267,7 @@ int main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Clear the window
|
// Clear the window
|
||||||
window.clear(sf::Color(50, 200, 50));
|
window.clear(sf::Color(50, 50, 50));
|
||||||
|
|
||||||
if (isPlaying)
|
if (isPlaying)
|
||||||
{
|
{
|
||||||
@ -272,6 +280,7 @@ int main()
|
|||||||
{
|
{
|
||||||
// Draw the pause message
|
// Draw the pause message
|
||||||
window.draw(pauseMessage);
|
window.draw(pauseMessage);
|
||||||
|
window.draw(sfmlLogo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display things on screen
|
// Display things on screen
|
BIN
examples/tennis/resources/ball.wav
Normal file
BIN
examples/tennis/resources/sfml_logo.png
Normal file
After Width: | Height: | Size: 13 KiB |
BIN
examples/tennis/resources/tuffy.ttf
Executable file
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 14 KiB |
@ -60,9 +60,9 @@ subject to the following restrictions:
|
|||||||
<string>ResourcePath.mm</string>
|
<string>ResourcePath.mm</string>
|
||||||
<string>ResourcePath.hpp</string>
|
<string>ResourcePath.hpp</string>
|
||||||
<string>main.cpp</string>
|
<string>main.cpp</string>
|
||||||
<string>cute_image.jpg</string>
|
<string>background.jpg</string>
|
||||||
<string>nice_music.ogg</string>
|
<string>doodle_pop.ogg</string>
|
||||||
<string>sansation.ttf</string>
|
<string>tuffy.ttf</string>
|
||||||
<string>icon.png</string>
|
<string>icon.png</string>
|
||||||
</array>
|
</array>
|
||||||
|
|
||||||
@ -93,26 +93,26 @@ subject to the following restrictions:
|
|||||||
</dict>
|
</dict>
|
||||||
|
|
||||||
<!-- RESOURCES -->
|
<!-- RESOURCES -->
|
||||||
<key>cute_image.jpg</key>
|
<key>background.jpg</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>Path</key>
|
<key>Path</key>
|
||||||
<string>cute_image.jpg</string>
|
<string>background.jpg</string>
|
||||||
<key>Group</key>
|
<key>Group</key>
|
||||||
<string>Resources</string>
|
<string>Resources</string>
|
||||||
</dict>
|
</dict>
|
||||||
|
|
||||||
<key>nice_music.ogg</key>
|
<key>doodle_pop.ogg</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>Path</key>
|
<key>Path</key>
|
||||||
<string>nice_music.ogg</string>
|
<string>doodle_pop.ogg</string>
|
||||||
<key>Group</key>
|
<key>Group</key>
|
||||||
<string>Resources</string>
|
<string>Resources</string>
|
||||||
</dict>
|
</dict>
|
||||||
|
|
||||||
<key>sansation.ttf</key>
|
<key>tuffy.ttf</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>Path</key>
|
<key>Path</key>
|
||||||
<string>sansation.ttf</string>
|
<string>tuffy.ttf</string>
|
||||||
<key>Group</key>
|
<key>Group</key>
|
||||||
<string>Resources</string>
|
<string>Resources</string>
|
||||||
</dict>
|
</dict>
|
||||||
|
BIN
tools/xcode/templates/SFML/SFML App.xctemplate/background.jpg
vendored
Normal file
After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 140 KiB |
BIN
tools/xcode/templates/SFML/SFML App.xctemplate/doodle_pop.ogg
vendored
Normal file
@ -34,14 +34,14 @@ int main(int, char const**)
|
|||||||
|
|
||||||
// Load a sprite to display
|
// Load a sprite to display
|
||||||
sf::Texture texture;
|
sf::Texture texture;
|
||||||
if (!texture.loadFromFile(resourcePath() + "cute_image.jpg")) {
|
if (!texture.loadFromFile(resourcePath() + "background.jpg")) {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
sf::Sprite sprite(texture);
|
sf::Sprite sprite(texture);
|
||||||
|
|
||||||
// Create a graphical text to display
|
// Create a graphical text to display
|
||||||
sf::Font font;
|
sf::Font font;
|
||||||
if (!font.loadFromFile(resourcePath() + "sansation.ttf")) {
|
if (!font.loadFromFile(resourcePath() + "tuffy.ttf")) {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
sf::Text text("Hello SFML", font, 50);
|
sf::Text text("Hello SFML", font, 50);
|
||||||
@ -49,7 +49,7 @@ int main(int, char const**)
|
|||||||
|
|
||||||
// Load a music to play
|
// Load a music to play
|
||||||
sf::Music music;
|
sf::Music music;
|
||||||
if (!music.openFromFile(resourcePath() + "nice_music.ogg")) {
|
if (!music.openFromFile(resourcePath() + "doodle_pop.ogg")) {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
tools/xcode/templates/SFML/SFML App.xctemplate/tuffy.ttf
vendored
Executable file
@ -58,9 +58,9 @@ subject to the following restrictions:
|
|||||||
<key>Nodes</key>
|
<key>Nodes</key>
|
||||||
<array>
|
<array>
|
||||||
<string>main.cpp</string>
|
<string>main.cpp</string>
|
||||||
<string>cute_image.jpg</string>
|
<string>background.jpg</string>
|
||||||
<string>nice_music.ogg</string>
|
<string>doodle_pop.ogg</string>
|
||||||
<string>sansation.ttf</string>
|
<string>tuffy.ttf</string>
|
||||||
<string>icon.png</string>
|
<string>icon.png</string>
|
||||||
</array>
|
</array>
|
||||||
|
|
||||||
@ -77,26 +77,26 @@ subject to the following restrictions:
|
|||||||
</dict>
|
</dict>
|
||||||
|
|
||||||
<!-- RESOURCES -->
|
<!-- RESOURCES -->
|
||||||
<key>cute_image.jpg</key>
|
<key>background.jpg</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>Path</key>
|
<key>Path</key>
|
||||||
<string>cute_image.jpg</string>
|
<string>background.jpg</string>
|
||||||
<key>Group</key>
|
<key>Group</key>
|
||||||
<string>Resources</string>
|
<string>Resources</string>
|
||||||
</dict>
|
</dict>
|
||||||
|
|
||||||
<key>nice_music.ogg</key>
|
<key>doodle_pop.ogg</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>Path</key>
|
<key>Path</key>
|
||||||
<string>nice_music.ogg</string>
|
<string>doodle_pop.ogg</string>
|
||||||
<key>Group</key>
|
<key>Group</key>
|
||||||
<string>Resources</string>
|
<string>Resources</string>
|
||||||
</dict>
|
</dict>
|
||||||
|
|
||||||
<key>sansation.ttf</key>
|
<key>tuffy.ttf</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>Path</key>
|
<key>Path</key>
|
||||||
<string>sansation.ttf</string>
|
<string>tuffy.ttf</string>
|
||||||
<key>Group</key>
|
<key>Group</key>
|
||||||
<string>Resources</string>
|
<string>Resources</string>
|
||||||
</dict>
|
</dict>
|
||||||
|
BIN
tools/xcode/templates/SFML/SFML CLT.xctemplate/background.jpg
vendored
Normal file
After Width: | Height: | Size: 48 KiB |
Before Width: | Height: | Size: 140 KiB |
BIN
tools/xcode/templates/SFML/SFML CLT.xctemplate/doodle_pop.ogg
vendored
Normal file
@ -5,7 +5,7 @@
|
|||||||
//
|
//
|
||||||
// This code will work only if you selected window, graphics and audio.
|
// This code will work only if you selected window, graphics and audio.
|
||||||
//
|
//
|
||||||
// In order to load the resources like cute_image.png, you have to set up
|
// In order to load the resources like background.png, you have to set up
|
||||||
// your target scheme:
|
// your target scheme:
|
||||||
//
|
//
|
||||||
// - Select "Edit Scheme…" in the "Product" menu;
|
// - Select "Edit Scheme…" in the "Product" menu;
|
||||||
@ -32,14 +32,14 @@ int main(int argc, char const** argv)
|
|||||||
|
|
||||||
// Load a sprite to display
|
// Load a sprite to display
|
||||||
sf::Texture texture;
|
sf::Texture texture;
|
||||||
if (!texture.loadFromFile("cute_image.jpg")) {
|
if (!texture.loadFromFile("background.jpg")) {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
sf::Sprite sprite(texture);
|
sf::Sprite sprite(texture);
|
||||||
|
|
||||||
// Create a graphical text to display
|
// Create a graphical text to display
|
||||||
sf::Font font;
|
sf::Font font;
|
||||||
if (!font.loadFromFile("sansation.ttf")) {
|
if (!font.loadFromFile("tuffy.ttf")) {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
sf::Text text("Hello SFML", font, 50);
|
sf::Text text("Hello SFML", font, 50);
|
||||||
@ -47,7 +47,7 @@ int main(int argc, char const** argv)
|
|||||||
|
|
||||||
// Load a music to play
|
// Load a music to play
|
||||||
sf::Music music;
|
sf::Music music;
|
||||||
if (!music.openFromFile("nice_music.ogg")) {
|
if (!music.openFromFile("doodle_pop.ogg")) {
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BIN
tools/xcode/templates/SFML/SFML CLT.xctemplate/tuffy.ttf
vendored
Executable file
@ -13,13 +13,14 @@ You can find more resources and information on the official web site: http://www
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Author & License
|
Authors & Licenses
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
The templates were written by Marco Antognini <antognini.marco@gmail.com> and are provided under
|
The templates were written by Marco Antognini <antognini.marco@gmail.com> and are provided under
|
||||||
the terms of the zlib/png license: http://opensource.org/licenses/zlib-license.php
|
the terms of the zlib/png license: http://opensource.org/licenses/zlib-license.php
|
||||||
|
|
||||||
|
The assets including doodle_pop.ogg and background.jpg are public domain. More information
|
||||||
|
can be found in the examples/ folder.
|
||||||
|
|
||||||
Features
|
Features
|
||||||
--------
|
--------
|
||||||
|