Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SFML\Graphics.hpp>
- #include "CRed.h"
- #include "CBlue.h"
- int main()
- {
- //ustawienie okna
- sf::RenderWindow window({ 1366, 720 }, "Bumper Cars", sf::Style::Fullscreen);
- window.setFramerateLimit(60);
- //pobranie tekstur z pliku
- sf::Texture texture1;
- texture1.loadFromFile("B_plansza.bmp");
- sf::Sprite map1;
- map1.setTexture(texture1);
- sf::Texture texture2;
- texture2.loadFromFile("B_car_red.png");
- CRed red1;
- red1.setTexture(texture2);
- sf::Texture texture3;
- texture3.loadFromFile("B_car_blue.png");
- CBlue blue1;
- blue1.setTexture(texture3);
- //ustawienie pozycji tekstur
- map1.setPosition(0, 0);
- red1.setPosition(300, 500);
- blue1.setPosition(800, 200);
- //główna pętla
- while (window.isOpen())
- {
- sf::Event event;
- while (window.pollEvent(event))
- {
- if (event.type == sf::Event::Closed)
- window.close();
- if (sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
- window.close();
- }
- red1.move_left(red1.velocity, red1.acceleration, red1, blue1, map1);
- red1.move_right(red1.velocity, red1.acceleration, red1, blue1, map1);
- red1.move_up(red1.velocity, red1.acceleration, red1, blue1, map1);
- red1.move_down(red1.velocity, red1.acceleration, red1, blue1, map1);
- window.clear();
- window.draw(map1);
- window.draw(red1);
- window.draw(blue1);
- window.display();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement