0 Members and 1 Guest are viewing this topic.
#include <SFML/System.hpp>#include <SFML/Graphics.hpp>#include <SFML/Window.hpp>#include <SFML/Audio.hpp>#include <iostream>#include <cmath> int main(){ // Create Window sf::RenderWindow App(sf::VideoMode(800, 600, 32), "Race of Life"); // Create a sprite for the background sf::Image HintergrundImage; if (!HintergrundImage.LoadFromFile("can.jpg")) return EXIT_FAILURE; sf::Sprite Hintergrund(HintergrundImage); sf::Image StartImage; if (!StartImage.LoadFromFile("start.png")) return EXIT_FAILURE; sf::Sprite Start(StartImage); sf::Image //Load Musik sf::SoundBuffer buffer; buffer.LoadFromFile( "IM.ogg" ); sf::Sound sound( buffer ); sound.Play(); // Start game loop while (App.IsOpened()) { // Process events sf::Event Event; while (App.GetEvent(Event)) { // Close window : exit if (Event.Type == sf::Event::Closed) App.Close(); } float ElapsedTime = App.GetFrameTime(); App.Draw(Hintergrund); App.Draw(Start); App.Display(); sf::Sleep(0.0015f); } return 0;}
if(mouseX > startImgX && mouseX < startImgX + startImgWidth && mouseY > startImgY && mouseY < startImgY + startImgHeight){ race.run();}
sf::Vector2f mouse (App.ConvertCoords (App.GetInput().GetMouseX(), App.GetInput().GetMouseY()));